AWS: Cloud Formation
Nagaraju Juluru
Lead Data Engineer | Cloud & Big Data Expert | AI-Driven Data Solutions | AWS, GCP, Snowflake, Databricks | Apache Spark | Real-Time Streaming | ETL/ELT | Data Lakehouse | Terraform | CI/CD Automation
AWS Cloud Formation is a service that lets us create, update and manage AWS Infrastructure with the help of configuration files. Creation and management of cloud infrastructure with help of config files is also called as Infrastructure as Code (IaC). After deploying Cloud Formation template on AWS it creates something called Stack. Stack consists of resources, outputs, inputs etc. We can delete the stack to delete every resources that were created when cloud formation template was deployed.
Cloud formation mainly consists of four sections (Apart from description and version):
1) Parameters: Used to declare variables that we have defined inside files that are present in external folder to template. (In our case we have params folder).
2)?Conditions: Used to define certain conditions which can be used while creating resources.
3) Resources: Used to define the config for resources that we want to create/update using our cloud formation. There can be multiple resources in one cloud formation template.
4) Output: After the stack creation we can output certain things like ARN of? the resources, Name of the resources etc. We can also use the outputs of one stack directly into another template given that both the templates are deployed in same region and account.
Documentation on Conditions:?https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html
Some of the CloudFormation Functions (Syntax in YML) :
1) Join: Used to concatenate the strings provided.
? ? Ex 1:?!Join [ '', [ "abc", "def", "ghi"] ]
? ? ? ? ? ? ?Output: "abcdefghi"
? ? Ex 2:?Join [ ':', [ 'abc', 'def', 'ghi'] ]
? ? ? ? ? ? ?Output: "abc:def:ghi"
2) Ref: Used to fetch ARN or Name of resource that is created in the same template.
领英推荐
? ? Ex 1:?!Ref Queue1 (Where Queue1 is soft resource name of an AWS SQS Queue named MyQueue)
? ? ? ? ? ? Output: MyQueue
3) GetAtt: Get attributes of a resource that is created in the same template. The attribute depends of resource to resource. Almost every resource has Arn attribute which can be used to find arn of the resource.
? ? Ex 1:?!GetAtt [ Queue1, Arn ]?(Where Queue1 is soft resource name of an AWS SQS Queue named MyQueue and has ARN arn:sqs:us-east-1:123123:MyQueue)
? ? ? ? ? ? Output:?arn:sqs:us-east-1:123123:MyQueue
4) ImportValue: Used to import values that are outputted by another stack in the same account and region.
? ? Ex 1:?!ImportValue QueueArn
? ? ? ? ? ? ?Output: Will give whatever was outputted by any stack in the same account and region with QueueArn name attached to it.
Documentation for CloudFormation Functions:?https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
Thank you for reading the article ..!
Regards
Mr. Nag