AWS Certified Solutions Architect - Professional
  • AWS Certified Solutions Architect - Professional
  • Analytics
    • Athena
    • Data Exchange
    • Kinesis Data Firehose
    • EMR
    • Glue
    • Kinesis Data Streams
    • Kinesis Data Analytics
    • Lake Formation
    • Managed Service for Apache Flink
    • Managed Streaming for Apache Kafka (Amazon MSK)
    • OpenSearch Service
    • QuickSight
  • Application Integration
    • AppFlow
  • AppSync
  • EventBridge
  • MQ
  • Simple Notification Service
  • Simple Queue Service
  • Step Functions
  • Simple Workflow Service
  • Mechanical Turk
  • Blockchain
    • Managed Blockchain
  • Business Applications
    • Simple Email Service
  • Cloud Financial Management
    • Budgets
    • Cost and Usage Report
  • Cost Explorer
  • Savings Plans
  • COMPUTE
    • App Runner
  • Auto Scaling
  • Batch
  • Elastic Beanstalk
  • OpsWorks
  • Elastic Compute Cloud
  • Fargate
  • Lambda
  • Serverless Application Model
  • Lightsail
  • Outposts
  • Wavelength
  • CONTAINERS
    • Elastic Container Registry
    • Elastic Container Service
    • ECS Anywhere
    • Elastic Kubernetes Service
    • EKS Anywhere
    • EKS Distro
  • DATABASES
    • Aurora
  • Aurora Serverless
  • DocumentDB
  • DynamoDB
  • ElastiCache
  • Keyspaces
  • Neptune
  • Quantum Ledger Database
  • Elasticsearch
  • Relational Database Service
  • Redshift
  • Timestream
  • Developer Tools
    • CI/CD using AWS Code
    • CodeArtifact
    • CodeBuild
    • CodeDeploy
    • CodeGuru
    • CodePipeline
    • X-Ray
  • End User Computing
    • AppStream 2.0
  • Workspaces
  • Frontend Web and Mobile
    • Amplify
    • API Gateway
    • Device Farm
    • Pinpoint
  • Internet of Things
    • IoT Core
    • IoT Device Defender
    • IoT Device Management
    • IoT Events
    • IoT Greengrass
    • IoT SiteWise
    • IoT Things Graph
  • IoT 1-Click
  • Machine Learning
    • Comprehend
    • Fraud Detector
    • Kendra
    • Lex
    • Personalize
    • Polly
    • Rekognition
  • SageMaker AI
  • Textract
  • Transcribe
  • Translate
  • Forecast 101
  • Management and Governance
    • CloudFormation
    • CloudTrail
    • CloudWatch
    • CloudWatch Logs
    • Cost Allocation Tags
    • Command Line Interface
    • Compute Optimizer
    • Config
    • Control Tower
    • Health Dashboard
    • License Manager
    • Managed Grafana
    • Managed Service for Prometheus
    • Management Console
    • Organizations
    • Proton
    • Service Catalog
    • Service Quotas
    • Systems Manager
    • Trusted Advisor
    • Well-Architected Tool
    • SAML2.0 Identity Federation
    • IAM Identity Center
    • Directory Service
  • Service Control Policies
  • Permissions Boundaries
  • Permissions Evaluation
  • Media Services
    • Elastic Transcoder
    • Kinesis Video Streams
  • Migration and Transfer
    • 6R's of Cloud Migration
    • Application Discovery Service
    • Application Migration Service
    • Database Migration Service
    • DataSync
    • Migration Hub
    • Schema Conversion Tool
    • Snow Family
    • Transfer Family
  • Networking and Content Delivery
    • Private and Public Services
    • DHCP In a VPC
    • VPC Router
    • Stateful vs Stateless Firewalls
    • Network Access Control Lists
    • Security Groups
    • Local Zones
    • Border Gateway Protocol
    • Global Accelerator
    • IPSec VPN
    • Site2Site VPN
    • Transit Gateway
    • VPC Routing
    • Accelerated Site-to-Site VPN
    • Client VPN
    • Direct Connect (DX)
    • Route53
    • Private Link
    • VPC
    • VPC Flow Logs
    • CloudFront
    • Elastic Load Balancing
  • Security, Identity, and Compliance
    • Artifact
    • Audit Manager
    • Certificate Manager
    • Parameter Store
    • CloudHSM
    • Cognito
    • Detective
    • Firewall Manager
    • GuardDuty
    • Identity and Access Management
    • Inspector
    • Key Management Service
    • Macie
    • Network Firewall
    • Resource Access Manager
    • Secrets Manager
    • Security Hub
    • Security Token Service
    • Shield
    • WAF
  • Storage
    • Backup
    • Elastic Block Store
    • Instance Store Volumes
    • Elastic Disaster Recovery
    • Elastic File System
    • FSx
    • Simple Storage Service
    • S3 Glacier
    • Storage Gateway
  • DISASTER RECOVERY
    • Types of DR - Cold, Warm, PilotLight
    • DR Architecture - Storage
    • DR Architecture - Compute
    • DR Architecture - Database
    • DR Architecture - Networking
Powered by GitBook
On this page
  • Physical and Logical Resources
  • Template and Pseudo Parameters
  • Template Parameters
  • Pseudo Parameters
  • Intrinsic Functions
  • Ref and Fn::GetAtt
  • Fn::GetAZs and Fn::Select
  • Fn::Join and Fn::Split
  • Fn::Base64 & Fn::Sub
  • Fn::Cidr
  • Mappings
  • Outputs
  • Conditions
  • DependsOn
  • Wait Conditions & cfn-signal
  • Nested Stacks
  • Cross-Stack References
  • Stack Sets
  • Deletion Policy
  • Stack Roles
  • Init (CFN-INIT)
  • cfn-hup
  • ChangeSets
  • Custom Resources
  1. Management and Governance

CloudFormation

Last updated 12 days ago

CloudFormation defines logical resources within templates (using YAML or JSON).

The logical resource defines the WHAT, and leaves the HOW up to the CFN product. A CFN stack creates a physical resource for every logical resource - updating or deleting them as a template changes.

Physical and Logical Resources

Template and Pseudo Parameters

Template and Pseudo Parameters are two methods to provide input to a template, which can influence what resources are provisioned, and the configuration of those resources.

Template Parameters

Pseudo Parameters

Intrinsic Functions

AWS CloudFormation provides several built-in functions that help you manage your stacks. Use intrinsic functions in your templates to assign values to properties that are not available until runtime.

Ref and Fn::GetAtt

Fn::GetAZs and Fn::Select

Fn::Join and Fn::Split

Fn::Base64 & Fn::Sub

Fn::Cidr

Mappings

The optional Mappings section matches a key to a corresponding set of named values. For example, if you want to set values based on a region, you can create a mapping that uses the region name as a key and contains the values you want to specify for each specific region. You use the Fn::FindInMap intrinsic function to retrieve values in a map.

Outputs

The optional Outputs section declares output values that you can import into other stacks (to create cross-stack references), return in response (to describe stack calls), or view on the AWS CloudFormation console. For example, you can output the S3 bucket name for a stack to make the bucket easier to find.

Conditions

The optional Conditions section contains statements that define the circumstances under which entities are created or configured. You might use conditions when you want to reuse a template that can create resources in different contexts, such as a test environment versus a production environment. In your template, you can add an EnvironmentType input parameter, which accepts either prod or test as inputs. Conditions are evaluated based on predefined pseudo parameters or input parameter values that you specify when you create or update a stack. Within each condition, you can reference another condition, a parameter value, or a mapping. After you define all your conditions, you can associate them with resources and resource properties in the Resources and Outputs sections of a template

DependsOn

With the DependsOn attribute you can specify that the creation of a specific resource follows another. When you add a DependsOn attribute to a resource, that resource is created only after the creation of the resource specified in theDependsOn attribute.

Wait Conditions & cfn-signal

CreationPolicy, WaitConditions and cfn-signal can all be used together to prevent the status if a resource from reaching create complete until AWS CloudFormation receives a specified number of success signals or the timeout period is exceeded.The cfn-signal helper script signals AWS CloudFormation to indicate whether Amazon EC2 instances have been successfully created or updated.

Provisioning

Signal

CreationPolicy

WaitConnection

Nested Stacks

Nested stacks allow for a hierarchy of related templates to be combined to form a single product

A root stack can contain and create nested stacks .. each of which can be passed parameters and provide back outputs.

Nested stacks should be used when the resources being provisioned share a lifecycle and are related.

Cross-Stack References

Cross stack references allow one stack to reference another

Outputs in one stack reference logical resources or attributes in that stack

They can be exported, and then using the !ImportValue intrinsic function, referenced from another stack.

Stack Sets

StackSets are a feature of CloudFormation allowing infrastructure to be deployed and managed across multiple regions and multiple accounts from a single location.

Additionally it adds a dynamic architecture - allowing automatic operations based on accounts being added or removed from the scope of a StackSet.

Deletion Policy

With the DeletionPolicy attribute you can preserve or (in some cases) backup a resource when its stack is deleted.

You specify a DeletionPolicy attribute for each resource that you want to control.

If a resource has no DeletionPolicy attribute, AWS CloudFormation deletes the resource by default.

Stack Roles

Stack roles allow an IAM role to be passed into the stack via PassRole

A stack uses this role, rather than the identity interacting with the stack to create, update and delete AWS resources.

It allows role separation and is a powerful security feature.

Init (CFN-INIT)

CloudFormationInit and cfn-init are tools which allow a desired state configuration management system to be implemented within CloudFormation

Use the AWS::CloudFormation::Init type to include metadata on an Amazon EC2 instance for the cfn-init helper script.

If your template calls the cfn-init script, the script looks for resource metadata rooted in the AWS::CloudFormation::Init metadata key. cfn-init supports all metadata types for Linux systems & It supports some metadata types for Windows

cfn-hup

The cfn-hup helper is a daemon that detects changes in resource metadata and runs user-specified actions when a change is detected. This allows you to make configuration updates on your running Amazon EC2 instances through the UpdateStack API action.

ChangeSets

When you need to update a stack, understanding how your changes will affect running resources before you implement them can help you update stacks with confidence. Change sets allow you to preview how proposed changes to a stack might impact your running resources, for example, whether your changes will delete or replace any critical resources, AWS CloudFormation makes the changes to your stack only when you decide to execute the change set, allowing you to decide whether to proceed with your proposed changes or explore other changes by creating another change set.

Custom Resources

Custom resources enable you to write custom provisioning logic in templates that AWS CloudFormation runs anytime you create, update (if you changed the custom resource), or delete stacks