Rollout Infrastructure Changes Using CI/CD Pipeline on AWS


This article is about how to effectively rollout infrastructure changes using CI/CD pipeline on AWS.

Today a lot of organizations run their production workload on AWS and are also adapting to follow Infrastructure as Code (IAC) practice. 

Infrastructure as code gives the ability for organizations to quickly and systematically provision and manage AWS resources. CloudFormation gives that ability to templatize infrastructure with which you can create and manage almost all th services on AWS. Also, one can manage the changes in Infrastructure by creating changesets and roll it out, this enables to quickly rollout and rollback changes.

This article will help you set up a sample infrastructure using CloudFormation template and manage the same using CI/CD approach. Continous Integration and Continous Deliver) is also a DevOps practice which is used to perform a systematic release of changes or new updates of a software or infrastructure.



As shown in above diagram, we will create a release Pipeline for infrastructure changes which will include Test and Production stage. The deployment will only be done with manual approvals at each stage.

In this scenario, we have a CloudFormation template which will create a WordPress infrastructure on EC2 instance, the deployment for the same will be managed via CodePipline.

AWS CodePipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your infrastructure changes or software changes. It helps automates the steps required to release your changes continuously.


  • AWS account
  • Switch to N.Virginia region
  • Download zip of GitHub repo

Step 1: Upload WordPress App artifact to s3 bucket 

From the downloaded zip navigate to directory “demo-2” which will have two files :


The first step here will be to upload “” file on an S3 bucket in your AWS account.

Note: The bucket should have versioning enabled in order for deployment to work.


Step 2: Create a Pipeline using CloudFormation script

Here the only task will be to execute a cloudformation template which will create all the following resources :

  • A Pipeline on CodePipline
  • Test environment stage in pipeline
  • Production environment stage in pipeline

From the files download, upload CodePipeline.yml file on Cloudformation and execute it.Insert only the thing which is highlighted in the image below leave rest of thing as it is.

Insert only the thing which is highlighted in the image below leave rest of thing as it is.


Once the information is filled, launch cloudformation template.

Now, cloudformation will create a pipeline and start launching WordPress infrastructure on an EC2 instance.

The moment test stage is deployment is completed you can access the test stage WordPress installation to see if everything is fine once you are satisfied you can approve the same deployment to be done on production stage for this to proceed you will receive an email to do manual approval for each deployment as shown below:


If for some reason the cloudformation formation stack encountered an error the stack will be automatically deleted as shown in architecture diagram above in overview section.

Otherwise, if there are no errors it will wait for approval and once approval is received it will deploy the environment. After approval CodePipeline will execute cloudformation template present in the file which will launch and create WordPress infrastructure.

You can see the IP address/ URL in cloudformation to access the WordPress application once the deployment is completed as shown below:


Step 3: Managing the changes in WordPress infrastructure

Whenever you want to do any changes in WordPress configuration or infrastructure the best way to do is to edit/update cloudformation template in

Once the template is updated, just recreate a zip of all the content as it is and upload the same to S3 bucket because the bucket has versioning enabled. CodePipeline will detect the new version and same will trigger CodePipeline to run once again.

This way you have successfully rollout Infrastructure Changes Using CI/CD Pipeline on AWS. You can modify the same CodePipline to deploy the application in different VPC or AWS account and in different environment/region.

Hope this helped!

Feel free to reach out at for any queries. thanks!

Blogger & Assc Cloud Architect

Site Footer

%d bloggers like this: