Wednesday, December 28, 2022

What Is Cloudformation ?

Cloudformation is an infrastructure as code tool that will allow you to create and configure aws resources by the help of single configuration file, also known as cf file.

CloudFormation was first introduced in July 2011
CloudFormation uses JSON or YAML Language.


CloudFormation Template

  • Format version: Format version defines the capability of a template.
  • Description: Any comments about your template can be specified in the description.
  • Metadata : The Metadata lets you associate a resources with structured data(in sequence) during the template runtime.
  • Parameters: Templates can be customized using parameters. Each time you create or update your stack, parameters help you give your template custom values at runtime.
  • Mappings: Mapping enables you to map keys to a corresponding named value that you specify in a conditional parameter. Also, you can retrieve values in a map by using the “Fn:: FindInMap” intrinsic function.
  • Conditions: In a template, conditions define whether certain resources are created or when resource properties are assigned to a value during stack creation or updating. Conditions can be used when you want to reuse the templates by creating resources in different contexts. You can use intrinsic functions to define conditions.
In a template, during stack creation, all the conditions in your template are evaluated. Any resources that are associated with a true condition are created, and the invalid conditions are ignored automatically.
  • Transform: Transform builds a simple declarative language for AWS CloudFormation and enables reuse of template components. Here, you can declare a single transform or multiple transforms within a template.
  • Resources: Using this section, you can declare the AWS resource that you want to create and specify in the stack, such as an Amazon S3 bucket or AWS Lambda.
  • Output: In a template, the output section describes the output values that you can import into other stacks or the values that are returned when you view your own stack properties. For example, for an S3 bucket name, you can declare an output and use the “Description-stacks” command from the AWS CloudFormation service to make the bucket name easier to find.


CloudFormation Template Attribute

  • DependsOn : Using the DependsOn attribute in a template, you can define the creation of a specific resource followed by another resource.
  • Example : AWS EC2 resource with a specified AWS S3 bucket resource (where S3 is assigned to DependsOn attribute). When a stack is created by AWS CloudFormation, it first creates an EC2 instance, then creates an S3 bucket.
  • Metadata : The Metadata attribute lets you associate a resources with structured data by the template runtime.


No comments:

Post a Comment

testing