Part of this article lets see how we can create a continuous integration and delivery pipeline (CI/CD) for applications deployed outside AWS cloud using ECS-anywhere. We will use
CodePipeline along with
AWS ECR to build this pipeline.
Here is the high level view of the pipeline, that we will build in this particle
Here are the sequence of events:
AWS CodeBuildwill download the source, build the artifacts, create a docker image for the application, and push the artifacts to
AWS CodeBuildtakes care of the following part of this step:
Change the name of the
SERVICE_NAME if desired, for running multiple tests.
export AWS_DEFAULT_REGION=us-east-1 export ROLE_NAME=ecsMithrilRole export CLUSTER_NAME=test-ecs-anywhere export SERVICE_NAME=test-ecs-anywhere-svc
Note: Change the value of
AWS_DEFAULT_REGIONto match the default AWS region.
Navigate to the root directory and run the following commands to provide execute permissions on the shell scripts
cd workload-management/cicd-deploy chmod +x *.sh ./setup.sh
The above shell script takes care of creating the following artifacts and deploying the sample application using ECS-anywhere
AWS ECRrepository to host the docker image for the sample application
AWS CodeCommitrepository to host the source code for the sample application
AWS CodeBuildprojects (one to package the application and another to update the deployed application with the latest version)
AWS CodePipelinelistening to the changes to the
masterbranch in the code repository
ECS Servicedefinition to deploy the sample application with
Note: Deploying this sample application will take sometime, so wait for couple of minutes before proceeding to next step
Here are some screenshots of the AWS artifact created by the shell script
Open the browser and navigate to
http://localhost:8080. We should see the below screenshot that shows the sample application is deployed.
Navigate to CodePipeline page in AWS Console, you should see the code pipeline running. Part of the
Deploy stage ECS task will be deployed to AWS ECS, so wait for couple of seconds after a successful execution of this stage before proceeding to next step.
We will make a small change to
index.html and check-in the updated files to
AWS CodeCommit. Navigate to gitrepo directory by running the following command:
index.html in your favorite text editor and update the text from
Hello world from ECS Anywhere! to
New Hello world from ECS Anywhere!. Save the file and run the following commands to push the changes back to
git add . git commit -m "Check in with new changes" git push cd ../..
EcsAnywhereCiCdPipeline (AWS CodePipeline) will get automatically triggered (like below) and this will take care of building the application and deploying the changes
Note: Deploying the updated application will take sometime, so wait for couple of minutes before proceeding to next step. Use AWS console to check the status of the build and deployment
Open the browser and navigate to this
http://localhost:8080. We should see the below screenshot that shows the latest changes are successfully deployed
Run the following command to delete all the AWS resources created for this article
./cleanup.sh cd ../..
This workload demostrates how easy is it to setup a CI/CD pipeline for applications running outside AWS cloud deployed using ECS-anywhere with the same set of fimilar tools.