Skip to content

Instantly share code, notes, and snippets.

View pbzona's full-sized avatar
🤠
having fun on the computer

Phil Z pbzona

🤠
having fun on the computer
View GitHub Profile
@pbzona
pbzona / mappings.yml
Created November 21, 2017 21:29
CloudFormation - Mapping example in YAML
Mappings:
RegionMap:
us-east-1:
32: "ami-6411e20d"
64: "ami-7a11e213"
us-west-1:
32: "ami-c9c7978c"
64: "ami-cfc7978a"
Resources:
myEC2Instance:
@pbzona
pbzona / CLI
Created November 21, 2017 21:28
CloudFormation - Launch EC2 with joined tags
$ aws cloudformation create-stack --stack-name ec2-$(date +%s) --template-body file://ec2-join-tag-example.yml --parameters file://params-app-role-env.json
@pbzona
pbzona / ec2-join-tag-example-yaml.yml
Created November 21, 2017 21:24
CloudFormation - Join example in YAML
Parameters:
App:
Description: "Examples: blog, api"
Type: String
Env:
Description: "Examples: prod, stag, dev"
Type: String
Role:
Description: "Examples: web, worker, scheduler"
Type: String
@pbzona
pbzona / join.rb
Created November 21, 2017 21:22
CloudFormation - Join example in Ruby
[app, env, role].join('-')
@pbzona
pbzona / CLI
Created November 21, 2017 21:17
CloudFormation - EC2 launch with larger instance (if)
$ aws cloudformation create-stack --stack-name ec2-$(date +%s) --template-body file://ec2-if-env-is-prod.yml --parameters "ParameterKey=Env,ParameterValue=prod"
@pbzona
pbzona / ec2-if-env-is-prod.yml
Created November 21, 2017 20:56
CloudFormation - Declarative code example in YAML
Parameters:
LargerInstance:
Description: Whether a larger instance should be used
Default: false
Type: String
AllowedValues: [true, false]
Resources:
EC2Instance:
   Type: AWS::EC2::Instance
   Properties:
@pbzona
pbzona / procedural.rb
Last active November 21, 2017 19:58
CloudFormation - Procedural example in Ruby
if env == “prod”
 # create a large m4.large instance for production environment
else
 # create a small t2.micro instance for development environment
end
@pbzona
pbzona / declarative.example
Created November 21, 2017 18:33
CloudFormation - Declarative code example
y = x
x = 1
print(y) # => prints 1
@pbzona
pbzona / procedural.example
Created November 21, 2017 18:32
CloudFormation - Procedural code example
x = 1
y = x
print(y) # => prints 1
@pbzona
pbzona / CLI
Created November 21, 2017 18:13
CloudFormation - EC2 creation command with params from JSON file
$ aws cloudformation create-stack --stack-name ec2-$(date +%s) --template-body file://ec2-param.yml --parameters file://params.json