AWS CloudFormation( Infrastructure as a code )
AWS CloudFormation provides users with a simple way to create and manage a collection of Amazon Web Services (AWS) resources by provisioning and updating them in a predictable way.
Working model
- Firstly we have to code our infrastructure in a YAML or JSON text-based file which is called a template.
- Then locally we write our code in the AWS CloudFormation tool. Otherwise we can upload a YAML or JSON file into the S3 bucket.
- Next use the GUI of AWS CF or the Command Line Interface to create a stack based on our template code.
- At last, CloudFormation will deploy resources, provision it and configures the template which we specified.
Cloud Pipeline interact with CloudFormation
- You can use AWS CodePipeline to trigger a Cloud Formation template to run in the deployment phase.
The pipeline has following stages:
- Source phase: Fetch the latest commit.
- Build phase: Build the code into a docker image and push it to ECR.
- Deploy phase: Take the latest docker image from ECR, deploy it to ECS
Circular dependency error in AWS CloudFormation : When two are dependent on one another we will get a circular dependency error because AWS CloudFormation is unable to clearly determine which resource should be created first.
To resolve a dependency error, add a DependsOn attribute to resources that depend on other resources in your tem