AWS CloudFormation | |
Developer: | Amazon Web Services |
Operating System: | Cross-platform |
Platform: | Amazon Web Services |
Genre: | Infrastructure as Code, Cloud computing |
License: | Proprietary software |
AWS CloudFormation is a service provided by Amazon Web Services (AWS) that enables users to model and manage infrastructure resources in an automated and secure manner.[1] Using CloudFormation, developers can define and provision AWS infrastructure resources using a JSON- or YAML-formatted infrastructure as code template.[2] [3] The service was released on February 25, 2011.[4] [5] [6] [7]
AWS CloudFormation provides a way for users to model an entire AWS infrastructure in a text file, allowing for the infrastructure to be version-controlled, shared, and reused.[8] By using templates, users can create, update, and delete a collection of resources together as a single unit, known as a stack.[9]
A CloudFormation template consists of several sections, including Resources, Parameters, Mappings, Conditions, Outputs, and Metadata.[10] The most important section is the Resources section, which defines the AWS resources to be created or modified.
Resources are the AWS components that are created, updated, or deleted when the CloudFormation stack is created, updated, or deleted. Examples of resources include Amazon EC2 instances, Amazon S3 buckets, and AWS Lambda functions.[11]
Parameters enable users to input custom values to a CloudFormation template, allowing for customization without modifying the template itself.[12] This makes templates more reusable and flexible to accommodate different environments and use cases.
Mappings define a set of key-value pairs that can be used to map input values to corresponding output values, making it possible to conditionally define properties and values based on the input parameters.[13] For example, mappings can be used to define different instance types and Amazon Machine Images (AMIs) for different environments.
Conditions enable users to define conditional statements within a CloudFormation template, allowing for the creation or modification of resources based on specific criteria.[14] This can be useful in cases where certain resources should only be created or modified under specific circumstances.
Outputs provide a way to export information about the created resources, making it possible to share this information between stacks or with external systems.[15] Outputs can be used to easily reference resources created by a stack in another stack, facilitating the integration of different AWS services.
Metadata is used to provide additional information about the template or resources within the template.[16] This can include documentation, licensing information, or other descriptive data.
The following example demonstrates a simple AWS CloudFormation template in YAML format:[17]
<nowiki> --- AWSTemplateFormatVersion: '2010-09-09' Description: A simple AWS CloudFormation template for an Amazon S3 bucket. Parameters: BucketName: Description: The name of the Amazon S3 bucket. Type: String Resources: S3Bucket: Type: 'AWS::S3::Bucket' Properties: BucketName: !Ref BucketName Outputs: BucketARN: Description: The Amazon S3 bucket ARN. Value: !GetAtt S3Bucket.Arn </nowiki>
This template has the following sections:
AWSTemplateFormatVersion: Specifies the CloudFormation template version.
Description: Provides a brief description of the template.
Parameters: Defines input parameters for the template. In this example, the parameter is the Amazon S3 bucket's name.
Resources: Lists the AWS resources to be created. Here, it specifies the creation of an Amazon S3 bucket.
Outputs: Defines the values to be returned after the stack is created. In this case, it returns the Amazon Resource Name (ARN) of the created S3 bucket.
By using this template in AWS CloudFormation, a user can create an Amazon S3 bucket with a specified name, and the ARN of the created bucket will be returned as an output value.
AWS CloudFormation Drift Detection is a feature that allows users to detect whether their stack resources have drifted from their expected template configurations.[18] Drift detection helps maintain the consistency of infrastructure resources and aids in troubleshooting when unexpected changes occur.
2011: AWS CloudFormation was officially launched on February 25, 2011, providing users with a way to define and manage AWS infrastructure resources using a single text file.[19]
2016: Support for YAML formatted templates was introduced, in addition to the original JSON format, offering users more options when creating templates.[20]
2018: AWS CloudFormation Drift Detection was launched, allowing users to detect when their stack resources have drifted from their expected configurations. This feature helps users identify and address configuration discrepancies.[21]
2019: AWS CloudFormation Registry and CLI were introduced, enabling users to extend the service with third-party and custom resource types. This enhancement allows for more flexibility in managing resources beyond the native AWS offerings.[22]