Skip to content

Instantly share code, notes, and snippets.

LaunchConfiguration:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: !FindInMap [AWSRegionToAMI, !Ref "AWS::Region", AMI]
InstanceType: t2.micro
SecurityGroups:
- !Ref EC2HostSecurityGroup
IamInstanceProfile: !Ref InstanceProfile
UserData:
"Fn::Base64": !Sub |
InstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Outputs:
VPC:
Description: A reference to the created VPC
Value: !Ref VPC
PublicSubnet1:
Description: A reference to the public subnet in the 1st Availability Zone
Value: !Ref PublicSubnet1
PublicSubnet2:
// simple API
app.use('/healthcheck', require('express-healthcheck')())
app.use('/echo', (req, res) => {
res.send({message: `Hello ${req.query.name}`})
})
Description: This template deploys infrastructure for SimpleAPI
Parameters:
Environment:
Description: An environment name that will be prefixed to resource names
Type: String
KeyName:
Description: EC2 key pair name for bastion host SSH access
Type: AWS::EC2::KeyPair::KeyName
Description: This template deploys security groups for SimpleAPI
Parameters:
Environment:
Description: An environment name that will be prefixed to resource names
Type: String
Namespace:
Description: An infrastructure namespace that will be prefixed to resource names
Type: String
Description: This template deploys bastion instance for SimpleAPI
Parameters:
BastionSecurityGroup:
Description: A reference to the security group for Bastion host
Type: String
Environment:
Description: An environment name that will be prefixed to resource names
Type: String
Description: This template deploys service instances for SimpleAPI
Parameters:
...
KeyName:
Description: EC2 key pair name for bastion host SSH access
Type: AWS::EC2::KeyPair::KeyName
...
Resources:
#!/bin/bash
PROFILE=$1
REGION=$2
BUCKET=$3
AWS_PROFILE=$PROFILE AWS_REGION=$REGION aws s3 cp ./cloudformation/cf.bastion.instance.yml s3://$BUCKET/cf.bastion.instance.yml
AWS_PROFILE=$PROFILE AWS_REGION=$REGION aws s3 cp ./cloudformation/cf.loadbalancer.yml s3://$BUCKET/cf.loadbalancer.yml
AWS_PROFILE=$PROFILE AWS_REGION=$REGION aws s3 cp ./cloudformation/cf.master.yml s3://$BUCKET/cf.master.yml
AWS_PROFILE=$PROFILE AWS_REGION=$REGION aws s3 cp ./cloudformation/cf.network.yml s3://$BUCKET/cf.network.yml
#!/bin/bash
PROFILE=$1
STACKNAME=$2
BUCKET=$3
ENVIRONMENT=$4
AWS_PROFILE=$PROFILE aws cloudformation create-stack --stack-name $STACKNAME \
--template-url https://s3.amazonaws.com/$BUCKET/cf.master.yml \
--parameters ParameterKey=Environment,ParameterValue=$ENVIRONMENT \