diff --git a/dotcom-rendering/cdk/bin/cdk.ts b/dotcom-rendering/cdk/bin/cdk.ts index 43b65b5790b..2da91e98115 100644 --- a/dotcom-rendering/cdk/bin/cdk.ts +++ b/dotcom-rendering/cdk/bin/cdk.ts @@ -142,6 +142,7 @@ export const TagPageRenderingPropsPROD: RenderingCDKStackProps = { }, }, instanceType: InstanceType.of(InstanceClass.C8G, InstanceSize.MEDIUM), + imageIdentifier: process.env.IMAGE_DIGEST!, }; new RenderingCDKStack( diff --git a/dotcom-rendering/cdk/lib/__snapshots__/renderingStack.test.ts.snap b/dotcom-rendering/cdk/lib/__snapshots__/renderingStack.test.ts.snap index 7438704e0c5..7cdbe74bee7 100644 --- a/dotcom-rendering/cdk/lib/__snapshots__/renderingStack.test.ts.snap +++ b/dotcom-rendering/cdk/lib/__snapshots__/renderingStack.test.ts.snap @@ -3697,6 +3697,9 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD "GuHttpsEgressSecurityGroup", "GuAutoScalingGroup", "GuApplicationTargetGroup", + "GuRiffRaffDeploymentIdParameterExperimental", + "GuHttpsEgressSecurityGroup", + "GuApplicationTargetGroup", "GuCertificate", "GuApplicationLoadBalancer", "GuAccessLoggingBucketParameter", @@ -3729,6 +3732,10 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD "Description": "S3 bucket to store your access logs", "Type": "AWS::SSM::Parameter::Value", }, + "DeployToolsAccountIdParameter": { + "Default": "/organisation/accounts/deployTools", + "Type": "AWS::SSM::Parameter::Value", + }, "DistributionBucketName": { "Default": "/account/services/artifact.bucket", "Description": "SSM parameter containing the S3 bucket name holding distribution artifacts", @@ -3739,6 +3746,10 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD "Description": "SSM parameter containing the Name (not ARN) on the kinesis stream", "Type": "AWS::SSM::Parameter::Value", }, + "RiffRaffDeploymentId": { + "Description": "Used by Riff-Raff to inject the deployment ID.", + "Type": "String", + }, "VpcId": { "Default": "/account/vpc/primary/id", "Description": "Virtual Private Cloud to run EC2 instances within. Should NOT be the account default VPC.", @@ -3776,6 +3787,9 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD { "Ref": "InstanceRoleTagpagerendering171BC2F9", }, + { + "Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD", + }, ], }, "Type": "AWS::IAM::Policy", @@ -3811,6 +3825,9 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD { "Ref": "InstanceRoleTagpagerendering171BC2F9", }, + { + "Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD", + }, ], }, "Type": "AWS::IAM::Policy", @@ -3860,6 +3877,9 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD { "Ref": "InstanceRoleTagpagerendering171BC2F9", }, + { + "Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD", + }, ], }, "Type": "AWS::IAM::Policy", @@ -4100,50 +4120,74 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD }, "Type": "AWS::IAM::Policy", }, - "GetDistributablePolicyTagpagerendering346128E3": { + "EcsService81FC6EF6": { + "DependsOn": [ + "EcsTaskDefinitionTaskRoleDefaultPolicy1FD2F057", + "EcsTaskDefinitionTaskRoleB7B6D8DD", + "ListenerTagpagerenderingDeterministicRouteToEc2Rule1C5C95A4", + "ListenerTagpagerenderingDeterministicRouteToEcsRuleAB05C756", + "ListenerTagpagerendering92E57078", + ], "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": "s3:GetObject", - "Effect": "Allow", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:aws:s3:::", - { - "Ref": "DistributionBucketName", - }, - "/frontend/PROD/tag-page-rendering/*", - ], - ], - }, - }, - ], - "Version": "2012-10-17", + "Cluster": { + "Ref": "tagpagerenderingEcsClusterE7696595", }, - "PolicyName": "GetDistributablePolicyTagpagerendering346128E3", - "Roles": [ - { - "Ref": "InstanceRoleTagpagerendering171BC2F9", + "DeploymentConfiguration": { + "Alarms": { + "AlarmNames": [], + "Enable": false, + "Rollback": false, }, - ], - }, - "Type": "AWS::IAM::Policy", - }, - "GuHttpsEgressSecurityGroupTagpagerenderingDC233ADE": { - "Properties": { - "GroupDescription": "Allow all outbound HTTPS traffic", - "SecurityGroupEgress": [ + "DeploymentCircuitBreaker": { + "Enable": true, + "Rollback": true, + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 100, + }, + "DeploymentController": { + "Type": "ECS", + }, + "EnableECSManagedTags": false, + "HealthCheckGracePeriodSeconds": 60, + "LaunchType": "FARGATE", + "LoadBalancers": [ { - "CidrIp": "0.0.0.0/0", - "Description": "Allow all outbound HTTPS traffic", - "FromPort": 443, - "IpProtocol": "tcp", - "ToPort": 443, + "ContainerName": "tag-page-rendering", + "ContainerPort": 9000, + "TargetGroupArn": { + "Ref": "TagpagerenderingEcsTargetGroupTagpagerendering0976D2E5", + }, }, ], + "Monitoring": { + "MetricConfigurations": [ + { + "MetricNames": [ + "CPUUtilization", + "MemoryUtilization", + ], + "ResolutionSeconds": 20, + }, + ], + }, + "NetworkConfiguration": { + "AwsvpcConfiguration": { + "AssignPublicIp": "DISABLED", + "SecurityGroups": [ + { + "Fn::GetAtt": [ + "GuHttpsEgressSecurityGroupTagpagerenderingecsF0505C36", + "GroupId", + ], + }, + ], + "Subnets": { + "Ref": "tagpagerenderingPrivateSubnets", + }, + }, + }, + "PropagateTags": "SERVICE", "Tags": [ { "Key": "App", @@ -4166,11 +4210,652 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD "Value": "PROD", }, ], - "VpcId": { - "Ref": "VpcId", + "TaskDefinition": { + "Ref": "EcsTaskDefinition63157ED3", + }, + }, + "Type": "AWS::ECS::Service", + }, + "EcsServiceTaskCountTarget02FCCE22": { + "DependsOn": [ + "EcsTaskDefinitionTaskRoleDefaultPolicy1FD2F057", + "EcsTaskDefinitionTaskRoleB7B6D8DD", + ], + "Properties": { + "MaxCapacity": 2, + "MinCapacity": 1, + "ResourceId": { + "Fn::Join": [ + "", + [ + "service/", + { + "Ref": "tagpagerenderingEcsClusterE7696595", + }, + "/", + { + "Fn::GetAtt": [ + "EcsService81FC6EF6", + "Name", + ], + }, + ], + ], + }, + "RoleARN": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":iam::", + { + "Ref": "AWS::AccountId", + }, + ":role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService", + ], + ], + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs", + }, + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + }, + "EcsTaskDefinition63157ED3": { + "Properties": { + "ContainerDefinitions": [ + { + "DependsOn": [ + { + "Condition": "START", + "ContainerName": "aws-otel-collector", + }, + ], + "DockerLabels": { + "RiffRaffDeploymentId": { + "Ref": "RiffRaffDeploymentId", + }, + }, + "Environment": [ + { + "Name": "STACK", + "Value": "frontend", + }, + { + "Name": "STAGE", + "Value": "PROD", + }, + { + "Name": "APP", + "Value": "tag-page-rendering", + }, + { + "Name": "TASK_NAME", + "Value": "tag-page-rendering", + }, + { + "Name": "GU_REPO", + "Value": "guardian/dotcom-rendering", + }, + { + "Name": "NODE_ENV", + "Value": "production", + }, + { + "Name": "GU_STAGE", + "Value": "PROD", + }, + { + "Name": "GU_APP", + "Value": "tag-page-rendering", + }, + { + "Name": "GU_STACK", + "Value": "frontend", + }, + { + "Name": "OTEL_EXPORTER_OTLP_ENDPOINT", + "Value": "http://localhost:4318", + }, + { + "Name": "OTEL_SERVICE_NAME", + "Value": "tag-page-rendering", + }, + ], + "Essential": true, + "Image": { + "Fn::Join": [ + "", + [ + { + "Ref": "DeployToolsAccountIdParameter", + }, + ".dkr.ecr.eu-west-1.", + { + "Ref": "AWS::URLSuffix", + }, + "/guardian/dotcom-rendering@sha256:12345", + ], + ], + }, + "LogConfiguration": { + "LogDriver": "awsfirelens", + "Options": { + "Name": "kinesis_streams", + "region": "eu-west-1", + "retry_limit": "2", + "stream": { + "Ref": "LoggingStreamName", + }, + }, + }, + "Name": "tag-page-rendering", + "PortMappings": [ + { + "ContainerPort": 9000, + "Protocol": "tcp", + }, + ], + "ReadonlyRootFilesystem": true, + "VersionConsistency": "disabled", + }, + { + "Environment": [ + { + "Name": "STACK", + "Value": "frontend", + }, + { + "Name": "STAGE", + "Value": "PROD", + }, + { + "Name": "APP", + "Value": "tag-page-rendering", + }, + { + "Name": "TASK_NAME", + "Value": "tag-page-rendering", + }, + { + "Name": "GU_REPO", + "Value": "guardian/dotcom-rendering", + }, + ], + "Essential": true, + "FirelensConfiguration": { + "Type": "fluentbit", + }, + "Image": "ghcr.io/guardian/devx-logs@sha256:cf91724a5166f1c143e07958820aa2122afb61c164b68555d15cb92abb5acda0", + "LogConfiguration": { + "LogDriver": "awslogs", + "Options": { + "awslogs-group": { + "Ref": "EcsTaskDefinitionLogShippingLogGroup0E405BD0", + }, + "awslogs-region": "eu-west-1", + "awslogs-stream-prefix": "frontend/PROD/tag-page-rendering/devx-logs-sidecar", + }, + }, + "MountPoints": [ + { + "ContainerPath": "/init", + "ReadOnly": false, + "SourceVolume": "logging-volume", + }, + ], + "Name": "LogShipping", + "ReadonlyRootFilesystem": true, + "VersionConsistency": "disabled", + }, + { + "Command": [ + "--config=/etc/ecs/ecs-default-config.yaml", + ], + "Cpu": 256, + "Essential": false, + "HealthCheck": { + "Command": [ + "CMD", + "/healthcheck", + ], + "Interval": 5, + "Retries": 2, + "Timeout": 3, + }, + "Image": "public.ecr.aws/aws-observability/aws-otel-collector@sha256:90b3180c21acb9497110480371a413ed91f2836077f8a8fb4507b019d3c481c0", + "LogConfiguration": { + "LogDriver": "awsfirelens", + "Options": { + "Name": "kinesis_streams", + "region": "eu-west-1", + "retry_limit": "2", + "stream": { + "Ref": "LoggingStreamName", + }, + }, + }, + "Memory": 512, + "Name": "aws-otel-collector", + "ReadonlyRootFilesystem": true, + }, + ], + "Cpu": "1024", + "ExecutionRoleArn": { + "Fn::GetAtt": [ + "EcsTaskDefinitionExecutionRoleBE450C73", + "Arn", + ], + }, + "Family": "TagPageRenderingPRODEcsTaskDefinition12224835", + "Memory": "2048", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": [ + "FARGATE", + ], + "RuntimePlatform": { + "CpuArchitecture": "ARM64", + "OperatingSystemFamily": "LINUX", + }, + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + "TaskRoleArn": { + "Fn::GetAtt": [ + "EcsTaskDefinitionTaskRoleB7B6D8DD", + "Arn", + ], + }, + "Volumes": [ + { + "Name": "logging-volume", + }, + ], + }, + "Type": "AWS::ECS::TaskDefinition", + }, + "EcsTaskDefinitionExecutionRoleBE450C73": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + }, + "Type": "AWS::IAM::Role", + }, + "EcsTaskDefinitionExecutionRoleDefaultPolicy1611A942": { + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "ecr:BatchCheckLayerAvailability", + "ecr:GetDownloadUrlForLayer", + "ecr:BatchGetImage", + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":ecr:eu-west-1:", + { + "Ref": "DeployToolsAccountIdParameter", + }, + ":repository/guardian/dotcom-rendering", + ], + ], + }, + }, + { + "Action": "ecr:GetAuthorizationToken", + "Effect": "Allow", + "Resource": "*", + }, + { + "Action": [ + "ecr:BatchCheckLayerAvailability", + "ecr:GetDownloadUrlForLayer", + "ecr:BatchGetImage", + ], + "Effect": "Allow", + "Resource": "arn:aws:ecr:eu-west-1:694911143906:repository/aws-guardduty-agent-fargate", + }, + { + "Action": [ + "logs:CreateLogStream", + "logs:PutLogEvents", + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "EcsTaskDefinitionLogShippingLogGroup0E405BD0", + "Arn", + ], + }, + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "EcsTaskDefinitionExecutionRoleDefaultPolicy1611A942", + "Roles": [ + { + "Ref": "EcsTaskDefinitionExecutionRoleBE450C73", + }, + ], + }, + "Type": "AWS::IAM::Policy", + }, + "EcsTaskDefinitionLogShippingLogGroup0E405BD0": { + "DeletionPolicy": "Retain", + "Properties": { + "RetentionInDays": 1, + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + }, + "Type": "AWS::Logs::LogGroup", + "UpdateReplacePolicy": "Retain", + }, + "EcsTaskDefinitionTaskRoleB7B6D8DD": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + }, + "Type": "AWS::IAM::Role", + }, + "EcsTaskDefinitionTaskRoleDefaultPolicy1FD2F057": { + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "logs:PutLogEvents", + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:DescribeLogStreams", + "logs:DescribeLogGroups", + "logs:PutRetentionPolicy", + "xray:PutTraceSegments", + "xray:PutTelemetryRecords", + "xray:GetSamplingRules", + "xray:GetSamplingTargets", + "xray:GetSamplingStatisticSummaries", + ], + "Effect": "Allow", + "Resource": "*", + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "EcsTaskDefinitionTaskRoleDefaultPolicy1FD2F057", + "Roles": [ + { + "Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD", + }, + ], + }, + "Type": "AWS::IAM::Policy", + }, + "GetDistributablePolicyTagpagerendering346128E3": { + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "s3:GetObject", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:aws:s3:::", + { + "Ref": "DistributionBucketName", + }, + "/frontend/PROD/tag-page-rendering/*", + ], + ], + }, + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "GetDistributablePolicyTagpagerendering346128E3", + "Roles": [ + { + "Ref": "InstanceRoleTagpagerendering171BC2F9", + }, + ], + }, + "Type": "AWS::IAM::Policy", + }, + "GuHttpsEgressSecurityGroupTagpagerenderingDC233ADE": { + "Properties": { + "GroupDescription": "Allow all outbound HTTPS traffic", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound HTTPS traffic", + "FromPort": 443, + "IpProtocol": "tcp", + "ToPort": 443, + }, + ], + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + "VpcId": { + "Ref": "VpcId", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "GuHttpsEgressSecurityGroupTagpagerenderingecsF0505C36": { + "Properties": { + "GroupDescription": "Allow all outbound HTTPS traffic", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound HTTPS traffic", + "FromPort": 443, + "IpProtocol": "tcp", + "ToPort": 443, + }, + ], + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering-ecs", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + "VpcId": { + "Ref": "VpcId", + }, + }, + "Type": "AWS::EC2::SecurityGroup", + }, + "GuHttpsEgressSecurityGroupTagpagerenderingecsfromTagPageRenderingPRODInternalIngressSecurityGroupTagpagerendering1CF134899000E9252A81": { + "Properties": { + "Description": "Load balancer to target", + "FromPort": 9000, + "GroupId": { + "Fn::GetAtt": [ + "GuHttpsEgressSecurityGroupTagpagerenderingecsF0505C36", + "GroupId", + ], + }, + "IpProtocol": "tcp", + "SourceSecurityGroupId": { + "Fn::GetAtt": [ + "InternalIngressSecurityGroupTagpagerendering38FD16DB", + "GroupId", + ], + }, + "ToPort": 9000, + }, + "Type": "AWS::EC2::SecurityGroupIngress", + }, + "GuHttpsEgressSecurityGroupTagpagerenderingecsfromTagPageRenderingPRODLoadBalancerTagpagerenderingSecurityGroup55D2582D900081AA330A": { + "Properties": { + "Description": "Load balancer to target", + "FromPort": 9000, + "GroupId": { + "Fn::GetAtt": [ + "GuHttpsEgressSecurityGroupTagpagerenderingecsF0505C36", + "GroupId", + ], + }, + "IpProtocol": "tcp", + "SourceSecurityGroupId": { + "Fn::GetAtt": [ + "LoadBalancerTagpagerenderingSecurityGroup4D481A16", + "GroupId", + ], }, + "ToPort": 9000, }, - "Type": "AWS::EC2::SecurityGroup", + "Type": "AWS::EC2::SecurityGroupIngress", }, "GuHttpsEgressSecurityGroupTagpagerenderingfromTagPageRenderingPRODInternalIngressSecurityGroupTagpagerendering1CF134899000DECEA4B2": { "Properties": { @@ -4248,6 +4933,9 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD { "Ref": "InstanceRoleTagpagerendering171BC2F9", }, + { + "Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD", + }, ], }, "Type": "AWS::IAM::Policy", @@ -4474,6 +5162,27 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD }, "Type": "AWS::EC2::SecurityGroupEgress", }, + "InternalIngressSecurityGroupTagpagerenderingtoTagPageRenderingPRODGuHttpsEgressSecurityGroupTagpagerenderingecs7BD0DC4E9000C0C61B8C": { + "Properties": { + "Description": "Load balancer to target", + "DestinationSecurityGroupId": { + "Fn::GetAtt": [ + "GuHttpsEgressSecurityGroupTagpagerenderingecsF0505C36", + "GroupId", + ], + }, + "FromPort": 9000, + "GroupId": { + "Fn::GetAtt": [ + "InternalIngressSecurityGroupTagpagerendering38FD16DB", + "GroupId", + ], + }, + "IpProtocol": "tcp", + "ToPort": 9000, + }, + "Type": "AWS::EC2::SecurityGroupEgress", + }, "LatencyScaleDownPolicyLowerAlarm3AAA79CF": { "Properties": { "AlarmActions": [ @@ -4672,8 +5381,21 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD ], "DefaultActions": [ { - "TargetGroupArn": { - "Ref": "TargetGroupTagpagerendering42E428EE", + "ForwardConfig": { + "TargetGroups": [ + { + "TargetGroupArn": { + "Ref": "TargetGroupTagpagerendering42E428EE", + }, + "Weight": 1, + }, + { + "TargetGroupArn": { + "Ref": "TagpagerenderingEcsTargetGroupTagpagerendering0976D2E5", + }, + "Weight": 0, + }, + ], }, "Type": "forward", }, @@ -4709,6 +5431,106 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD }, "Type": "AWS::ElasticLoadBalancingV2::Listener", }, + "ListenerTagpagerenderingDeterministicRouteToEc2Rule1C5C95A4": { + "Properties": { + "Actions": [ + { + "TargetGroupArn": { + "Ref": "TargetGroupTagpagerendering42E428EE", + }, + "Type": "forward", + }, + ], + "Conditions": [ + { + "Field": "http-header", + "HttpHeaderConfig": { + "HttpHeaderName": "X-Gu-Target-Group", + "Values": [ + "ec2", + ], + }, + }, + ], + "ListenerArn": { + "Ref": "ListenerTagpagerendering92E57078", + }, + "Priority": 10, + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + }, + "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", + }, + "ListenerTagpagerenderingDeterministicRouteToEcsRuleAB05C756": { + "Properties": { + "Actions": [ + { + "TargetGroupArn": { + "Ref": "TagpagerenderingEcsTargetGroupTagpagerendering0976D2E5", + }, + "Type": "forward", + }, + ], + "Conditions": [ + { + "Field": "http-header", + "HttpHeaderConfig": { + "HttpHeaderName": "X-Gu-Target-Group", + "Values": [ + "ecs", + ], + }, + }, + ], + "ListenerArn": { + "Ref": "ListenerTagpagerendering92E57078", + }, + "Priority": 11, + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + }, + "Type": "AWS::ElasticLoadBalancingV2::ListenerRule", + }, "LoadBalancerDNS": { "Properties": { "Name": "tag-page-rendering.guardianapis.com", @@ -4856,6 +5678,27 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD }, "Type": "AWS::EC2::SecurityGroupEgress", }, + "LoadBalancerTagpagerenderingSecurityGrouptoTagPageRenderingPRODGuHttpsEgressSecurityGroupTagpagerenderingecs7BD0DC4E9000E1B35F77": { + "Properties": { + "Description": "Load balancer to target", + "DestinationSecurityGroupId": { + "Fn::GetAtt": [ + "GuHttpsEgressSecurityGroupTagpagerenderingecsF0505C36", + "GroupId", + ], + }, + "FromPort": 9000, + "GroupId": { + "Fn::GetAtt": [ + "LoadBalancerTagpagerenderingSecurityGroup4D481A16", + "GroupId", + ], + }, + "IpProtocol": "tcp", + "ToPort": 9000, + }, + "Type": "AWS::EC2::SecurityGroupEgress", + }, "ParameterStoreReadTagpagerendering4CA7B6E3": { "Properties": { "PolicyDocument": { @@ -4903,6 +5746,9 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD { "Ref": "InstanceRoleTagpagerendering171BC2F9", }, + { + "Ref": "EcsTaskDefinitionTaskRoleB7B6D8DD", + }, ], }, "Type": "AWS::IAM::Policy", @@ -4958,6 +5804,55 @@ exports[`The RenderingCDKStack matches the snapshot for Tag Page Rendering PROD }, "Type": "AWS::IAM::Policy", }, + "TagpagerenderingEcsTargetGroupTagpagerendering0976D2E5": { + "Properties": { + "HealthCheckIntervalSeconds": 10, + "HealthCheckPath": "/_healthcheck", + "HealthCheckProtocol": "HTTP", + "HealthCheckTimeoutSeconds": 5, + "HealthyThresholdCount": 5, + "Port": 9000, + "Protocol": "HTTP", + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + "TargetGroupAttributes": [ + { + "Key": "deregistration_delay.timeout_seconds", + "Value": "30", + }, + { + "Key": "stickiness.enabled", + "Value": "false", + }, + ], + "TargetType": "ip", + "UnhealthyThresholdCount": 2, + "VpcId": { + "Ref": "VpcId", + }, + }, + "Type": "AWS::ElasticLoadBalancingV2::TargetGroup", + }, "TargetGroupTagpagerendering42E428EE": { "Properties": { "HealthCheckIntervalSeconds": 10, @@ -5307,6 +6202,39 @@ systemctl start tag-page-rendering", }, "Type": "AWS::IAM::InstanceProfile", }, + "tagpagerenderingEcsClusterE7696595": { + "Properties": { + "ClusterSettings": [ + { + "Name": "containerInsights", + "Value": "enhanced", + }, + ], + "Tags": [ + { + "Key": "App", + "Value": "tag-page-rendering", + }, + { + "Key": "gu:cdk:version", + "Value": "TEST", + }, + { + "Key": "gu:repo", + "Value": "guardian/dotcom-rendering", + }, + { + "Key": "Stack", + "Value": "frontend", + }, + { + "Key": "Stage", + "Value": "PROD", + }, + ], + }, + "Type": "AWS::ECS::Cluster", + }, }, } `; diff --git a/dotcom-rendering/cdk/lib/renderingStack.test.ts b/dotcom-rendering/cdk/lib/renderingStack.test.ts index bfc564e214a..65680999fc6 100644 --- a/dotcom-rendering/cdk/lib/renderingStack.test.ts +++ b/dotcom-rendering/cdk/lib/renderingStack.test.ts @@ -56,7 +56,7 @@ describe('The RenderingCDKStack', () => { expect(template.toJSON()).toMatchSnapshot(); }); - it('matches the snapshot for Tag Page Rendering PROD (does not use ECS)', () => { + it('matches the snapshot for Tag Page Rendering PROD (now using ECS)', () => { const app = new App(); const stack = new RenderingCDKStack( app,