s3-api

command module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2019 License: MIT Imports: 8 Imported by: 0

README

s3-api

This API provides simple restful API access to Amazon's S3 service.

Endpoints

GET /v1/s3/ping
GET /v1/s3/version
GET /v1/s3/metrics

# Managing buckets
POST /v1/s3/{account}/buckets
GET /v1/s3/{account}/buckets
HEAD /v1/s3/{account}/buckets/{bucket}
GET /v1/s3/{account}/buckets/{bucket}
PUT /v1/s3/{account}/buckets/{bucket}
DELETE /v1/s3/{account}/buckets/{bucket}

# Managing bucket users
POST /v1/s3/{account}/buckets/{bucket}/users
GET /v1/s3/{account}/buckets/{bucket}/users
GET /v1/s3/{account}/buckets/{bucket}/users/{user}
PUT /v1/s3/{account}/buckets/{bucket}/users/{user}
DELETE /v1/s3/{account}/buckets/{bucket}/users/{user}

# Managing websites
POST /v1/s3/{account}/websites
HEAD /v1/s3/{account}/websites/{website}
GET /v1/s3/{account}/websites/{website}
PUT /v1/s3/{account}/websites/{website}
DELETE /v1/s3/{account}/websites/{website}

# Managing website users
POST /v1/s3/{account}/websites/{website}/users
GET /v1/s3/{account}/websites/{website}/users
GET /v1/s3/{account}/websites/{website}/users/{user}
PUT /v1/s3/{account}/websites/{website}/users/{user}
DELETE /v1/s3/{account}/websites/{website}/users/{user}

Authentication

Authentication is accomplished via a pre-shared key. This is done via the X-Auth-Token header.

Access to buckets

When creating a bucket, by default, an IAM policy (of the same name) is created with full access to that bucket...

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:AbortMultipartUpload",
                "s3:DeleteBucketWebsite",
                "s3:DeleteObject",
                "s3:DeleteObjectVersion",
                "s3:GetAccelerateConfiguration",
                "s3:GetBucketAcl",
                "s3:GetBucketCORS",
                "s3:GetBucketLocation",
                "s3:GetBucketLogging",
                "s3:GetBucketNotification",
                "s3:GetBucketPolicy",
                "s3:GetBucketTagging",
                "s3:GetBucketVersioning",
                "s3:GetBucketWebsite",
                "s3:GetLifecycleConfiguration",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:GetObjectVersion",
                "s3:GetObjectVersionAcl",
                "s3:GetReplicationConfiguration",
                "s3:ListAllMyBuckets",
                "s3:ListBucket",
                "s3:ListBucketMultipartUploads",
                "s3:ListBucketVersions",
                "s3:ListMultipartUploadParts",
                "s3:PutAccelerateConfiguration",
                "s3:PutBucketAcl",
                "s3:PutBucketCORS",
                "s3:PutBucketLogging",
                "s3:PutBucketNotification",
                "s3:PutBucketPolicy",
                "s3:PutBucketRequestPayment",
                "s3:PutBucketTagging",
                "s3:PutBucketVersioning",
                "s3:PutBucketWebsite",
                "s3:PutLifecycleConfiguration",
                "s3:PutReplicationConfiguration",
                "s3:PutObject",
                "s3:PutObjectAcl",
                "s3:PutObjectVersionAcl",
                "s3:ReplicateDelete",
                "s3:ReplicateObject",
                "s3:RestoreObject"
            ],
            "Resource": [
                "arn:aws:s3:::my-awesome-bucket"
            ]
        },
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": [
                "arn:aws:s3:::my-awesome-bucket/*"
            ]
        }
    ]
}

and a group is created with that policy attached. To allow access to a bucket, create a bucket user by POSTing to the /v1/s3/{account}/buckets/{bucket}/users endpoint.

Examples

Get a list of buckets

GET /v1/s3/{account}/buckets

Response Code Definition
200 OK return the list of buckets
400 Bad Request badly formed request
404 Not Found account not found
500 Internal Server Error a server error occurred
Create a bucket

POST `/v1/s3/{account}/buckets

Request
{
    "Tags": [
        { "Key": "Application", "Value": "HowToGet" },
        { "Key": "COA", "Value": "Take.My.Money.$$$$" },
        { "Key": "CreatedBy", "Value": "Big Bird" }
    ],
    "BucketInput": {
        "Bucket": "foobarbucketname"
    }
}
Response
{
    "Bucket": "/foobarbucketname",
    "Policy": {
        "Arn": "arn:aws:iam::12345678910:policy/foobarbucketname-BktAdmPlc",
        "AttachmentCount": 0,
        "CreateDate": "2019-03-01T15:33:52Z",
        "DefaultVersionId": "v1",
        "Description": null,
        "IsAttachable": true,
        "Path": "/",
        "PermissionsBoundaryUsageCount": 0,
        "PolicyId": "ABCDEFGHI12345678",
        "PolicyName": "foobarbucketname-BktAdmPlc",
        "UpdateDate": "2019-03-01T15:33:52Z"
    },
    "Group": {
        "Arn": "arn:aws:iam::12345678910:group/foobarbucketname-BktAdmGrp",
        "CreateDate": "2019-03-01T15:33:52Z",
        "GroupId": "GROUPID123",
        "GroupName": "foobarbucketname-BktAdmGrp",
        "Path": "/"
    }
}
Response Code Definition
202 Accepted creation request accepted
400 Bad Request badly formed request
403 Forbidden you don't have access to bucket
404 Not Found account not found
409 Conflict bucket or iam policy already exists
429 Too Many Requests service or rate limit exceeded
500 Internal Server Error a server error occurred
503 Service Unavailable an AWS service is unavailable
Update a bucket

Updating a bucket currently only supports updating the bucket's tags

PUT /v1/s3/{account}/buckets/foobarbucketname

Request
{
    "Tags": [
        { "Key": "Application", "Value": "HowToGet" },
        { "Key": "COA", "Value": "Take.My.Money.$$$$" },
        { "Key": "CreatedBy", "Value": "Big Bird" }
    ]
}
Response Code Definition
200 OK deleted bucket
400 Bad Request badly formed request
500 Internal Server Error a server error occurred
Check if a bucket exists

HEAD /v1/s3/{account}/buckets/foobarbucketname

Response Code Definition
200 OK bucket exists
403 Forbidden you don't have access to bucket
404 Not Found account or bucket not found
500 Internal Server Error a server error occurred
Get information for a bucket

Getting details about a bucket currently only returns tagging information and if the bucket is empty

GET /v1/s3/{account}/buckets/foobarbucketname

Response Code Definition
200 OK deleted bucket
400 Bad Request badly formed request
500 Internal Server Error a server error occurred
Delete a bucket

DELETE `/v1/s3/{account}/buckets/{bucket}

Response Code Definition
200 OK deleted bucket
400 Bad Request badly formed request
403 Forbidden you don't have access to bucket
404 Not Found account or bucket not found
409 Conflict bucket is not empty
500 Internal Server Error a server error occurred
Create a bucket user

POST `/v1/s3/{account}/buckets/{bucket}/users

Request
{
    "UserName": "somebucketuser"
}
Response
{
    "User": {
        "Arn": "arn:aws:iam::12345678910:user/somebucketuser",
        "CreateDate": "2019-03-01T16:11:00Z",
        "PasswordLastUsed": null,
        "Path": "/",
        "PermissionsBoundary": null,
        "Tags": null,
        "UserId": "AIDAJJSBBEAVOQLFAAUCG",
        "UserName": "somebucketuser"
    },
    "AccessKey": {
        "AccessKeyId": "ABCDEFGHIJ12345678",
        "CreateDate": "2019-03-01T16:11:00Z",
        "SecretAccessKey": "sssshimsupersekretdonttellanyoneyousawme",
        "Status": "Active",
        "UserName": "somebucketuser"
    }
}
Response Code Definition
200 OK user created
400 Bad Request badly formed request
403 Forbidden you don't have access to bucket
404 Not Found account or user not found when creating key
409 Conflict user already exists
429 Too Many Requests service or rate limit exceeded
500 Internal Server Error a server error occurred
Get a bucket user's details

GET /v1/s3/{account}/bucket/users/{user}

Response
{
    "User": {
        "Arn": "arn:aws:iam::12345678910:user/somebucketuser",
        "CreateDate": "2019-03-19T18:31:14Z",
        "PasswordLastUsed": null,
        "Path": "/",
        "PermissionsBoundary": null,
        "Tags": null,
        "UserId": "AIDAJJSBBEAVOQLFAAUCG",
        "UserName": "somebucketuser"
    },
    "AccessKeys": [
        {
            "AccessKeyId": "AKIAJTGA5ITTTJ7WOR7A",
            "CreateDate": "2019-03-19T18:31:14Z",
            "Status": "Active",
            "UserName": "somebucketuser"
        }
    ],
    "Groups": [
        {
            "Arn": "arn:aws:iam::12345678910:group/somebucketuser",
            "CreateDate": "2019-03-19T14:20:01Z",
            "GroupId": "AGPAJ6SYNPMFP6O5KXQJW",
            "GroupName": "somebucketuser-BktAdmGrp",
            "Path": "/"
        }
    ],
    "Policies": [
        {
            "Arn": "arn:aws:iam::12345678910:policy/somebucketuser-BktAdmPlc",
            "PolicyName": "somebucketuser-BktAdmPlc"
        }
    ]
}
Reset access keys for a bucket user

PUT /v1/s3/{account}/buckets/{bucket}/users/{user}

Response
{
    "DeletedKeyIds": [
        "ABCDEFGHIJK123456789"
    ],
    "AccessKey": {
        "AccessKeyId": "LMNOPQRSTUVW123456789",
        "CreateDate": "2019-03-01T16:14:07Z",
        "SecretAccessKey": "sssshimsupersekretdonttellanyoneyousawme",
        "Status": "Active",
        "UserName": "someuser-admin1"
    }
}
Response Code Definition
200 OK keys reset successfully
400 Bad Request badly formed request
403 Forbidden you don't have access to delete the user
404 Not Found account or user not found
429 Too Many Requests service or rate limit exceeded
500 Internal Server Error a server error occurred
List users for a bucket

GET `/v1/s3/{account}/buckets/{bucket}/users/{user}

Response
[
    {
        "Arn": "arn:aws:iam::12345678910:user/someuser-admin1",
        "CreateDate": "2019-03-01T16:11:00Z",
        "PasswordLastUsed": null,
        "Path": "/",
        "PermissionsBoundary": null,
        "Tags": null,
        "UserId": "ABCDEFGHI12345678",
        "UserName": "someuser-admin1"
    },
        {
        "Arn": "arn:aws:iam::12345678910:user/someuser-admin2",
        "CreateDate": "2019-03-01T16:11:00Z",
        "PasswordLastUsed": null,
        "Path": "/",
        "PermissionsBoundary": null,
        "Tags": null,
        "UserId": "ZYXWUTS87654321",
        "UserName": "someuser-admin2"
    }
]
Delete a bucket user

DELETE `/v1/s3/{account}/buckets/{bucket}/users/{user}

Response Code Definition
200 OK deleted user
400 Bad Request badly formed request
403 Forbidden you don't have access to delete the user
404 Not Found account or user not found
429 Too Many Requests service or rate limit exceeded
500 Internal Server Error a server error occurred
Create a website

POST /v1/s3/{account}/websites

Request
{
    "Tags": [
        { "Key": "Application", "Value": "HowToGet" },
        { "Key": "COA" "Value", "Value": "Take.My.Money.$$$$" },
        { "Key": "CreatedBy", "Value": "Big Bird" }
    ],
    "BucketInput": {
        "Bucket": "foobar.bulldogs.cloud"
    }
}
Response
{
    "Bucket": "/foobar.bulldogs.cloud",
    "Policy": {
        "Arn": "arn:aws:iam::12345678910:policy/foobar.bulldogs.cloud-BktAdmPlc",
        "AttachmentCount": 0,
        "CreateDate": "2019-03-01T15:33:52Z",
        "DefaultVersionId": "v1",
        "Description": null,
        "IsAttachable": true,
        "Path": "/",
        "PermissionsBoundaryUsageCount": 0,
        "PolicyId": "ABCDEFGHI12345678",
        "PolicyName": "foobar.bulldogs.cloud-BktAdmPlc",
        "UpdateDate": "2019-03-01T15:33:52Z"
    },
    "Group": {
        "Arn": "arn:aws:iam::12345678910:group/foobar.bulldogs.cloud-BktAdmGrp",
        "CreateDate": "2019-03-01T15:33:52Z",
        "GroupId": "GROUPID123",
        "GroupName": "foobar.bulldogs.cloud-BktAdmGrp",
        "Path": "/"
    }
}
Response Code Definition
202 Accepted creation request accepted
400 Bad Request badly formed request
403 Forbidden you don't have access to bucket
404 Not Found account not found
409 Conflict bucket or iam policy already exists
429 Too Many Requests service or rate limit exceeded
500 Internal Server Error a server error occurred
503 Service Unavailable an AWS service is unavailable
Check if a website exists

HEAD /v1/s3/{account}/websites/{website}

See Check if a bucket exists

Get information for a website

Getting details about a website currently only returns tagging information and if the bucket is empty

GET /v1/s3/{account}/websites/{website}

See Get information for a bucket

Update a website

Updating a website currently only supports updating the bucket's tags

PUT /v1/s3/{account}/websites/{website}

See Update a bucket

Delete a website

DELETE /v1/s3/{account}/websites/{website}

See Delete a bucket

Create a website user

POST /v1/s3/{account}/websites/{website}/users

See Create a bucket user

Get a website user's details

GET /v1/s3/{account}/websites/{website}/users/{user}

See Get a bucket user's details

List users for a website

GET /v1/s3/{account}/websites/{website}/users/{user}

See List users for a bucket

Reset access keys for a website user

PUT /v1/s3/{account}/websites/{website}/users/{user}

See Reset access keys for a bucket user

Delete a website user

DELETE /v1/s3/{account}/websites/{website}/users/{user}

See Delete a bucket user

Author

E Camden Fisher camden.fisher@yale.edu

License

The MIT License (MIT)
Copyright (c) 2019 Yale University

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL