config files are ready for the deployment #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AWSTemplateFormatVersion: '2010-09-09' | ||
|
Check failure on line 1 in .github/workflows/template.yml
|
||
| Description: CloudFormation template to create ECR + ECS infra for Document Portal | ||
| Parameters: | ||
| VpcCIDR: | ||
| Type: String | ||
| Default: 10.0.0.0/16 | ||
| Subnet1CIDR: | ||
| Type: String | ||
| Default: 10.0.1.0/24 | ||
| Subnet2CIDR: | ||
| Type: String | ||
| Default: 10.0.2.0/24 | ||
| ImageUrl: | ||
| Type: String | ||
| Description: ECR Image URI to use for container | ||
| Resources: | ||
| MyECRRepository: | ||
| Type: AWS::ECR::Repository | ||
| Properties: | ||
| RepositoryName: documentportal | ||
| ImageScanningConfiguration: | ||
| scanOnPush: true | ||
| ImageTagMutability: MUTABLE | ||
| MyVPC: | ||
| Type: AWS::EC2::VPC | ||
| Properties: | ||
| CidrBlock: !Ref VpcCIDR | ||
| EnableDnsSupport: true | ||
| EnableDnsHostnames: true | ||
| Tags: | ||
| - Key: Name | ||
| Value: ecs-vpc | ||
| Subnet1: | ||
| Type: AWS::EC2::Subnet | ||
| Properties: | ||
| VpcId: !Ref MyVPC | ||
| CidrBlock: !Ref Subnet1CIDR | ||
| AvailabilityZone: !Select [0, !GetAZs ''] | ||
| MapPublicIpOnLaunch: true | ||
| Tags: | ||
| - Key: Name | ||
| Value: public-subnet-1 | ||
| Subnet2: | ||
| Type: AWS::EC2::Subnet | ||
| Properties: | ||
| VpcId: !Ref MyVPC | ||
| CidrBlock: !Ref Subnet2CIDR | ||
| AvailabilityZone: !Select [1, !GetAZs ''] | ||
| MapPublicIpOnLaunch: true | ||
| Tags: | ||
| - Key: Name | ||
| Value: public-subnet-2 | ||
| InternetGateway: | ||
| Type: AWS::EC2::InternetGateway | ||
| AttachGateway: | ||
| Type: AWS::EC2::VPCGatewayAttachment | ||
| Properties: | ||
| VpcId: !Ref MyVPC | ||
| InternetGatewayId: !Ref InternetGateway | ||
| RouteTable: | ||
| Type: AWS::EC2::RouteTable | ||
| Properties: | ||
| VpcId: !Ref MyVPC | ||
| PublicRoute: | ||
| Type: AWS::EC2::Route | ||
| DependsOn: AttachGateway | ||
| Properties: | ||
| RouteTableId: !Ref RouteTable | ||
| DestinationCidrBlock: 0.0.0.0/0 | ||
| GatewayId: !Ref InternetGateway | ||
| RouteAssoc1: | ||
| Type: AWS::EC2::SubnetRouteTableAssociation | ||
| Properties: | ||
| SubnetId: !Ref Subnet1 | ||
| RouteTableId: !Ref RouteTable | ||
| RouteAssoc2: | ||
| Type: AWS::EC2::SubnetRouteTableAssociation | ||
| Properties: | ||
| SubnetId: !Ref Subnet2 | ||
| RouteTableId: !Ref RouteTable | ||
| ECSCluster: | ||
| Type: AWS::ECS::Cluster | ||
| Properties: | ||
| ClusterName: document-portal-cluster | ||
| ECSExecutionRole: | ||
| Type: AWS::IAM::Role | ||
| Properties: | ||
| AssumeRolePolicyDocument: | ||
| Version: '2012-10-17' | ||
| Statement: | ||
| - Effect: Allow | ||
| Principal: | ||
| Service: ecs-tasks.amazonaws.com | ||
| Action: sts:AssumeRole | ||
| ManagedPolicyArns: | ||
| - arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy | ||
| ECSSecurityGroup: | ||
| Type: AWS::EC2::SecurityGroup | ||
| Properties: | ||
| GroupDescription: Allow access to container port | ||
| VpcId: !Ref MyVPC | ||
| SecurityGroupIngress: | ||
| - IpProtocol: tcp | ||
| FromPort: 8080 | ||
| ToPort: 8080 | ||
| CidrIp: 0.0.0.0/0 | ||
| ECSTaskDefinition: | ||
| Type: AWS::ECS::TaskDefinition | ||
| Properties: | ||
| Family: documentportaltd | ||
| Cpu: 256 | ||
| Memory: 512 | ||
| NetworkMode: awsvpc | ||
| RequiresCompatibilities: | ||
| - FARGATE | ||
| ExecutionRoleArn: !GetAtt ECSExecutionRole.Arn | ||
| ContainerDefinitions: | ||
| - Name: document-portal-container | ||
| Image: !Ref ImageUrl | ||
| PortMappings: | ||
| - ContainerPort: 8080 | ||
| Essential: true | ||
| LogConfiguration: | ||
| LogDriver: awslogs | ||
| Options: | ||
| awslogs-group: /ecs/documentportal | ||
| awslogs-region: !Ref AWS::Region | ||
| awslogs-stream-prefix: ecs | ||
| ECSService: | ||
| Type: AWS::ECS::Service | ||
| DependsOn: AttachGateway | ||
| Properties: | ||
| ServiceName: document-portal-service | ||
| Cluster: !Ref ECSCluster | ||
| LaunchType: FARGATE | ||
| DesiredCount: 1 | ||
| NetworkConfiguration: | ||
| AwsvpcConfiguration: | ||
| AssignPublicIp: ENABLED | ||
| Subnets: | ||
| - !Ref Subnet1 | ||
| - !Ref Subnet2 | ||
| SecurityGroups: | ||
| - !Ref ECSSecurityGroup | ||
| TaskDefinition: !Ref ECSTaskDefinition | ||
| Outputs: | ||
| ECSClusterName: | ||
| Value: !Ref ECSCluster | ||
| TaskDefinitionArn: | ||
| Value: !Ref ECSTaskDefinition | ||