Skip to content

Amazon ECS deploy & update

Brice Ruth edited this page Jul 3, 2015 · 1 revision

Prerequisites:

  • IAM user 'deploy' with all access rights (needs to create VPC, gateway, etc.)
  • ECS key pair named 'AWS Eastern'

Setup:

  • Create ~/.aws/credentials with IAM user's key id & secret
[deploy]
aws_access_key_id = blah
aws_secret_access_key = blah
  • Run coffee support/deploy.coffee

This creates necessary infrastructure templates that CloudFormation uses to create resources. You will run into an error creating the S3 bucket if your bucket name overlaps with any other S3 bucket in any organization, globally ... pick something unique. // TODO: indicate where to change.

  • In AWS -> CloudFormation, create two stacks, cf_base (creates network infrastructure) and cf_node_server (creates deployment)

Note: You will run into errors if you are at the AWS limit of VPCs or Internet gateways in your organization. Either request an increase or delete at least one of each.

Create cf_base and let it finish before creating cf_node_server. When both stacks have setup successfully, the containers will be running and the associated ELB address will be serving the site. Create a CNAME in your DNS to point at the ELB and you're done!

Updating:

Until this is automated, the process of updating the site involves updating the task definition in ECS to point to a new version in Docker Hub.

  • Access AWS ECS -> Task Definitions
  • Select the definition for the cluster (will be marked ACTIVE)
  • Create new revision
  • JSON -> edit image: to point to the new version, e.g.: user/repo:v_98 => user/repo:v_102
  • Note: This depends on your docker push creating versioned tags when you publish your container.
  • => Create
  • Navigate to the Service in your cluster, select => update and set the number of tasks to 0 to remove the old version
  • => Update Service
  • Select the service => update and set the number of tasks to 1 (or higher) to setup the new version
  • => Update Service

Once ECS has cycled through and started the new revised task definition, the ELB will update to point at the new container instance and be available - this typically takes a couple minutes.

Clone this wiki locally