Ticker

6/recent/ticker-posts

Manage Cloudformation Templates using nested stacks & Bitbucket pipeline

 

Prerequisite:

  • OIDC Role & S3 Bucket
  • How to create OIDC role, Here is the link

What is nested stack?

According to AWS documentation, Nested stacks are stacks that are created inside other stacks. You can create a nested stack within another stack by using the AWS::CloudFormation::Stack resource.

As infrastructure grows, there is a certain components that are repeated in multiple templates. Instead of declaring these components again and again, we can separate them and create individual templates for them. Then, we can use the AWS::CloudFormation::Stack resource in our main template to link to these separate templates, creating nested stacks. This helps in organizing and reusing our code more efficiently.

Repository Structure(GitHub Link):


Contents of root_template.yaml

Contents of s3-bucket.yaml

Contents of vpc.yaml

Contents of bitbucket-pipelines.yml


Set the following deployment & corresponding variables in Bitbucket repository:








What is taskcat?

TaskCat is a tool that used to test AWS CloudFormation templates. It deploys CloudFormation templates in specified AWS Regions and accordingly it creates a report. The report shows whether the cft templates passed or failed in each region. 
It helps you ensure your template works correctly across different regions.

If you want to include testing as part of your CICD pipeline, just install the taskcat and then run the tests.

In Build stage you can add following lines of code:
pip3 install taskcat --user
taskcat test run
Content of .taskcat.yml:
project:
  name: taskcat-test
  regions:
    - us-east-1
tests:
  vpc-test:
    template: vpc.yaml    

Now Run the pipeline:

Post a Comment

0 Comments