artem zhurbila 5 aws - cloud formation and beanstalk

37
5 AWS - CloudFormation and Elastic Beanstalk Artem Zhurbila [email protected] [email protected]

Upload: artem-zhurbila

Post on 20-Aug-2015

246 views

Category:

Software


0 download

TRANSCRIPT

5 AWS - CloudFormation and Elastic BeanstalkArtem Zhurbila

[email protected]@gmail.com

Agenda1. CloudFormation overview2. CloudFormation template structure3. CloudFormer4. Elastic Beanstalk overview5. Deploy Docker image

2

CloudFormation3

- Control AWS infrastructure in predictable way (infrastructure as code)

- You don’t need to figure out the order for provisioning of AWS services

- no additional charge- JSON-formatted template (Declarative style)- By default, “automatic rollback on error” feature is

enabled. Stacks can be fully created, or not at all.

AWS Test Drive

AWS Test Drive - sandbox containing preconfigured server based solutions. Using a step-by-step lab manual and video, launch, login and learn about these popular 3rd party IT solutions, powered by AWS and CloudFormation.

4

5

Resources block is mandatory.Other blocks are optional.

Template structure

Parameters6

Intrinsic Function ● Fn::Base64● Condition Functions

Fn::AndFn::EqualsFn::IfFn::NotFn::Or

7

● Fn::FindInMap● Fn::GetAtt● Fn::GetAZs● Fn::Join● Fn::Select● Ref

Pseudo Parameters Reference● AWS::AccountId● AWS::Region● AWS::StackName

8

"Outputs" { "MyStacksRegion" : { "Value" : { "Ref" : " AWS::Region" } }}

Resources9

Resources types

● AWS::AutoScaling::AutoScalingGroup

● AWS::AutoScaling::LaunchConfiguration

● AWS::AutoScaling::ScalingPolicy● AWS::AutoScaling::

ScheduledAction● AWS::CloudFront::Distribution● AWS::CloudTrail::Trail● AWS::CloudWatch::Alarm● AWS::DynamoDB::Table● AWS::EC2::CustomerGateway● AWS::EC2::DHCPOptions● AWS::EC2::EIP● AWS::EC2::EIPAssociation

10

● AWS::EC2::NetworkInterface● AWS::EC2::

NetworkInterfaceAttachment● AWS::EC2::Route● AWS::EC2::RouteTable● AWS::EC2::SecurityGroup● AWS::EC2::Volume● AWS::EC2::VolumeAttachment● AWS::EC2::VPC● AWS::EC2::

VPCDHCPOptionsAssociation● AWS::EC2::

VPCGatewayAttachment● AWS::EC2::VPCPeeringConnection● etc

Conditions11

Outputs

"Outputs" : { "Logical ID" : { "Value" : "Value to return", "Description" : "Information about the value" }}

12

Stack

Stack - collection of AWS resources that result from instantiating a template. Stack = template + input parameters

13

CloudFormation console14

15

16

17

18

19

Bootstrapping ApplicationsPython helper scripts (preinstalled on Amazon Linux AMI in /opt/aws/bin):1. cfn-get-metadata: Retrieve metadata (key-value) attached to resources in

the template.2. cfn-init: install packages and files described in AWS::CloudFormation::Init.3. cfn-signal: signal to the stack creation workflow that your application is

ready to take traffic. Signal an CloudFormation CreationPolicy or WaitCondition

4. cfn-hup: daemon to listen for stack updates and execute hooks to react to those changes.

You can use CloudFormation scripts on their own or in conjunction with CloudInit (official Ubuntu EC2 AMI support it).

20

Elastic Beanstalk21

Beanstalk components22

Applications23

Create new environment - step 1 24

Worker Tier25

step 2 - Application26

Ways to deploy Docker app1. Create a Dockerfile to deploy a Docker container to

AWS Elastic Beanstalk.2. Create a Dockerrun.aws.json file to deploy a Docker

container from an existing Docker image3. Create a .zip file containing any application file

dependencies, the Dockerfile or Dockerrun.aws.json

27

Dockerrun.aws.json file example28

step 3 - Environment29

step 4 - Additional resource30

step 5 - configuration31

32

step 6 - environment keys

First docker app example33

34

Inside EC2 - docker35

Docker + Elastic Beanstalk36

37

Artem [email protected]

[email protected]

https://www.linkedin.com/in/zhurbila