Menu
AWS CodeDeploy
User Guide (API Version 2014-10-06)

Push a Revision for AWS CodeDeploy to Amazon S3

After you plan your revision as described in Plan a Revision for AWS CodeDeploy and add an AppSpec file to the revision as described in Add an Application Specification File to a Revision for AWS CodeDeploy, you are ready to bundle the component files and push the revision to Amazon S3. After you push the revision, you can use AWS CodeDeploy to deploy the revision from Amazon S3 to the instances.

Note

AWS CodeDeploy can also be used to deploy revisions that have been pushed to GitHub. For more information, see your GitHub documentation.

We assume you have already followed the instructions in Getting Started with AWS CodeDeploy to set up the AWS CLI. This is especially important for calling the push command described later.

Be sure you have an Amazon S3 bucket. Follow the instructions in Create a Bucket.

The target Amazon S3 bucket must be created or exist in the same region as the target instances. For example, if you want to deploy a revision to some instances in the US East (N. Virginia) Region and other instances in the US West (Oregon) Region, then you must have one bucket in the US East (N. Virginia) Region with one copy of the revision and another bucket in the US West (Oregon) Region with another copy of the same revision. In this scenario, you would then need to create two separate deployments, one in the US East (N. Virginia) Region and another in the US West (Oregon) Region, even though the revision is the same in both regions and buckets.

You must have permissions to upload to the Amazon S3 bucket. You can specify these permissions through an Amazon S3 bucket policy. For example, in the following Amazon S3 bucket policy, using the wildcard character (*) allows AWS account 111122223333 to upload files to any directory in the Amazon S3 bucket named codedeploydemobucket:

Copy
{ "Statement": [ { "Action": [ "s3:PutObject" ], "Effect": "Allow", "Resource": "arn:aws:s3:::codedeploydemobucket/*", "Principal": { "AWS": [ "111122223333" ] } } ] }

To view your AWS account ID, see Finding Your AWS Account ID.

To learn how to generate and attach an Amazon S3 bucket policy, see Bucket Policy Examples.

The IAM user who is calling the push command must have, at minimum, permissions to upload the revision to each target Amazon S3 bucket. For example, the following policy allows the IAM user to upload revisions anywhere in the Amazon S3 bucket named codedeploydemobucket:

Copy
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObject" ], "Resource": "arn:aws:s3:::codedeploydemobucket/*" } ] }

To learn how to create and attach an IAM policy, see Working with Policies.

To bundle and push the revision in a single command, from the command line, switch to the root directory (folder) of the revision, and then call the push command.

For example, to bundle the component files into a revision starting from the current directory, associated with the application named WordPress_App, to an Amazon S3 bucket named codedeploydemobucket, with a revision name of WordPressApp.zip, call the push command as follows:

In Linux, macOS, or Unix:

Copy
aws deploy push \ --application-name WordPress_App \ --description "This is a revision for the application WordPress_App" \ --ignore-hidden-files \ --s3-location s3://codedeploydemobucket/WordPressApp.zip \ --source .

In Windows:

Copy
aws deploy push --application-name WordPress_App --description "This is a revision for the application WordPress_App" --ignore-hidden-files --s3-location s3://codedeploydemobucket/WordPressApp.zip --source .

After the push is successful, you can use the AWS CLI or the AWS CodeDeploy console to deploy the revision from Amazon S3 to the instances. For instructions, see Create a Deployment with AWS CodeDeploy.