Skip to content

Instantly share code, notes, and snippets.

@antklim
Created March 22, 2018 20:24
Show Gist options
  • Save antklim/66be1d9bd54d6d8e198dcc051f68307a to your computer and use it in GitHub Desktop.
Save antklim/66be1d9bd54d6d8e198dcc051f68307a to your computer and use it in GitHub Desktop.
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
Default: SimpleAPIKey
Namespace:
Description: An infrastructure namespace that will be prefixed to resource names
Type: String
Default: simple-api
Resources:
VPC:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/antklim-cf-templates/simple-api/cf.network.yml
Parameters:
Environment: !Ref Environment
Namespace: !Ref Namespace
SecurityGroups:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/antklim-cf-templates/simple-api/cf.security.groups.yml
Parameters:
Environment: !Ref Environment
Namespace: !Ref Namespace
VPC: !GetAtt VPC.Outputs.VPC
LoadBalancers:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/antklim-cf-templates/simple-api/cf.loadbalancer.yml
Parameters:
Environment: !Ref Environment
LoadBalancerSecurityGroup: !GetAtt SecurityGroups.Outputs.LoadBalancerSecurityGroup
Namespace: !Ref Namespace
PublicSubnet1: !GetAtt VPC.Outputs.PublicSubnet1
PublicSubnet2: !GetAtt VPC.Outputs.PublicSubnet2
VPC: !GetAtt VPC.Outputs.VPC
Bastion:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/antklim-cf-templates/simple-api/cf.bastion.instance.yml
Parameters:
BastionSecurityGroup: !GetAtt SecurityGroups.Outputs.BastionSecurityGroup
Environment: !Ref Environment
KeyName: !Ref KeyName
Namespace: !Ref Namespace
PublicSubnet: !GetAtt VPC.Outputs.PublicSubnet1
SimpleAPIService:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub https://s3.amazonaws.com/antklim-cf-templates/simple-api/cf.service.instance.yml
Parameters:
EC2HostSecurityGroup: !GetAtt SecurityGroups.Outputs.EC2HostSecurityGroup
Environment: !Ref Environment
KeyName: !Ref KeyName
LoadBalancerListener: !GetAtt LoadBalancers.Outputs.LoadBalancerListener
Namespace: !Ref Namespace
PrivateSubnet1: !GetAtt VPC.Outputs.PrivateSubnet1
PrivateSubnet2: !GetAtt VPC.Outputs.PrivateSubnet2
VPC: !GetAtt VPC.Outputs.VPC
Outputs:
LoadBalancerUrl:
Description: The URL of the ALB
Value: !GetAtt LoadBalancers.Outputs.LoadBalancerUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment