Package: cdklabs.ecs-codedeploy
CDK ECS CodeDeployThis project contains CDK constructs to create CodeDeploy ECS deployments.InstallationTypeScriptyarnadd@cdklabs/cdk-ecs-codedeployJavaSeehttps://mvnrepository.com/artifact/io.github.cdklabs/cdk-ecs-codedeployPythonSeehttps://pypi.org/project/cdklabs.ecs-codedeploy/C#Seehttps://www.nuget.org/packages/Cdklabs.CdkEcsCodeDeploy/DeploymentsCodeDeploy for ECS can manage the deployment of new task definitions to ECS services.  Only 1 deployment construct can be defined for a given EcsDeploymentGroup.# deployment_group: codeDeploy.IEcsDeploymentGroup# task_definition: ecs.ITaskDefinitionEcsDeployment(deployment_group=deployment_group,target_service=TargetService(task_definition=task_definition,container_name="mycontainer",container_port=80))The deployment will use the AutoRollbackConfig for the EcsDeploymentGroup unless it is overridden in the deployment:# deployment_group: codeDeploy.IEcsDeploymentGroup# task_definition: ecs.ITaskDefinitionEcsDeployment(deployment_group=deployment_group,target_service=TargetService(task_definition=task_definition,container_name="mycontainer",container_port=80),auto_rollback=codeDeploy.AutoRollbackConfig(failed_deployment=True,deployment_in_alarm=True,stopped_deployment=False))By default, the deployment will timeout after 30 minutes. The timeout value can be overridden:# deployment_group: codeDeploy.IEcsDeploymentGroup# task_definition: ecs.ITaskDefinitionEcsDeployment(deployment_group=deployment_group,target_service=TargetService(task_definition=task_definition,container_name="mycontainer",container_port=80),timeout=Duration.minutes(60))API CanariesCodeDeploy can leverage Cloudwatch Alarms to trigger automatic rollbacks. TheApiCanaryconstruct simplifies the process for creating CloudWatch Synthetics Canaries to monitor APIs. The following code demonstrates a canary that monitorshttps://xkcd.com/908/info.0.jsonand checks the JSON response to assert thatsafe_titlehas the value of'The Cloud'.canary=ApiCanary(stack,"Canary",base_url="https://xkcd.com",duration_alarm_threshold=Duration.seconds(5),thread_count=5,steps=[ApiTestStep(name="info",path="/908/info.0.json",jmes_path="safe_title",expected_value="The Cloud")])Application Load Balanced CodeDeployed Fargate ServiceAn L3 construct namedApplicationLoadBalancedCodeDeployedFargateServiceextendsApplicationLoadBalancedFargateServiceand adds support for deploying new versions of the service with AWS CodeDeploy. Additionally, an Amazon CloudWatch Synthetic canary is created via theApiCanaryconstruct and is monitored by the CodeDeploy deployment to trigger rollback if the canary begins to alarm.# cluster: ecs.ICluster# image: ecs.ContainerImageservice=ApplicationLoadBalancedCodeDeployedFargateService(stack,"Service",cluster=cluster,task_image_options=ApplicationLoadBalancedTaskImageOptions(image=image),api_test_steps=[ApiTestStep(name="health",path="/health",jmes_path="status",expected_value="ok")])Local Developmentyarninstall
yarnbuild
yarntestTo run an integration test and update the snapshot, run:yarninteg:ecs-deployment:deployTo recreate snapshots for integration tests, run:yarninteg:snapshot-allSecuritySeeCONTRIBUTINGfor more information.LicenseThis project is licensed under the Apache-2.0 License.