infrastructure as code with aws cloudformation

40
Infrastructure as code with AWS CloudFormation PyMunich 2016

Upload: justyna-janczyszyn

Post on 16-Apr-2017

298 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Infrastructure as Code with AWS CloudFormation

Infrastructure as code with

AWS CloudFormation

PyMunich 2016

Page 2: Infrastructure as Code with AWS CloudFormation

Justyna Janczyszyn (JJ)

@JJanczyszyn

software engineer at 10Clouds

Page 3: Infrastructure as Code with AWS CloudFormation
Page 4: Infrastructure as Code with AWS CloudFormation

CHALLENGES

4 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 5: Infrastructure as Code with AWS CloudFormation

5 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 6: Infrastructure as Code with AWS CloudFormation

6 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 7: Infrastructure as Code with AWS CloudFormation

7 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 8: Infrastructure as Code with AWS CloudFormation

8 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 9: Infrastructure as Code with AWS CloudFormation

9 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Image taken from: Infrastructure as Code by Kief Morris

Page 10: Infrastructure as Code with AWS CloudFormation

10 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 11: Infrastructure as Code with AWS CloudFormation

11 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 12: Infrastructure as Code with AWS CloudFormation

Infrastructure as code principles and practices to the rescue!

12 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 13: Infrastructure as Code with AWS CloudFormation

Any element of infrastructure should be easily reproducible

13 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Infrastructure as Code by Kief Morris

Page 14: Infrastructure as Code with AWS CloudFormation

Systems should be consistent

14 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Infrastructure as Code by Kief Morris

Page 15: Infrastructure as Code with AWS CloudFormation

Processes should be repeatable

15 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Infrastructure as Code by Kief Morris

Page 16: Infrastructure as Code with AWS CloudFormation

Design is always changing

16 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Infrastructure as Code by Kief Morris

Page 17: Infrastructure as Code with AWS CloudFormation

Practices

17 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

• Use Definition files • Self-documented systems and processes • Version all the things • Continuously test the systems and processes • Small changes rather than batches • Services available continuously

Infrastructure as Code by Kief Morris

Page 18: Infrastructure as Code with AWS CloudFormation

CloudFormation

18 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 19: Infrastructure as Code with AWS CloudFormation

19 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 20: Infrastructure as Code with AWS CloudFormation

20 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Image taken from http://fbrnc.net/blog/2016/05/green-blue-deployments-with-aws-lambda-and-cloudformation

Page 21: Infrastructure as Code with AWS CloudFormation

Creating a stack

21 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

aws cloudformation create-stack --stack-name demo-iac

--template-body file://Template.yaml --parameters file://Params.json

--capabilities CAPABILITY_NAMED_IAM --region eu-west-1;

Page 22: Infrastructure as Code with AWS CloudFormation
Page 23: Infrastructure as Code with AWS CloudFormation

23 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 24: Infrastructure as Code with AWS CloudFormation

24 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 25: Infrastructure as Code with AWS CloudFormation

25 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 26: Infrastructure as Code with AWS CloudFormation

26 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

aws cloudformation describe-stacks --stack-name demo-iac

Describe a stack

Page 27: Infrastructure as Code with AWS CloudFormation
Page 28: Infrastructure as Code with AWS CloudFormation

Delete a stack

28 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

aws cloudformation delete-stack —stack-name demo-iac

Page 29: Infrastructure as Code with AWS CloudFormation

Change Sets

29 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

https://aws.amazon.com/blogs/aws/new-change-sets-for-aws-cloudformation/

Page 30: Infrastructure as Code with AWS CloudFormation

https://aws.amazon.com/blogs/aws/new-change-sets-for-aws-cloudformation/

Page 31: Infrastructure as Code with AWS CloudFormation

aws cloudformation estimate-template-cost --template-body file://Template.yaml

--parameters file://Params.json;

31 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Cost estimation

Page 32: Infrastructure as Code with AWS CloudFormation

32 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Page 33: Infrastructure as Code with AWS CloudFormation

33 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Best Practices

Page 34: Infrastructure as Code with AWS CloudFormation

34 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Planning and organizing

• organize stacks by lifecycle and ownership • reuse templetes for various environments • use nested stacks

Page 35: Infrastructure as Code with AWS CloudFormation

35 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Creating templates• don’t embed credentials in templates • validate templates before using them • use parameter constraints

Page 36: Infrastructure as Code with AWS CloudFormation

36 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

Managing stacks

• use stack policies • use change sets • manage all stack resources through cloudformation • use code reviews and revision for your templates

Page 37: Infrastructure as Code with AWS CloudFormation

Ready to use templates

37 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

• https://github.com/awslabs/aws-cloudformation-templates

• https://github.com/widdix/aws-cf-templates

Page 38: Infrastructure as Code with AWS CloudFormation

Library to create AWS CloudFormation descriptions

38 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

• https://github.com/cloudtools/troposphere

Page 39: Infrastructure as Code with AWS CloudFormation

Other resources

39 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code

• Infrastructure as Code by Kief Morris

http://infrastructure-as-code.com/

• Martin Fowler’s Infrastructure as Code at YOW! 2016:

https://www.youtube.com/watch?v=ueAef9tNUck

http://martinfowler.com/bliki/InfrastructureAsCode.html

• Great blog on AWS:

https://cloudonaut.io/

Page 40: Infrastructure as Code with AWS CloudFormation

Step by step automate all

40 PyMunich 2016@JJanczyszyn

https://github.com/tramwaj29/infrastructure-as-code