Top Banner
Tom Maddox
44

Defining VPC Based Web Apps in AWS CloudFormation

Feb 22, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Defining VPC Based Web Apps in AWS CloudFormation

Tom Maddox –

Page 2: Defining VPC Based Web Apps in AWS CloudFormation
Page 3: Defining VPC Based Web Apps in AWS CloudFormation
Page 4: Defining VPC Based Web Apps in AWS CloudFormation
Page 5: Defining VPC Based Web Apps in AWS CloudFormation
Page 6: Defining VPC Based Web Apps in AWS CloudFormation
Page 7: Defining VPC Based Web Apps in AWS CloudFormation
Page 8: Defining VPC Based Web Apps in AWS CloudFormation
Page 9: Defining VPC Based Web Apps in AWS CloudFormation
Page 10: Defining VPC Based Web Apps in AWS CloudFormation

Elastic Beanstalk OpsWorks CloudFormation EC2

Convenience Control

Higher-level services Do it yourself

Page 11: Defining VPC Based Web Apps in AWS CloudFormation
Page 12: Defining VPC Based Web Apps in AWS CloudFormation

Continuous integration for your complete stack

Version Control Jenkins

Test

Live

Amazon

S3

AWS

CloudFormation

App commit

Infra commit

Pull

Deploy new

template

Deploy

new app

Page 13: Defining VPC Based Web Apps in AWS CloudFormation

Continuous integration for your complete stack

Version Control Jenkins

Test

Live

Amazon

S3

AWS

CloudFormation

App commit

Infra commit

Pull

Promote new

template

Promote

new app

Page 14: Defining VPC Based Web Apps in AWS CloudFormation
Page 15: Defining VPC Based Web Apps in AWS CloudFormation

"Parameters"

"Mappings"

"Conditions"

"Resources"

"Outputs"

Page 16: Defining VPC Based Web Apps in AWS CloudFormation
Page 17: Defining VPC Based Web Apps in AWS CloudFormation

"Parameters" : {

“InstanceType” : {

“Description” : “The EC2 Instance Type to launch.”,

“Type” : “String”,

“AllowedValues” : [“t1.micro”, “m1.small”, “m1.medium”]

}

},

“InstanceType” : { “Ref” : “InstanceType” }

Page 18: Defining VPC Based Web Apps in AWS CloudFormation

"Outputs" : {

"InstancePublicDnsName" : {

"Description" : "The public DNS name of the newly created EC2 instance",

"Value" : { ”Fn::GetAtt" : [ "Ec2Instance”, “PublicDnsName” ] }

}

}

Page 19: Defining VPC Based Web Apps in AWS CloudFormation

"Environment" : {

"Description" : "Specifies if this a Dev QA or Prod Environment",

"Type" : "String",

"Default" : "Dev",

"AllowedValues" : [ "Dev", "QA", "Prod"]

},

"Conditions" : {

"ProdEnvironment" : { "Fn::Equals" : [ { "Ref" : "Environment" }, "Prod" ]}

},

"InstanceType" : { "Fn::If" : [ "ProdEnvironment", “m3.2xlarge”, “m3.medium” ] }

Page 20: Defining VPC Based Web Apps in AWS CloudFormation

"Mappings" : {

"RegionMap" : {

"us-east-1" : { "32" : "ami-6411e20d", "64" : "ami-7a11e213" },

"us-west-1" : { "32" : "ami-c9c7978c", "64" : "ami-cfc7978a" },

"eu-west-1" : { "32" : "ami-37c2f643", "64" : "ami-31c2f645" },

"ap-southeast-1" : { "32" : "ami-66f28c34", "64" : "ami-60f28c32" },

"ap-northeast-1" : { "32" : "ami-9c03a89d", "64" : "ami-a003a8a1" }

}

},

"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "32"]},

Page 21: Defining VPC Based Web Apps in AWS CloudFormation

http://aws.amazon.com/cloudformation/aws-cloudformation-templates/

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/CHAP_Te

mplateQuickRef.html

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-

reference.html

Page 22: Defining VPC Based Web Apps in AWS CloudFormation
Page 23: Defining VPC Based Web Apps in AWS CloudFormation
Page 24: Defining VPC Based Web Apps in AWS CloudFormation
Page 25: Defining VPC Based Web Apps in AWS CloudFormation

"Metadata" : {

"AWS::CloudFormation::Init" : {

"webapp-config": {

"packages" : {},

"sources" : {},

"files" : {},

"groups" : {},

"users" : {},

"commands" : {},

"services" : {}

}

}

},

Page 26: Defining VPC Based Web Apps in AWS CloudFormation

"packages" : {},

"sources" : {},

"files" : {},

"groups" : {},

"users" : {},

"commands" : {},

"services" : {}

Page 27: Defining VPC Based Web Apps in AWS CloudFormation

Managing your stacks

Page 28: Defining VPC Based Web Apps in AWS CloudFormation

Frontend Services

• E-Commerce Website

Backend Services

• Search, Payment Gateway, Reviews, Recommendations

Shared Services

• Common Monitoring tools, Queues

Base Network

• VPCs, Subnets, VPNs, NATs

Identity • IAM Users, Groups, Roles

Page 29: Defining VPC Based Web Apps in AWS CloudFormation

E-Commerce Website Recommendations Engine

"Parameters" : {

“RecommendationsEndPoint” : {

“Description” : “URL of the recommendations ELB”,

“Type” : “String”

}

},

"Outputs" : {

"RecommendationsEndPoint" : {

"Description" : "URL of the recommendations ELB",

"Value" : { ”Fn::GetAtt" : [ "RecommendationsELB”, “PublicDnsName” ] }

}

}

Page 30: Defining VPC Based Web Apps in AWS CloudFormation

ELB_AND_AS

“Resources” : {

“ELB”,

“AutoScaling”

}

Website1

“Resources” : {

“NestedStack”,

“RDS”

}

Website2

“Resources” : {

“NestedStack”,

“DynamoDB”

}

Website1

“Resources” : {

“ELB”,

“AutoScaling”,

“RDS”

}

Website2

“Resources” : {

“ELB”,

“AutoScaling”,

“DynamoDB”

}

Page 31: Defining VPC Based Web Apps in AWS CloudFormation
Page 32: Defining VPC Based Web Apps in AWS CloudFormation

Amazon

Route 53

Page 33: Defining VPC Based Web Apps in AWS CloudFormation

"UpdatePolicy" : {

"AutoScalingRollingUpdate" : {

"MaxBatchSize" : “2”,

"MinInstancesInService" : ”2”,

"PauseTime" : “PT20M”

}

}

Page 34: Defining VPC Based Web Apps in AWS CloudFormation
Page 35: Defining VPC Based Web Apps in AWS CloudFormation
Page 36: Defining VPC Based Web Apps in AWS CloudFormation

"UpdatePolicy": {

"AutoScalingRollingUpdate": {

"PauseTime": "PT0S",

"MaxBatchSize": “6",

"MinInstancesInService": "0"

}

}

"UpdatePolicy": {

"AutoScalingRollingUpdate": {

"PauseTime": "PT15S",

"MaxBatchSize": "2",

"MinInstancesInService": "2"

}

}

Page 37: Defining VPC Based Web Apps in AWS CloudFormation
Page 38: Defining VPC Based Web Apps in AWS CloudFormation
Page 39: Defining VPC Based Web Apps in AWS CloudFormation

AWS::EC2::VPC::Id

List<AWS::EC2::Subnet::Id>

List<AWS::EC2::SecurityGroup::Id>

AWS::EC2::KeyPair::KeyName

Page 40: Defining VPC Based Web Apps in AWS CloudFormation

{

"AWSTemplateFormatVersion" : "2010-09-09",

"Resources" : {

"myS3Bucket" : {

"Type" : "AWS::S3::Bucket",

"DeletionPolicy" : "Retain"

"Properties" : {

"BucketName" : “MyBucket”

}

}

}

}

{

"AWSTemplateFormatVersion" : "2010-09-09",

"Resources" : {

"myVolume" : {

"Type":"AWS::EC2::Volume",

"DeletionPolicy" : "Snapshot”

"Properties" : {

"AvailabilityZone" :”us-east-1a”,

"Size” : “100”

}

}

}

}

MyBucket myVolume Snapshot

Page 41: Defining VPC Based Web Apps in AWS CloudFormation

“Do not update the databases”

"Effect" : "Deny",

"Principal" : "*",

"Action" : "Update:*",

"Resource" : "*",

"Condition" : {

"StringEquals" : {

"ResourceType” : [

"AWS::RDS::DBInstance”,

"AWS::Redshift::Cluster”

]

}

}

“Okay to update, unless the update requires replacement”

"Effect" : "Deny",

"Principal": "*",

"Action" : "Update:Replace",

"Resource" : "LogicalResourceId/MyInstance"

Page 42: Defining VPC Based Web Apps in AWS CloudFormation

{

"Version": "2012-10-17",

"Statement": [

{

"Effect": ”Deny",

"Action": “*",

"Resource": "*"

},

{

"Effect" : ”Allow",

"Action" : [

"Action": "ec2:Describe*”

],

"Condition": {

"Null": { "ec2:ResourceTag/*cloudformation*" : "true" }

},

"Resource" : "*"

}

]

}

Page 43: Defining VPC Based Web Apps in AWS CloudFormation
Page 44: Defining VPC Based Web Apps in AWS CloudFormation

http://tinyurl.com/pgs3mjo

http://tinyurl.com/pd86795