CloudFormation | Elastic Beanstalk |
---|---|
"Template-driven provisioning" | "Web apps made easy" |
Deploys infrastructure using code | Deploys applications on EC2 (PaaS) |
Can be used to deploy almost any AWS service | Deploys web applications based on Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker |
Uses JSON or YAML template files | Uses ZIP or WAR files |
Similar to Terraform | Similar to Google App Engine |
Component | Description |
---|---|
Templates | JSON or YAML text file containing instructions for building out the AWS environment. |
Stacks | The entire environment described by the template; created, updated, and deleted as a single unit. |
StackSets | Extends stacks to create, update, or delete stacks across multiple accounts and regions with a single operation. |
Change Sets | A summary of proposed changes to your stack; allows previewing impact before implementation. |
Resources
section.Resources:
MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: "ami-0ff8a91507f77f867"
Parameters:
InstanceTypeParameter:
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- m1.small
- m1.large
Description: Enter t2.micro, m1.small, or m1.large. Default is t2.micro.
!Ref
function.AWS::AccountId
, AWS::NotificationARNs
, AWS::Region
, AWS::StackId
, AWS::StackName
, AWS::URLSuffix
, AWS::Partition
.RegionMap:
us-east-1:
HVM64: ami-0ff8a91507f77f867
HVMG2: ami-0a584ac55a7631c0c
us-west-1:
HVM64: ami-0bdb828fd58c52235
HVMG2: ami-066ee5fd4a9ef77f1
Outputs:
StackVPC:
Description: The ID of the VPC
Value: !Ref MyVPC
Export:
Name: !Sub "${AWS::StackName}-VPCID"
Conditions:
CreateProdResources: !Equals [ !Ref EnvType, prod ]
Transform: AWS::Serverless-2016-10-31
Resources:
MyServerlessFunctionLogicalID:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs8.10
CodeUri: 's3://testBucket/mySourceCode.zip'
!Ref
(or Fn::Ref
):
!GetAtt
(or Fn::GetAtt
):
!FindInMap
(or Fn::FindInMap
):
!ImportValue
(or Fn::ImportValue
):
!Join
(or Fn::Join
):
!Sub
(or Fn::Sub
):