AWS CloudFormation Concepts: Difference between revisions
Line 110: | Line 110: | ||
* [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html AWS::CloudFormation::Init] | * [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html AWS::CloudFormation::Init] | ||
* [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html AWS::CloudFormation::Interface] | * [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html AWS::CloudFormation::Interface] | ||
* [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/working-with-templates-cfn-designer.html AWS::CloudFormation::Designer]: describes how resources are laid out in the AWS CloudFormation Designer. | * [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/working-with-templates-cfn-designer.html AWS::CloudFormation::Designer]: describes how resources are laid out in the [[#Designer|AWS CloudFormation Designer]]. | ||
==<span id='Resource'></span>Resources== | ==<span id='Resource'></span>Resources== |
Revision as of 21:39, 11 March 2019
External
Internal
Overview
CloudFormation creates and configures resources, grouped in stacks. The resource declarations are provided as templates. One of the greatest benefits of templates and AWS CloudFormation is the ability to create a set of resources that work together to create an application or solution.
Bootstrapping Application via WS CloudFormation
Stack
A stack is a collection of AWS resources that can be managed (create, update or delete) as a single unit. Every stack is based on a template: all resources in a stack are defined by the stack's AWS CloudFormation template. Because AWS CloudFormation treats the stack resources as a single unit, they must all be created or deleted successfully for the stack to be created or deleted. If a resource cannot be created, AWS CloudFormation rolls the stack back and automatically deletes any resources that were created. If a resource cannot be deleted, any remaining resources are retained until the stack can be successfully deleted.
Nested Stack
A nested stack is a stack created as part of other stacks.
Root Stack
Stack Operations
Template
A template is a declaration of AWS resources that make up a stack. The template describes what resources are needed, and AWS CloudFormation provisions those resources in an orderly and. predictable fashion. The resources are created in parallel where possible. AWS CloudFormation deals with failure and transient issues. The templates are stored as JSON or YAML text files.
Template Structure
---
AWSTemplateFormatVersion: "version date"
Description:
<String>
Metadata:
<template metadata>
Parameters:
<set of parameters>
Mappings:
<set of mappings>
Conditions:
<set of conditions>
Transform:
<set of transforms>
Resources:
<set of resources - the only required top-level object>
Outputs:
<set of outputs>
AWSTemplateFormatVersion
Description
Input Parameters
The input parameters are declared in a template's Parameters object. A parameter contains a list of attributes that define its value and constraints against its value.. The only required attribute is Type, which can be a String, Number or an AWS-specific type.
Parameters:
WebServerPort:
Default: 8888
Description: TCP/IP port for the WordPress web server
Type: Number
MinValue: 1
MaxValue: 65535
For AWS-specific parameter types, AWS CloudFormation validates input values against existing values in the user's AWS account and in the region where he or she is creating the stack before creating any stack resources.
Validation Constraints
- MinLength
- MaxLength
- Default
- AllowedValues
- AllowedPattern
Metadata
Metadata section is optional, and provides information about the template itself. These details may include implementation details for specific resources.
Keys:
- AWS::CloudFormation::Init
- AWS::CloudFormation::Interface
- AWS::CloudFormation::Designer: describes how resources are laid out in the AWS CloudFormation Designer.
Resources
A resource must have a Type attribute, which defines the kind of AWS resource should be created.
AWS::ProductIdentifier::ResourceType
Full list of resource types:
Resource declarations use a Properties attribute to specify the information used to create a resource.
Resource Name
The name used for a resource within the template is a logical name. When AWS CloudFormation creates the resource, it generates a physical name that is based on the combination of the logical name, the stack name, and a unique ID.
AWS::CloudFormation::Stack
AWS::CloudFormation::Stack enables nesting another stack as a resource within a template.
Change Set
Function
AWS CloudFormation has a number of intrinsic functions that can be used to refer to other resources and their properties.
Functions: