Skip to content
Latchkey

aws codedeploy create-deployment: Trigger CodeDeploy in CI

Kick off a CodeDeploy deployment from a revision in S3 or GitHub.

aws codedeploy create-deployment starts a deployment of an application revision to a deployment group (EC2, on-prem, ECS, or Lambda). In CI it follows uploading the bundle to S3, returning a deployment ID you can poll to completion.

Common flags

  • --application-name - the CodeDeploy application (required)
  • --deployment-group-name - target deployment group (required)
  • --revision - location of the revision (S3 or GitHub spec)
  • --s3-location bucket=...,key=...,bundleType=zip - shorthand S3 revision
  • --description - label the deployment

Example in CI

Deploy a bundle uploaded to S3.

shell
aws codedeploy create-deployment --application-name my-app --deployment-group-name prod --s3-location bucket=${BUCKET},key=app.zip,bundleType=zip

Common errors in CI

  • An error occurred (ApplicationDoesNotExistException) - application name wrong
  • An error occurred (DeploymentGroupDoesNotExistException) - deployment group typo
  • An error occurred (RevisionDoesNotExistException) - S3 key/bucket wrong or not uploaded
  • An error occurred (AccessDeniedException) - role lacks codedeploy:CreateDeployment

Key takeaways

  • Upload the bundle to S3 first, then reference it with --s3-location.
  • The command returns a deployment ID - poll get-deployment for status.
  • Most failures are a wrong application, group, or S3 revision path.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →