[{"data":1,"prerenderedAt":90},["ShallowReactive",2],{"pattern-ecs-vpc-lattice-typescript-cdk":3,"pattern-group-ecs-vpc-lattice-typescript-cdk":6},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":10,"deploy":12,"description":18,"extension":19,"framework":20,"gitHub":21,"highlight":6,"introBox":25,"language":31,"level":32,"meta":33,"patternArch":34,"patternGroup":6,"patternGroupLabel":6,"resources":69,"stem":83,"testing":84,"videoId":6,"__hash__":89},"patterns\u002Fpatterns\u002Fecs-vpc-lattice-typescript-cdk.json","Amazon ECS blue\u002Fgreen deployments with Amazon VPC Lattice",null,{"text":8},[9],"Delete the stack: \u003Ccode>npx cdk destroy\u003C\u002Fcode>.",[11],"content\u002Fcontributors\u002Fnithin-chandran-r.json",{"text":13},[14,15,16,17],"npm install","REGION=${AWS_REGION:-$(aws configure get region)}","PL=$(aws ec2 describe-managed-prefix-lists --region $REGION --filters \"Name=prefix-list-name,Values=com.amazonaws.$REGION.vpc-lattice\" --query \"PrefixLists[0].PrefixListId\" --output text)","npx cdk deploy --parameters LatticePrefixListId=$PL","Amazon ECS on AWS Fargate blue\u002Fgreen with Amazon VPC Lattice test and production listener rules, an AWS Lambda test hook and an Amazon CloudWatch alarm for rollback.","json","AWS CDK",{"template":22},{"patternPath":23,"templateFile":24},"ecs-vpc-lattice\u002Ftypescript\u002Fcdk","lib\u002Fecs-vpc-lattice-stack.ts",{"headline":26,"text":27},"How it works",[28,29,30],"This pattern deploys an Amazon ECS on AWS Fargate service that uses the built-in blue\u002Fgreen deployment strategy with Amazon VPC Lattice. The VPC Lattice service has a listener with a test rule (header `x-environment: test`) and a production rule, and two IP target groups that ECS registers tasks into.","When you deploy a new version, ECS starts the green tasks and sends test traffic to them. An AWS Lambda lifecycle hook in the VPC calls the VPC Lattice test rule, compares the version it receives with the expected one and returns SUCCEEDED or FAILED. Only then does ECS shift production traffic. An Amazon CloudWatch alarm on VPC Lattice 5xx responses rolls the deployment back automatically.","The VPC Lattice service uses auth type `NONE`, so any client in the associated VPC can call it. For production, use auth type `AWS_IAM` with an auth policy.","TypeScript","300",{},{"icon1":35,"icon2":40,"icon3":44,"icon4":49,"icon5":52,"line1":56,"line2":60,"line3":63,"line4":66},{"x":36,"y":37,"service":38,"label":39},12,52,"lambda-event-functions","AWS Lambda\nTest hook",{"x":41,"y":37,"service":42,"label":43},38,"vpc-lattice","Amazon VPC Lattice\nRouting rules",{"x":45,"y":46,"service":47,"label":48},64,20,"fargate","AWS Fargate\nBlue",{"x":45,"y":50,"service":47,"label":51},75,"AWS Fargate\nGreen",{"x":53,"y":37,"service":54,"label":55},88,"cloudwatch","Amazon CloudWatch\nAlarms",{"from":57,"to":58,"label":59},"icon1","icon2","Test header",{"from":58,"to":61,"label":62},"icon3","Prod",{"from":58,"to":64,"label":65},"icon4","Test",{"from":58,"to":67,"label":68},"icon5","Metrics",{"bullets":70},[71,74,77,80],{"text":72,"link":73},"Amazon ECS blue\u002Fgreen deployments","https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonECS\u002Flatest\u002Fdeveloperguide\u002Fdeployment-type-blue-green.html",{"text":75,"link":76},"VPC Lattice resources for Amazon ECS blue\u002Fgreen, linear, and canary deployments","https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonECS\u002Flatest\u002Fdeveloperguide\u002Fvpc-lattice-resources-for-blue-green.html",{"text":78,"link":79},"Lambda hooks for Amazon ECS service deployments","https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonECS\u002Flatest\u002Fdeveloperguide\u002Flambda-lifecycle-hooks.html",{"text":81,"link":82},"Control traffic to your VPC Lattice services using security groups","https:\u002F\u002Fdocs.aws.amazon.com\u002Fvpc-lattice\u002Flatest\u002Fug\u002Fsecurity-groups.html","patterns\u002Fecs-vpc-lattice-typescript-cdk",{"text":85},[86,87,88],"Read the stack outputs, then deploy a second version with \u003Ccode>npx cdk deploy --parameters LatticePrefixListId=$PL -c appVersion=v2\u003C\u002Fcode>, with \u003Ccode>PL\u003C\u002Fcode> set as in the deployment steps (look it up again if you opened a new shell).","Watch the deployment with \u003Ccode>aws ecs list-service-deployments\u003C\u002Fcode> and \u003Ccode>aws ecs describe-service-deployments\u003C\u002Fcode>, the production listener rule weights with \u003Ccode>aws vpc-lattice get-rule\u003C\u002Fcode>, and the hook Lambda logs with \u003Ccode>aws logs filter-log-events\u003C\u002Fcode>. The hook log shows the test listener returning the new version before production traffic shifts.","See the GitHub repo for the exact commands and expected output.","6bdjxe_24gW78svbLzDntbBrQ0g_pHB4D6LIXoNYAFw",1795084463258]