Be more careful with default types (#34)

This commit is contained in:
Niklas Fondberg
2021-09-09 09:40:40 +02:00
committed by GitHub
parent 4eb04534f5
commit 692b530623
11 changed files with 130 additions and 41 deletions
+31 -27
View File
@@ -91,7 +91,7 @@ Resources:
Cluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Join ["", [!Ref "AWS::StackName", Cluster]]
ClusterName: !Join ['', [!Ref 'AWS::StackName', Cluster]]
TaskDefinition:
Type: AWS::ECS::TaskDefinition
@@ -99,7 +99,7 @@ Resources:
DependsOn: LogGroup
Properties:
# Name of the task definition. Subsequent versions of the task definition are grouped together under this name.
Family: !Join ["", [!Ref "AWS::StackName", TaskDefinition]]
Family: !Join ['', [!Ref 'AWS::StackName', TaskDefinition]]
# awsvpc is required for Fargate
NetworkMode: awsvpc
RequiresCompatibilities:
@@ -119,10 +119,14 @@ Resources:
- ContainerPort: !Ref ContainerPort
# Define which parameters should be fetched
Secrets:
- Name: "DATABASE_URL"
ValueFrom: !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${EnvironmentName}/graphql-api/DATABASE_URL"
- Name: "COGNITO_POOL_ID"
ValueFrom: !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${EnvironmentName}/cognito/ADMIN_POOL_ID"
- Name: 'DATABASE_URL'
ValueFrom: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${EnvironmentName}/graphql-api/DATABASE_URL'
- Name: 'COGNITO_POOL_ID'
ValueFrom: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${EnvironmentName}/cognito/ADMIN_POOL_ID'
- Name: 'INTERIORS_URL'
ValueFrom: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${EnvironmentName}/INTERIORS_URL'
- Name: 'INTERIORS_TOKEN'
ValueFrom: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/${EnvironmentName}/INTERIORS_TOKEN'
# Send logs to CloudWatch Logs
LogConfiguration:
LogDriver: awslogs
@@ -135,47 +139,47 @@ Resources:
ExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Join ["", [!Ref "AWS::StackName", ExecutionRole]]
RoleName: !Join ['', [!Ref 'AWS::StackName', ExecutionRole]]
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: "sts:AssumeRole"
Action: 'sts:AssumeRole'
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
- 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'
- arn:aws:iam::aws:policy/AmazonSSMReadOnlyAccess
# A role for the containers
TaskRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Join ["", [!Ref "AWS::StackName", TaskRole]]
RoleName: !Join ['', [!Ref 'AWS::StackName', TaskRole]]
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: "sts:AssumeRole"
Action: 'sts:AssumeRole'
# A role needed for auto scaling
AutoScalingRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Join ["", [!Ref "AWS::StackName", AutoScalingRole]]
RoleName: !Join ['', [!Ref 'AWS::StackName', AutoScalingRole]]
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: "sts:AssumeRole"
Action: 'sts:AssumeRole'
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceAutoscaleRole"
- 'arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceAutoscaleRole'
ContainerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription:
!Join ["", [!Ref "AWS::StackName", ContainerSecurityGroup]]
!Join ['', [!Ref 'AWS::StackName', ContainerSecurityGroup]]
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
@@ -187,7 +191,7 @@ Resources:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription:
!Join ["", [!Ref "AWS::StackName", LoadBalancerSecurityGroup]]
!Join ['', [!Ref 'AWS::StackName', LoadBalancerSecurityGroup]]
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
@@ -235,7 +239,7 @@ Resources:
HealthCheckTimeoutSeconds: 10
UnhealthyThresholdCount: 2
HealthyThresholdCount: 2
Name: !Join ["", [!Ref "AWS::StackName", Group]]
Name: !Join ['', [!Ref 'AWS::StackName', Group]]
Port: !Ref ContainerPort
Protocol: HTTP
TargetGroupAttributes:
@@ -262,7 +266,7 @@ Resources:
LoadBalancerAttributes:
- Key: idle_timeout.timeout_seconds
Value: 1200
Name: !Join ["", [!Ref "AWS::StackName", LB]]
Name: !Join ['', [!Ref 'AWS::StackName', LB]]
# "internal" is also an option
Scheme: internet-facing
SecurityGroups:
@@ -274,8 +278,8 @@ Resources:
DNSRecord:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneName: !Join ["", [!Ref HostedZoneName, .]]
Name: !Join ["", [!Ref Subdomain, ., !Ref HostedZoneName, .]]
HostedZoneName: !Join ['', [!Ref HostedZoneName, .]]
Name: !Join ['', [!Ref Subdomain, ., !Ref HostedZoneName, .]]
Type: A
AliasTarget:
DNSName: !GetAtt LoadBalancer.DNSName
@@ -284,14 +288,14 @@ Resources:
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Join ["", [/ecs/, !Ref "AWS::StackName", TaskDefinition]]
LogGroupName: !Join ['', [/ecs/, !Ref 'AWS::StackName', TaskDefinition]]
AutoScalingTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MinCapacity: !Ref MinContainers
MaxCapacity: !Ref MaxContainers
ResourceId: !Join ["/", [service, !Ref Cluster, !GetAtt Service.Name]]
ResourceId: !Join ['/', [service, !Ref Cluster, !GetAtt Service.Name]]
ScalableDimension: ecs:service:DesiredCount
ServiceNamespace: ecs
# "The Amazon Resource Name (ARN) of an AWS Identity and Access Management (IAM) role that allows Application Auto Scaling to modify your scalable target."
@@ -299,7 +303,7 @@ Resources:
AutoScalingPolicy:
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: !Join ["", [!Ref "AWS::StackName", AutoScalingPolicy]]
PolicyName: !Join ['', [!Ref 'AWS::StackName', AutoScalingPolicy]]
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref AutoScalingTarget
TargetTrackingScalingPolicyConfiguration:
@@ -327,7 +331,7 @@ Resources:
PolicyDocument:
Version: 2012-10-17
Statement:
- Resource: "*"
- Resource: '*'
Effect: Allow
Action:
- logs:CreateLogGroup
@@ -380,7 +384,7 @@ Resources:
- s3:GetObject
- s3:GetObjectVersion
- s3:GetBucketVersioning
- Resource: "*"
- Resource: '*'
Effect: Allow
Action:
- ecs:List*
@@ -455,7 +459,7 @@ Resources:
Type: AWS::CodePipeline::Pipeline
Properties:
RoleArn: !GetAtt CodePipelineServiceRole.Arn
Name: !Join ["", [!Ref "AWS::StackName", Pipeline]]
Name: !Join ['', [!Ref 'AWS::StackName', Pipeline]]
ArtifactStore:
Type: S3
Location: !Ref ArtifactBucket
@@ -511,7 +515,7 @@ Resources:
Outputs:
Endpoint:
Description: Endpoint
Value: !Join ["", ["https://", !Ref DNSRecord]]
Value: !Join ['', ['https://', !Ref DNSRecord]]
Service:
Value: Service
PipelineUrl: