Skip to content

Commit 3723aca

Browse files
authored
feat(ecs): add support for native blue/green deployments in ECS L2 (#35061)
### Issue # (if applicable) Closes #35010 ### Reason for this change Introducing ECS native B/G deployment support in L2 constructs. https://aws.amazon.com/blogs/aws/accelerate-safe-software-releases-with-new-built-in-blue-green-deployments-in-amazon-ecs/ ### Description of changes Introduced the following properties to `base-service.ts`: - LoadBalancer - AdvancedConfiguration: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-ecs-service-loadbalancer.html#cfn-ecs-service-loadbalancer-advancedconfiguration - DeploymentConfiguration - Strategy: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-ecs-service-deploymentconfiguration.html#cfn-ecs-service-deploymentconfiguration-strategy - BakeTime: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-ecs-service-deploymentconfiguration.html#cfn-ecs-service-deploymentconfiguration-baketimeinminutes - LifecycleHooks: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-ecs-service-deploymentconfiguration.html#cfn-ecs-service-deploymentconfiguration-lifecyclehooks - ServiceConnect - TestTrafficRules: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-ecs-service-serviceconnectclientalias.html#cfn-ecs-service-serviceconnectclientalias-testtrafficrules ### Describe any new or updated permissions being added ### Description of how you validated changes Add unit tests and an integration test ### Checklist - [X ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8bff8f9 commit 3723aca

15 files changed

+1289
-371
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.blue-green-deployment-strategy.js.snapshot/aws-ecs-blue-green-deployment.assets.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.blue-green-deployment-strategy.js.snapshot/aws-ecs-blue-green-deployment.template.json

Lines changed: 103 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -614,143 +614,6 @@
614614
"Priority": 1
615615
}
616616
},
617-
"EcsTaskExecutionRoleC0B6A84D": {
618-
"Type": "AWS::IAM::Role",
619-
"Properties": {
620-
"AssumeRolePolicyDocument": {
621-
"Statement": [
622-
{
623-
"Action": "sts:AssumeRole",
624-
"Effect": "Allow",
625-
"Principal": {
626-
"Service": "ecs-tasks.amazonaws.com"
627-
}
628-
}
629-
],
630-
"Version": "2012-10-17"
631-
},
632-
"ManagedPolicyArns": [
633-
{
634-
"Fn::Join": [
635-
"",
636-
[
637-
"arn:",
638-
{
639-
"Ref": "AWS::Partition"
640-
},
641-
":iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
642-
]
643-
]
644-
}
645-
]
646-
}
647-
},
648-
"ServiceRole4288B192": {
649-
"Type": "AWS::IAM::Role",
650-
"Properties": {
651-
"AssumeRolePolicyDocument": {
652-
"Statement": [
653-
{
654-
"Action": "sts:AssumeRole",
655-
"Effect": "Allow",
656-
"Principal": {
657-
"Service": "ecs.amazonaws.com"
658-
}
659-
}
660-
],
661-
"Version": "2012-10-17"
662-
},
663-
"ManagedPolicyArns": [
664-
{
665-
"Fn::Join": [
666-
"",
667-
[
668-
"arn:",
669-
{
670-
"Ref": "AWS::Partition"
671-
},
672-
":iam::aws:policy/service-role/AmazonEC2ContainerServiceRole"
673-
]
674-
]
675-
}
676-
],
677-
"Policies": [
678-
{
679-
"PolicyDocument": {
680-
"Statement": [
681-
{
682-
"Action": "lambda:InvokeFunction",
683-
"Effect": "Allow",
684-
"Resource": "*"
685-
}
686-
],
687-
"Version": "2012-10-17"
688-
},
689-
"PolicyName": "LambdaInvokePolicy"
690-
},
691-
{
692-
"PolicyDocument": {
693-
"Statement": [
694-
{
695-
"Action": [
696-
"elasticloadbalancing:ModifyListener",
697-
"elasticloadbalancing:ModifyRule"
698-
],
699-
"Effect": "Allow",
700-
"Resource": {
701-
"Ref": "ALBProductionListenerRule243D0687"
702-
}
703-
}
704-
],
705-
"Version": "2012-10-17"
706-
},
707-
"PolicyName": "ELBPolicy"
708-
}
709-
]
710-
}
711-
},
712-
"ServiceRoleDefaultPolicy94CF55F6": {
713-
"Type": "AWS::IAM::Policy",
714-
"Properties": {
715-
"PolicyDocument": {
716-
"Statement": [
717-
{
718-
"Action": "lambda:InvokeFunction",
719-
"Effect": "Allow",
720-
"Resource": [
721-
{
722-
"Fn::GetAtt": [
723-
"LambdaHookBF1BC8B4",
724-
"Arn"
725-
]
726-
},
727-
{
728-
"Fn::Join": [
729-
"",
730-
[
731-
{
732-
"Fn::GetAtt": [
733-
"LambdaHookBF1BC8B4",
734-
"Arn"
735-
]
736-
},
737-
":*"
738-
]
739-
]
740-
}
741-
]
742-
}
743-
],
744-
"Version": "2012-10-17"
745-
},
746-
"PolicyName": "ServiceRoleDefaultPolicy94CF55F6",
747-
"Roles": [
748-
{
749-
"Ref": "ServiceRole4288B192"
750-
}
751-
]
752-
}
753-
},
754617
"LambdaHookServiceRole9AAAD33B": {
755618
"Type": "AWS::IAM::Role",
756619
"Properties": {
@@ -856,12 +719,6 @@
856719
}
857720
],
858721
"Cpu": "256",
859-
"ExecutionRoleArn": {
860-
"Fn::GetAtt": [
861-
"EcsTaskExecutionRoleC0B6A84D",
862-
"Arn"
863-
]
864-
},
865722
"Family": "awsecsbluegreendeploymentTaskDef51D80572",
866723
"Memory": "512",
867724
"NetworkMode": "awsvpc",
@@ -883,11 +740,6 @@
883740
"Ref": "FargateCluster7CCD5F93"
884741
},
885742
"DeploymentConfiguration": {
886-
"BakeTimeInMinutes": 0,
887-
"DeploymentCircuitBreaker": {
888-
"Enable": false,
889-
"Rollback": false
890-
},
891743
"LifecycleHooks": [
892744
{
893745
"HookTargetArn": {
@@ -896,24 +748,21 @@
896748
"Arn"
897749
]
898750
},
751+
"LifecycleStages": [
752+
"PRE_SCALE_UP"
753+
],
899754
"RoleArn": {
900755
"Fn::GetAtt": [
901-
"ServiceRole4288B192",
756+
"ServicePreScaleUpRoleD002A553",
902757
"Arn"
903758
]
904-
},
905-
"LifecycleStages": [
906-
"POST_TEST_TRAFFIC_SHIFT"
907-
]
759+
}
908760
}
909761
],
910762
"MaximumPercent": 200,
911-
"MinimumHealthyPercent": 100,
763+
"MinimumHealthyPercent": 50,
912764
"Strategy": "BLUE_GREEN"
913765
},
914-
"DeploymentController": {
915-
"Type": "ECS"
916-
},
917766
"EnableECSManagedTags": false,
918767
"HealthCheckGracePeriodSeconds": 60,
919768
"LaunchType": "FARGATE",
@@ -923,14 +772,14 @@
923772
"AlternateTargetGroupArn": {
924773
"Ref": "GreenTG71A27F2F"
925774
},
775+
"ProductionListenerRule": {
776+
"Ref": "ALBProductionListenerRule243D0687"
777+
},
926778
"RoleArn": {
927779
"Fn::GetAtt": [
928-
"ServiceRole4288B192",
780+
"ServiceLBAlternateOptionsRole06C91D94",
929781
"Arn"
930782
]
931-
},
932-
"ProductionListenerRule": {
933-
"Ref": "ALBProductionListenerRule243D0687"
934783
}
935784
},
936785
"ContainerName": "nginx",
@@ -969,6 +818,99 @@
969818
"ALBProductionListenerRule243D0687",
970819
"TaskDefTaskRole1EDB4A67"
971820
]
821+
},
822+
"ServiceLBAlternateOptionsRole06C91D94": {
823+
"Type": "AWS::IAM::Role",
824+
"Properties": {
825+
"AssumeRolePolicyDocument": {
826+
"Statement": [
827+
{
828+
"Action": "sts:AssumeRole",
829+
"Effect": "Allow",
830+
"Principal": {
831+
"Service": "ecs.amazonaws.com"
832+
}
833+
}
834+
],
835+
"Version": "2012-10-17"
836+
},
837+
"ManagedPolicyArns": [
838+
{
839+
"Fn::Join": [
840+
"",
841+
[
842+
"arn:",
843+
{
844+
"Ref": "AWS::Partition"
845+
},
846+
":iam::aws:policy/AmazonECSInfrastructureRolePolicyForLoadBalancers"
847+
]
848+
]
849+
}
850+
]
851+
},
852+
"DependsOn": [
853+
"TaskDefTaskRole1EDB4A67"
854+
]
855+
},
856+
"ServicePreScaleUpRoleD002A553": {
857+
"Type": "AWS::IAM::Role",
858+
"Properties": {
859+
"AssumeRolePolicyDocument": {
860+
"Statement": [
861+
{
862+
"Action": "sts:AssumeRole",
863+
"Effect": "Allow",
864+
"Principal": {
865+
"Service": "ecs.amazonaws.com"
866+
}
867+
}
868+
],
869+
"Version": "2012-10-17"
870+
}
871+
}
872+
},
873+
"ServicePreScaleUpRoleDefaultPolicyF1032E86": {
874+
"Type": "AWS::IAM::Policy",
875+
"Properties": {
876+
"PolicyDocument": {
877+
"Statement": [
878+
{
879+
"Action": "lambda:InvokeFunction",
880+
"Effect": "Allow",
881+
"Resource": [
882+
{
883+
"Fn::GetAtt": [
884+
"LambdaHookBF1BC8B4",
885+
"Arn"
886+
]
887+
},
888+
{
889+
"Fn::Join": [
890+
"",
891+
[
892+
{
893+
"Fn::GetAtt": [
894+
"LambdaHookBF1BC8B4",
895+
"Arn"
896+
]
897+
},
898+
":*"
899+
]
900+
]
901+
}
902+
]
903+
}
904+
],
905+
"Version": "2012-10-17"
906+
},
907+
"PolicyName": "ServicePreScaleUpRoleDefaultPolicyF1032E86",
908+
"Roles": [
909+
{
910+
"Ref": "ServicePreScaleUpRoleD002A553"
911+
}
912+
]
913+
}
972914
}
973915
},
974916
"Parameters": {

packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.blue-green-deployment-strategy.js.snapshot/integ.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)