More Related Content Similar to Michael_Blum_Mastering_CloudFormation.pdf (20) Michael_Blum_Mastering_CloudFormation.pdf2. 1. Introduction
2. Standards
3. Modularity & Reusability
4. Sharing Stack information
5. Policy Based Resources
6. Updatable Resources
7. End2End testing
8. Demo
9. General recommendations
Mastering
AWS CloudFormation
© 2020 Shine Solutions Group
4. • Infrastructure as Code since 2011
• Serverless Application Model (SAM)
• Cloud Development Kit (CDK)
• HashiCorp Terraform
AWS CloudFormation
© 2020 Shine Solutions Group
4
Introduction
6. • Integrate Linters into Development Lifecycle
• cfn-lint
• cfn_nag
• statelint (Step Functions)
• Automate validation
• Pull Requests
• CI/CD
• Git Hook
AWS CloudFormation
© 2020 Shine Solutions Group
6
Standards - Linting
7. • Structuring CF Template
• Group by Service
• Group by Resource Type
• YAML Inline Comments
• Enhanced Readability
• Faster navigation
AWS CloudFormation
© 2020 Shine Solutions Group
7
Standards - Structuring
8. • Seperate by logical utilisation
• functional purpose
• operational purpose
• Modular design
• Simplified Updates
• Modular flexibility
• Isolated changes
AWS CloudFormation
© 2020 Shine Solutions Group
8
Standards - Separating
10. • Promotes Modularity
• Reduced deployment time
• Cost optimisation
• Reusability
• Increased flexibility
• Permission-Based Segregation
AWS CloudFormation
© 2020 Shine Solutions Group
10
Modularity & Reusability - Prerequisite Stack
12. AWS CloudFormation
© 2020 Shine Solutions Group
12
Modularity & Reusability - Nested Stack
• Stacks within Stacks
• Modularisation
• Standardisation
• Reusable templates
• Dependency Management
• Output Reference
15. AWS CloudFormation
© 2020 Shine Solutions Group
15
Sharing - Export/Import
• Stack Outputs
• Unique per Account & Region
• Include stack name & environment name
• Parameterise as much as possible
• Imported outputs Cannot be deleted
• Preserve exported outputs
• Create new version of export
• Avoid for Single Stack version
18. AWS CloudFormation
© 2020 Shine Solutions Group
18
• Unique per Account & Region
• Include stack name & environment name
• Parameterise as much as possible
• Referred Parameters can be deleted
• Stack Update fails if deleted
• Creation, Deletion, Update
• Renaming == deletion
• Stack Update resolves updated parameter value
• Prefer for Single Stack version
Sharing - SSM
22. • Detaching policy from resource
• Enhances Modularity
• Enhances Parameterisation
AWS CloudFormation
© 2020 Shine Solutions Group
22
Policy Based resources
25. • Avoid Naming Resources
• Renaming = Replacing
• Prefer Tagging
• Lambda & Step Function incl. dynamic reference in S3Key
AWS CloudFormation
© 2020 Shine Solutions Group
25
Updatable Resources
27. • TaskCat
• > taskcat test run
• Automated linting
• Automated Deployment
• Multiple Regions
• Test Result
AWS CloudFormation
© 2020 Shine Solutions Group
27
End 2 End Testing
31. • Automate validation
• Keep a modular mindset
• Keep templates small
• Design templates enabling deployment of multiple stack versions
• Parameterise as much as possible
• Don’t hardcode information
• No manual changes to resources
• Include Policy-Based resources
• Ensure your resources are updatable
• If suitable automate testing
AWS CloudFormation
© 2020 Shine Solutions Group
31
General recommendations