Deploying to AWS S3

2 minute read

To make it easy for you to deploy your application to AWS S3, we’ve built a container that has the AWS CLI installed. We will set up a simple example showing you how to configure any deployment to AWS S3.

CodeShip AWS Deployment Container

CloudBees CodeShip Pro uses an AWS deployment container that we maintain to authenticate with your AWS account.

Please review our AWS documentation to learn how to set up and use this authentication container.

You will need the AWS service, as well as your application itself, defined via your codeship-services.yml file so that you can execute the necessary S3 commands in your codeship-steps.yml file.

It is also advised that you review AWS’ IAM documentation to find the correct policies for your account.

Deploying To S3

In the following example we’re uploading a file to S3 from the source repository which we access through the host volume at /deploy.

Add the following into your codeship-steps.yml file:

- service: awsdeployment command: aws s3 cp /deploy/FILE_TO_DEPLOY s3://SOME_BUCKET

Note that the awsdeployment and the data from the volume are both discussed in more detail in our AWS documentation, and that all S3-related commands will work the same way in lieu of the above example.

S3 Permissions Policy

To upload new application versions to the S3 bucket specified in the deployment configuration, we need at least Put access to the bucket (or the appname prefix). See the following snippet for an example.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:PutObjectAcl", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::[s3-bucket]/*" ] }, { "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::[s3-bucket]" ] } ] }