This repository has been archived on 2023-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
defend-together/infrastructure/cloudformation/dt/top.yaml

182 lines
5.3 KiB
YAML
Raw Normal View History

AWSTemplateFormatVersion: '2010-09-09'
Description: Defend Together ECS Infrastructure
Parameters:
#------------------------
# Deployment Information
#------------------------
environment:
Type: String
Description: Name of the environment to use in naming.
Default: production
release:
Type: String
Description: Name of the release name of the stack version to use.
Default: production
2020-05-01 05:47:00 +02:00
AllowedValues: ['develop', 'stage', 'production']
ConstraintDescription: "Must be a possible release version."
VpcId:
Description: ID of the VPC
Type: AWS::EC2::VPC::Id
2020-05-01 05:47:00 +02:00
DockerTag:
Description: Tag in DockerHub to deploy
Type: String
Default: "latest"
#-----------------
# Load Balancing
#-----------------
PublicSubnets:
Description: The public subnets for the ALB to run in. (Space seperated)
Type: String
#-----
# DNS
#-----
Domain:
Type: String
Description: The domain to create the endpoint on (Must have an existing hosted zone ex. `example.com`) Leave blank to skip DNS.
Default: ""
SubDomain:
Type: String
Description: The subdomain to be used by dt. (ex. `dt.example.com`)
Default: dt
#------------
# CloudWatch
#------------
LogGroup:
Type: String
Description: The AWS CloudWatch log group to output logs to.
Default: "/ecs/dt"
Conditions:
CreateDns: !Not [!Equals [!Ref Domain, ""]]
Resources:
#-----
# DNS
#-----
DnsRecords:
Condition: CreateDns
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/dns.yaml'
Parameters:
environment: !Ref environment
Domain: !Ref Domain
SubDomain: !Ref SubDomain
DtDNS: !GetAtt LoadBalancing.Outputs.NlbDnsName
2020-05-14 10:39:51 +02:00
#-----
# IAM
#-----
IAM:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/iam.yaml'
Parameters:
environment: !Ref environment
#--------
# Lambda
#--------
LambdaFunctions:
Type: AWS::CloudFormation::Stack
Properties:
2020-05-14 10:48:49 +02:00
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/lambdas.yaml'
2020-05-14 10:44:53 +02:00
Parameters:
2020-05-14 10:39:51 +02:00
environment: !Ref environment
2020-05-14 11:08:59 +02:00
release: !Ref release
2020-05-14 10:39:51 +02:00
TaskManagerRole: !GetAtt IAM.Outputs.DefaultRole
VpcId: !Ref VpcId
2020-05-14 11:15:17 +02:00
SubnetIds: !Join [",", !Split [" ", !Ref PublicSubnets]]
2020-05-14 10:39:51 +02:00
#------------
# CloudWatch
#------------
CloudWatchRules:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/cloudwatch.yaml'
2020-05-14 10:44:53 +02:00
Parameters:
2020-05-14 10:39:51 +02:00
environment: !Ref environment
Cluster: !GetAtt EcsCluster.Outputs.Cluster
LambdaArn: !GetAtt LambdaFunctions.Outputs.TaskListManager
2020-05-09 11:07:50 +02:00
#---------
# Caching
#---------
RedisCache:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/redis/top.yaml'
Parameters:
Environment: !Ref environment
VpcId: !Ref VpcId
SubnetIds: !Join [",", !Split [" ", !Ref PublicSubnets]]
Project: "DT"
#-----------------
# Load Balancing
#-----------------
LoadBalancing:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/load_balancing.yaml'
Parameters:
environment: !Ref environment
release: !Ref release
VpcId: !Ref VpcId
PublicSubnets: !Join [",", !Split [" ", !Ref PublicSubnets]]
EcsCluster:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/cluster/top.yaml'
Parameters:
Environment: !Ref environment
VpcId: !Ref VpcId
SubnetIds: !Join [",", !Split [" ", !Ref PublicSubnets]]
Project: "DT"
2020-05-10 05:58:10 +02:00
#----------------------
# ECS Tasks & Services
#----------------------
# Game Server
TaskDefinition:
Type: AWS::CloudFormation::Stack
Properties:
2020-05-10 06:03:17 +02:00
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/server_task.yaml'
Parameters:
2020-05-01 05:47:00 +02:00
environment: !Ref environment
LogGroupName: !Ref LogGroup
2020-05-01 05:47:00 +02:00
DockerTag: !Ref DockerTag
EcsService:
DependsOn: LoadBalancing
Type: AWS::ECS::Service
Properties:
Cluster: !GetAtt EcsCluster.Outputs.Cluster
DesiredCount: 1
TaskDefinition: !GetAtt TaskDefinition.Outputs.TaskArn
2020-05-10 05:58:10 +02:00
# Auth Server
AuthTaskDefinition:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/auth_task.yaml'
Parameters:
environment: !Ref environment
LogGroupName: !Ref LogGroup
DockerTag: !Ref DockerTag
RedisHostname: !GetAtt RedisCache.Outputs.Endpoint
AuthService:
Type: AWS::ECS::Service
Properties:
Cluster: !GetAtt EcsCluster.Outputs.Cluster
DesiredCount: 1
TaskDefinition: !GetAtt AuthTaskDefinition.Outputs.TaskArn