Deploy application using Jenkinsfile and AWS Code deploy Deploy application using Jenkinsfile and AWS Code deploy jenkins jenkins

Deploy application using Jenkinsfile and AWS Code deploy


Alternatively you can use AWS CLI commands to do code deployment. This involves two steps.

Step 1 - Push the deployment bundle to S3 bucket. See the following command:

aws --profile {profile_name} deploy push --application-name {code_deploy_application_name} --s3-location s3://<s3_file_path>.zip

Where:

  1. profile_name = name of AWS profile (if using multiple accounts)
  2. code_deploy_application_name = name of AWS code deployment application.
  3. s3_file_path = S3 file path for deployment bundle zip file.

Step 2 - Initiate code deploymentThe second command is the used to trigger code deployment. See the following command:

aws --profile {profile} deploy create-deployment  --application-name {code_deploy_application_name} --deployment-group-name {code_deploy_group_name} --s3-location bucket={s3_bucket_name},bundleType=zip,key={s3_bucket_zip_file_path}

Where:

  1. profile = name of your AWS profile (if using multiple accounts)
  2. code_deploy_application_name = same as step 1.
  3. code_deploy_group_name = name of code deployment group. This is associated with your code deploy application.
  4. s3_bucket_name = name of S3 bucket which will store your deployment artefacts. (Make sure that your role that performs code deploy has permissions to s3 bucket.)
  5. s3_bucket_zip_file_path = same as step 1.