diff --git a/infrastructure/cloudformation/dt/auth_task.yaml b/infrastructure/cloudformation/dt/auth_task.yaml new file mode 100644 index 0000000..bafd766 --- /dev/null +++ b/infrastructure/cloudformation/dt/auth_task.yaml @@ -0,0 +1,49 @@ +AWSTemplateFormatVersion: '2010-09-09' +Description: Defend Togeher ECS Task +Parameters: + LogGroupName: + Type: String + Description: The AWS CloudWatch log group to output logs to. + Default: "/ecs/dt" + + environment: + Type: String + Description: Name of the environment to use in naming. + Default: production + + DockerTag: + Description: Tag in DockerHub to deploy + Type: String + Default: "latest" + +Resources: + + LogGroup: + Type: AWS::Logs::LogGroup + Properties: + RetentionInDays: 7 + LogGroupName: !Sub "${LogGroupName}-auth/${environment}" + + TaskDefinition: + Type: AWS::ECS::TaskDefinition + Properties: + ContainerDefinitions: + - Name: defend-together-authorizer + Essential: 'true' + Image: !Sub "josephbmanley/defend-together-authorizer:${DockerTag}" + MemoryReservation: 250 + PortMappings: + - HostPort: 7778 + ContainerPort: 7778 + Protocol: tcp + LogConfiguration: + LogDriver: awslogs + Options: + awslogs-region: + Ref: AWS::Region + awslogs-group: + Ref: LogGroup +Outputs: + TaskArn: + Description: ARN of the TaskDefinition + Value: !Ref TaskDefinition \ No newline at end of file diff --git a/infrastructure/cloudformation/dt/task.yaml b/infrastructure/cloudformation/dt/server_task.yaml similarity index 100% rename from infrastructure/cloudformation/dt/task.yaml rename to infrastructure/cloudformation/dt/server_task.yaml diff --git a/infrastructure/cloudformation/dt/top.yaml b/infrastructure/cloudformation/dt/top.yaml index 54f4f9a..ab14f7a 100644 --- a/infrastructure/cloudformation/dt/top.yaml +++ b/infrastructure/cloudformation/dt/top.yaml @@ -104,13 +104,15 @@ Resources: SubnetIds: !Join [",", !Split [" ", !Ref PublicSubnets]] Project: "DT" - #------------------- - # ECS Task & Service - #------------------- + #---------------------- + # ECS Tasks & Services + #---------------------- + + # Game Server TaskDefinition: Type: AWS::CloudFormation::Stack Properties: - TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/task.yaml' + TemplateURL: !Sub 'https://s3.${AWS::Region}.amazonaws.com/sumu-stacks/dt/${release}/cloudformation/dt/sever_task.yaml' Parameters: environment: !Ref environment LogGroupName: !Ref LogGroup @@ -124,7 +126,21 @@ Resources: Cluster: !GetAtt EcsCluster.Outputs.Cluster DesiredCount: 1 TaskDefinition: !GetAtt TaskDefinition.Outputs.TaskArn - LoadBalancers: - - ContainerName: "defend-together" - ContainerPort: 7777 - TargetGroupArn: !GetAtt LoadBalancing.Outputs.TargetGroup \ No newline at end of file + + # 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 \ No newline at end of file