S3 Storage | Create - AMS Advanced Change Type Reference

S3 Storage | Create

Create an Amazon S3 bucket for cloud storage.

Full classification: Deployment | Advanced stack components | S3 storage | Create

Change Type Details

Change type ID

ct-1a68ck03fn98r

Current version

4.0

Expected execution duration

60 minutes

AWS approval

Required

Customer approval

Not required

Execution mode

Automated

Additional Information

Create S3 storage

Screenshot of this change type in the AMS console:

Change type details for creating an Amazon S3 bucket, including description and execution mode.

How it works:

  1. Navigate to the Create RFC page: In the left navigation pane of the AMS console click RFCs to open the RFCs list page, and then click Create RFC.

  2. Choose a popular change type (CT) in the default Browse change types view, or select a CT in the Choose by category view.

    • Browse by change type: You can click on a popular CT in the Quick create area to immediately open the Run RFC page. Note that you cannot choose an older CT version with quick create.

      To sort CTs, use the All change types area in either the Card or Table view. In either view, select a CT and then click Create RFC to open the Run RFC page. If applicable, a Create with older version option appears next to the Create RFC button.

    • Choose by category: Select a category, subcategory, item, and operation and the CT details box opens with an option to Create with older version if applicable. Click Create RFC to open the Run RFC page.

  3. On the Run RFC page, open the CT name area to see the CT details box. A Subject is required (this is filled in for you if you choose your CT in the Browse change types view). Open the Additional configuration area to add information about the RFC.

    In the Execution configuration area, use available drop-down lists or enter values for the required parameters. To configure optional execution parameters, open the Additional configuration area.

  4. When finished, click Run. If there are no errors, the RFC successfully created page displays with the submitted RFC details, and the initial Run output.

  5. Open the Run parameters area to see the configurations you submitted. Refresh the page to update the RFC execution status. Optionally, cancel the RFC or create a copy of it with the options at the top of the page.

How it works:

  1. Use either the Inline Create (you issue a create-rfc command with all RFC and execution parameters included), or Template Create (you create two JSON files, one for the RFC parameters and one for the execution parameters) and issue the create-rfc command with the two files as input. Both methods are described here.

  2. Submit the RFC: aws amscm submit-rfc --rfc-id ID command with the returned RFC ID.

    Monitor the RFC: aws amscm get-rfc --rfc-id ID command.

To check the change type version, use this command:

aws amscm list-change-type-version-summaries --filter Attribute=ChangeTypeId,Value=CT_ID

INLINE CREATE:

Issue the create RFC command with execution parameters provided inline (escape quotation marks when providing execution parameters inline), and then submit the returned RFC ID. For example, you can replace the contents with something like this:

Example with only required parameters, version 4.0 (AccessControl parameter is replaced with specific access parameters):

aws amscm create-rfc --title "my-s3-bucket" --change-type-id "ct-1a68ck03fn98r" --change-type-version "4.0" --execution-parameters "{\"Description\":\"S3 bucket for application A.\",\"VpcId\":\"VPC_ID\",\"StackTemplateId\":\"stm-s2b72beb200000000\",\"Name\":\"my-s3-bucket\",\"TimeoutInMinutes\":60,\"Parameters\":{\"BucketName\":\"my-s3-bucket\"}}"

Example with version 3.0 parameters including AccessControl parameter:

aws --profile saml amscm create-rfc --change-type-id "ct-1a68ck03fn98r" --change-type-version "2.0" --title "TITLE" --execution-parameters "{\"Description\":\"YOUR_S3_DESCRIPTION\", \"VpcId\":\"VPC_ID\", \"StackTemplateId\":\"stm-s2b72beb000000000\", \"Name\":\"AMS-STACK-NAME\", \"TimeoutInMinutes\":60,\"Parameters\": {\"AccessControl\":\"PublicRead\", \"BucketName\":\"UNIQUE-S3-BUCKET-NAME\"}}"

Example with all parameters, version 4.0 (AccessControl parameter is replaced with specific access parameters):

aws amscm create-rfc --title "my-s3-bucket" --change-type-id "ct-1a68ck03fn98r" --change-type-version "4.0" --execution-parameters "{\"Description\":\"S3 bucket for application A\",\"VpcId\":\"VPC_ID\",\"StackTemplateId\":\"stm-s2b72beb200000000\",\"Name\":\"my-s3-bucket\",\"TimeoutInMinutes\":60,\"Parameters\":{\"BucketName\":\"my-s3-bucket\",\"ServerSideEncryption\":\"KmsManagedKeys\",\"KMSKeyId\":\"arn:aws:kms:us-east-1:123456789012:key/fc69dcab-d3c7-4d36-b204-9da582ae760b\",\"Versioning\":\"Enabled\",\"IAMPrincipalsRequiringReadObjectAccess\":[\"arn:aws:iam::123456789012:role/roleA\"],\"IAMPrincipalsRequiringWriteObjectAccess\":[\"arn:aws:iam::123456789012:role/roleA\"],\"ServicesRequiringReadObjectAccess\":[\"logs.us-east-1.amazonaws.com\"],\"ServicesRequiringWriteObjectAccess\":[\"logs.us-east-1.amazonaws.com\"],\"EnforceSecureTransport\":true,\"AccessAllowedIpRanges\":[\"1.2.3.0/24\",\"2.3.4.0/24\"]}}"

TEMPLATE CREATE:

  1. Output the execution parameters JSON schema for this change type to a file; this example names it CreateBucketParams.json.

    aws amscm get-change-type-version --change-type-id "ct-1a68ck03fn98r" --query "ChangeTypeVersion.ExecutionInputSchema" --output text > CreateBucketParams.json
  2. Modify and save the CreateBucketParams file. Note that you do not need to use your account ID in the BucketName, but it can make finding the bucket easier (remember that bucket names must be unique in the account across all regions and cannot have uppercase letters). If using this to create a tier-and-tie WordPress site, you may want to indicate that purpose when setting the BucketName.

    Example with version 3.0 parameters including AccessControl:

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb000000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "AccessControl": "Private", "BucketName": "ACCOUNT_ID.BUCKET_NAME" } }

    Example with version 4.0 new access parameters (example grants READ access to the objects in the bucket for an IAM user or a role):

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb200000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "ACCOUNT_ID.BUCKET_NAME", "IAMPrincipalsWithReadObjectAccess": [ "arn:aws:iam::123456789123:role/roleA", "arn:aws:iam::987654321987:role/roleB" ] } }

    For the resulting policy, see Grants READ access for an IAM User or a Role.

    Example with version 4.0 new access parameters (example grants WRITE access to the objects in the bucket for an IAM user or a role):

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb200000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "ACCOUNT_ID.BUCKET_NAME", "IAMPrincipalsRequiringWriteObjectAccess": [ "arn:aws:iam::123456789123:role/roleA", "arn:aws:iam::987654321987:role/roleB" ] } }

    For the resulting policy, see Grants WRITE access for an IAM User or a Role.

    Example with version 4.0 new access parameters (example grants READ access to the objects in the bucket for an AWS service):

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb200000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "ACCOUNT_ID.BUCKET_NAME", "ServicesRequiringWriteObjectAccess": [ "rds.amazonaws.com", "logs.ap-southeast-2.amazonaws.com", "ec2.amazonaws.com" ] } }

    For the resulting policy, see Grants READ access for an AWS Service.

    Example with version 4.0 new access parameters (example grants WRITE access to the objects in the bucket for an AWS service):

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb200000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "ACCOUNT_ID.BUCKET_NAME", "ServicesRequiringWriteObjectAccess": [ "rds.amazonaws.com", "logs.ap-southeast-2.amazonaws.com", "ec2.amazonaws.com" ] } }

    For the resulting policy, see Grants WRITE access for an AWS Service.

    Example with version 4.0, (enforce secure transport):

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb200000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "ACCOUNT_ID.BUCKET_NAME", "EnforceSecureTransport": "true" } }

    For the resulting policy, see Uses EnforceSecureTransport.

    Example with version 4.0, limits access to the bucket from a set of IP ranges use <>:

    { "Description": "S3-Bucket-Create", "VpcId": "VPC-ID", "StackTemplateId": "stm-s2b72beb200000000", "Name": "My-S3-Bucket", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "ACCOUNT_ID.BUCKET_NAME", "AccessAllowedIpRanges": [ "1.2.3.0/24", "2.3.4.0/24" ] } }

    For the resulting policy, see Limits Access to IP Range.

  3. Output the RFC template JSON file to a file named CreateBucketRfc.json:

    aws amscm create-rfc --generate-cli-skeleton > CreateBucketRfc.json
  4. Modify and save the CreateBucketRfc.json file. For example, you can replace the contents with something like this:

    { "ChangeTypeVersion": "4.0", "ChangeTypeId": "ct-1a68ck03fn98r", "Title": "S3-Bucket-Create-RFC", "RequestedStartTime": "2016-12-05T14:20:00Z", "RequestedEndTime": "2016-12-05T16:20:00Z" }
  5. Create the RFC, specifying the CreateBucketRfc file and the CreateBucketParams file:

    aws amscm create-rfc --cli-input-json file://CreateBucketRfc.json --execution-parameters file://CreateBucketParams.json

    You receive the ID of the new RFC in the response and can use it to submit and monitor the RFC. Until you submit it, the RFC remains in the editing state and does not start.

  6. To view the S3 bucket or load objects to it, look in the execution output: Use the stack_id to view the bucket in the Cloud Formation Console, use the S3BucketName to view the bucket in the S3 Console.

    Note

    When uploading objects from a non-owner account, it is mandatory to specify the bucket-owner-full-control ACL, that grants the bucket owner account full control over all the objects in the bucket. Example:

    aws s3api put-object --acl bucket-owner-full-control --bucket ACCOUNT_ID.BUCKET_NAME --key data.txt --body /tmp/data.txt
Note

This walkthrough describes, and provides example commands for, creating an Amazon S3 storage bucket using version 4.0 of the change type (ct-1a68ck03fn98r). This version does not allow you to create a public S3 bucket, only private is allowed. To create a public S3 storage bucket, use a previous version of the change type, and specify PublicRead for the AccessControl parameter.

Also, this walkthrough does not grant the permissions necessary for deleting versioned objects.

To learn more about Amazon S3, see Amazon Simple Storage Service Documentation.

S3 Storage Bucket Create Resulting Policies

Depending on how you created your Amazon S3 storage bucket, you created policies. These example policies match various Amazon S3 create scenarios provided in Creating an S3 Bucket with the CLI.

Grants READ access for an IAM User or a Role

Resulting example policy grants READ access to the objects in the bucket for an IAM user or a role:

{ "Sid": "AllowBucketReadActionsForArns", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::123456789123:role/roleA”, "arn:aws:iam::987654321987:role/roleB” ] }, "Action": [ "s3:GetBucketAcl", "s3:GetBucketLocation", "s3:ListBucket" ], "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME" }, { "Sid": "AllowObjectReadActionsForArns", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::123456789123:role/roleA”, "arn:aws:iam::987654321987:role/roleB” ] }, "Action": [ "s3:GetObject", "s3:ListMultipartUploadParts" ], "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*" }

For the execution parameters to create this policy with the S3 storage bucket Create change type, see Creating an S3 Bucket with the CLI

Grants WRITE access for an IAM User or a Role

The following resulting example policy grants WRITE access to the objects in the bucket for a IAM user or a role. This policy does not grant the permissions necessary for deleting versioned objects.

{ "Sid": "AllowObjectWriteActionsForArns", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam::123456789123:role/roleA”, "arn:aws:iam::987654321987:role/roleB” ] }, "Action": [ "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload" ], "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*" }

For the execution parameters to create this policy with the S3 storage bucket Create change type, see Creating an S3 Bucket with the CLI

Grants READ access for an AWS Service

Resulting example policy grants READ access to the objects in the bucket for an AWS service:

{ "Sid": "AllowBucketReadActionsForServcices", "Effect": "Allow", "Principal": { "Service": [ "rds.amazonaws.com", "logs.ap-southeast-2.amazonaws.com", "ec2.amazonaws.com" ] }, "Action": [ "s3:GetBucketAcl", "s3:GetBucketLocation", "s3:ListBucket" ], "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*" }, { "Sid": "AllowObjectReadActionsForServcices", "Effect": "Allow", "Principal": { "Service": [ "rds.amazonaws.com", "logs.ap-southeast-2.amazonaws.com", "ec2.amazonaws.com" ] }, "Action": [ "s3:GetObject", "s3:ListMultipartUploadParts" ], "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*" }

For the execution parameters to create this policy with the S3 storage bucket Create change type, see Creating an S3 Bucket with the CLI

Grants WRITE access for an AWS Service

The following resulting example policy grants WRITE access to the objects in the bucket for an AWS service. This policy does not grant the permissions necessary for deleting versioned objects.

{ "Sid": "AllowObjectWriteActionsForServcices", "Effect": "Allow", "Principal": { "Service": [ "rds.amazonaws.com", "logs.ap-southeast-2.amazonaws.com", "ec2.amazonaws.com" ] }, "Action": [ "s3:PutObject", "s3:DeleteObject", "s3:AbortMultipartUpload" ], "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*" }

For the execution parameters to create this policy with the S3 storage bucket Create change type, see Creating an S3 Bucket with the CLI

Uses EnforceSecureTransport

Resulting example policy enforcing secure transport:

{ "Sid": "EnforceSecureTransport", "Effect": "Deny", "Principal": "*", "Action": "*", "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*", "Condition": { "Bool": { "aws:SecureTransport": "false" } } }

For the execution parameters to create this policy with the S3 storage bucket Create change type, see Creating an S3 Bucket with the CLI

Limits Access to IP Range

Resulting example policy limiting access to the bucket from a set of IP ranges:

{ "Sid": "RestrictBasedOnIPRanges", "Effect": "Deny", "Principal": "*", "Action": "s3:*", "Resource": "arn:aws:s3:::ACCOUNT-ID.BUCKET_NAME/*", "Condition": { "NotIpAddress": { "aws:SourceIp": [ “1.2.3.0/24", “2.3.4.0/24" ] } } }

For the execution parameters to create this policy with the S3 storage bucket Create change type, see Creating an S3 Bucket with the CLI

Execution Input Parameters

For detailed information about the execution input parameters, see Schema for Change Type ct-1a68ck03fn98r.

Example: Required Parameters

{ "Description": "This is a test description", "VpcId": "vpc-12345678901234567", "StackTemplateId": "stm-s2b72beb200000000", "Name": "Test Stack", "TimeoutInMinutes": 60, "Parameters": { "BucketName": "mybucket" } }

Example: All Parameters

{ "Description": "This is a test description", "VpcId": "vpc-12345678", "StackTemplateId": "stm-s2b72beb200000000", "Name": "Test Stack", "Tags": [ { "Key": "foo", "Value": "bar" }, { "Key": "testkey", "Value": "testvalue" } ], "TimeoutInMinutes": 60, "Parameters": { "BucketName": "mybucket", "ServerSideEncryption": "KmsManagedKeys", "KMSKeyId": "arn:aws:kms:ap-southeast-2:123456789012:key/9d5948f1-2082-4c07-a183-eb829b8d81c4", "Versioning": "Enabled", "IAMPrincipalsRequiringReadObjectAccess": [ "arn:aws:iam::123456789012:user/myuser", "arn:aws:iam::123456789012:role/myrole" ], "IAMPrincipalsRequiringWriteObjectAccess": [ "arn:aws:iam::123456789012:user/myuser", "arn:aws:iam::123456789012:role/myrole" ], "ServicesRequiringReadObjectAccess": [ "rds.amazonaws.com", "ec2.amazonaws.com", "logs.ap-southeast-2.amazonaws.com" ], "ServicesRequiringWriteObjectAccess": [ "rds.amazonaws.com", "ec2.amazonaws.com", "logs.ap-southeast-2.amazonaws.com" ], "EnforceSecureTransport": true, "AccessAllowedIpRanges": [ "1.0.0.0/24", "2.0.0.0/24" ] } }