Deploy to Elastic Beanstalk

Prerequisites

Deployment with Codefresh

  • Add encrypted environment variables for AWS credentials:
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
  • Provide the following environment variables:
    • AWS_REGION
    • AWS_ENV_NAME
    • AWS_VERSION
    • AWS_BRANCH

codefresh_eb_env_vars.png

TIP
The $ of application you can find in the Elastic Beanstalk service.

codefresh_eb_version_label.png

TIP
The $ of application you can find in the Elastic Beanstalk service.

codefresh_eb_environment.png

Add the following step to codefresh.yml:

deploy_step

deploy-elastic-beanstalk:
    fail-fast: false
    image: garland/aws-cli-docker:latest
    commands:
     - sh -c  "aws configure set region '${{AWS_REGION}}' && aws elasticbeanstalk update-environment --environment-name '${{AWS_ENV_NAME}}' --version-label '${{AWS_VERSION}}' "
    when:
      condition:
        all:
          masterBranch: "'${{CF_BRANCH}}' == '${{AWS_BRANCH}}'"

Deployment Flow

  • Go to the Elastic Beanstalk service and create an application and environment.

codefresh_eb_environment.png

  • Perform the following commands from root of your project:
    • eb init
    • eb create ${{AWS_ENV_NAME}}

NOTE
If you don’t have awsebcli, install EB CLI.

codefresh_eb_health.png

  • Add this repository to Codefresh, provide the necessary environments variables and build this service

codefresh_eb_cf_step_deploy.png

Example

CD pipeline examples