Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a CloudFormation parameter allowing stack shutdown. #2022

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions cloudformation/jolly-roger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ Parameters:
Description: Comma-separated list of SSH users, each of the form <username>=<ssh_import_id>
Type: String
Default: "evan=gh:ebroder,zarvox=gh:zarvox"
EnableServing:
Description: Whether to bring up the app; set to false to shut it down and save on costs
Type: String
Default: "true"
AllowedValues: ["true", "false"]

Conditions:
HavePapertrail: !Not [!Equals [!Ref PapertrailHost, ""]]
HaveCloudWatch: !Equals [!Ref EnableCloudWatch, "true"]
HaveServing: !Equals [!Ref EnableServing, "true"]

Resources:
LambdaExecutionRole:
Expand Down Expand Up @@ -263,24 +269,29 @@ Resources:

VPC:
Type: AWS::EC2::VPC
Condition: HaveServing
Properties:
CidrBlock: 10.32.0.0/16
EnableDnsHostnames: true

PublicSubnetRouteTable:
Type: AWS::EC2::RouteTable
Condition: HaveServing
Properties:
VpcId: !Ref VPC

InternetGateway:
Type: AWS::EC2::InternetGateway
Condition: HaveServing
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Condition: HaveServing
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
PublicRouteToInternet:
Type: AWS::EC2::Route
Condition: HaveServing
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
Expand All @@ -289,26 +300,30 @@ Resources:

PublicSubnet1:
Type: AWS::EC2::Subnet
Condition: HaveServing
Properties:
AvailabilityZone: !Select [0, !GetAZs ""]
CidrBlock: 10.32.0.0/24
MapPublicIpOnLaunch: true
VpcId: !Ref VPC
PublicSubnet1RouteTableAssoc:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: HaveServing
Properties:
RouteTableId: !Ref PublicSubnetRouteTable
SubnetId: !Ref PublicSubnet1

PublicSubnet2:
Type: AWS::EC2::Subnet
Condition: HaveServing
Properties:
AvailabilityZone: !Select [1, !GetAZs ""]
CidrBlock: 10.32.1.0/24
MapPublicIpOnLaunch: true
VpcId: !Ref VPC
PublicSubnet2RouteTableAssoc:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: HaveServing
Properties:
RouteTableId: !Ref PublicSubnetRouteTable
SubnetId: !Ref PublicSubnet2
Expand Down Expand Up @@ -387,6 +402,7 @@ Resources:

AppSecurityGroup:
Type: AWS::EC2::SecurityGroup
Condition: HaveServing
Properties:
GroupDescription: Security group for app server instances
SecurityGroupEgress:
Expand Down Expand Up @@ -441,6 +457,7 @@ Resources:

AppNlb:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Condition: HaveServing
Properties:
Type: network
Scheme: internet-facing
Expand All @@ -449,6 +466,7 @@ Resources:
- !Ref PublicSubnet2
AppNlbTargetHTTP:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Condition: HaveServing
Properties:
HealthCheckProtocol: HTTP
HealthCheckPort: 443
Expand All @@ -465,6 +483,7 @@ Resources:
Value: true
AppNlbTargetHTTPS:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Condition: HaveServing
Properties:
HealthCheckProtocol: HTTP
HealthCheckPort: 443
Expand All @@ -481,6 +500,7 @@ Resources:
Value: true
AppNlbListenerHTTP:
Type: AWS::ElasticLoadBalancingV2::Listener
Condition: HaveServing
Properties:
LoadBalancerArn: !Ref AppNlb
Protocol: TCP
Expand All @@ -490,6 +510,7 @@ Resources:
TargetGroupArn: !Ref AppNlbTargetHTTP
AppNlbListenerHTTPS:
Type: AWS::ElasticLoadBalancingV2::Listener
Condition: HaveServing
Properties:
LoadBalancerArn: !Ref AppNlb
Protocol: TLS
Expand All @@ -503,6 +524,7 @@ Resources:

AppLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Condition: HaveServing
Properties:
LaunchTemplateData:
IamInstanceProfile:
Expand Down Expand Up @@ -942,6 +964,7 @@ Resources:

AppAsg:
Type: AWS::AutoScaling::AutoScalingGroup
Condition: HaveServing
Properties:
HealthCheckType: ELB
HealthCheckGracePeriod: 1800
Expand Down Expand Up @@ -970,6 +993,7 @@ Resources:

AppDns:
Type: AWS::Route53::RecordSet
Condition: HaveServing
Properties:
HostedZoneId: !Ref AppDomain
Name: !Ref AppUrl
Expand Down