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:
- profile_name = name of AWS profile (if using multiple accounts)
- code_deploy_application_name = name of AWS code deployment application.
- 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:
- profile = name of your AWS profile (if using multiple accounts)
- code_deploy_application_name = same as step 1.
- code_deploy_group_name = name of code deployment group. This is associated with your code deploy application.
- 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.)
- s3_bucket_zip_file_path = same as step 1.