cdklabs.ecs-codedeploy


Namecdklabs.ecs-codedeploy JSON
Version 0.0.278 PyPI version JSON
download
home_pagehttps://github.com/cdklabs/cdk-ecs-codedeploy.git
SummaryCDK Constructs for performing ECS Deployments with CodeDeploy
upload_time2024-05-11 18:14:38
maintainerNone
docs_urlNone
authorAmazon Web Services<aws-cdk-dev@amazon.com>
requires_python~=3.8
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CDK ECS CodeDeploy

[![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg)](https://constructs.dev/packages/@cdklabs/cdk-ecs-codedeploy)
[![npm version](https://badge.fury.io/js/@cdklabs%2Fcdk-ecs-codedeploy.svg)](https://badge.fury.io/js/@cdklabs%2Fcdk-ecs-codedeploy)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.cdklabs/cdk-ecs-codedeploy/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.cdklabs/cdk-ecs-codedeploy)
[![PyPI version](https://badge.fury.io/py/cdklabs.ecs-codedeploy.svg)](https://badge.fury.io/py/cdklabs.ecs-codedeploy)
[![NuGet version](https://badge.fury.io/nu/Cdklabs.CdkEcsCodeDeploy.svg)](https://badge.fury.io/nu/Cdklabs.CdkEcsCodeDeploy)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdklabs/cdk-ecs-codedeploy)
[![Mergify](https://img.shields.io/endpoint.svg?url=https://api.mergify.com/badges/cdklabs/cdk-ecs-codedeploy&style=flat)](https://mergify.io)

This project contains CDK constructs to create CodeDeploy ECS deployments.

## Installation

<details><summary><strong>TypeScript</strong></summary>

```bash
yarn add @cdklabs/cdk-ecs-codedeploy
```

</details><details><summary><strong>Java</strong></summary>

See https://mvnrepository.com/artifact/io.github.cdklabs/cdk-ecs-codedeploy

</details><details><summary><strong>Python</strong></summary>

See https://pypi.org/project/cdklabs.ecs-codedeploy/

</details><details><summary><strong>C#</strong></summary>

See https://www.nuget.org/packages/Cdklabs.CdkEcsCodeDeploy/

</details>

### Deployments

CodeDeploy for ECS can manage the deployment of new task definitions to ECS services.  Only 1 deployment construct can be defined for a given EcsDeploymentGroup.

```python
# deployment_group: codeDeploy.IEcsDeploymentGroup
# task_definition: ecs.ITaskDefinition


EcsDeployment(
    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:

```python
# deployment_group: codeDeploy.IEcsDeploymentGroup
# task_definition: ecs.ITaskDefinition


EcsDeployment(
    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:

```python
# deployment_group: codeDeploy.IEcsDeploymentGroup
# task_definition: ecs.ITaskDefinition


EcsDeployment(
    deployment_group=deployment_group,
    target_service=TargetService(
        task_definition=task_definition,
        container_name="mycontainer",
        container_port=80
    ),
    timeout=Duration.minutes(60)
)
```

### API Canaries

CodeDeploy can leverage Cloudwatch Alarms to trigger automatic rollbacks. The `ApiCanary` construct simplifies the process for creating CloudWatch Synthetics Canaries to monitor APIs. The following code demonstrates a canary that monitors https://xkcd.com/908/info.0.json and checks the JSON response to assert that `safe_title` has the value of `'The Cloud'`.

```python
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 Service

An L3 construct named `ApplicationLoadBalancedCodeDeployedFargateService` extends [ApplicationLoadBalancedFargateService](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedFargateService.html) and adds support for deploying new versions of the service with AWS CodeDeploy. Additionally, an Amazon CloudWatch Synthetic canary is created via the `ApiCanary` construct and is monitored by the CodeDeploy deployment to trigger rollback if the canary begins to alarm.

```python
# cluster: ecs.ICluster
# image: ecs.ContainerImage

service = 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 Development

```bash
yarn install
yarn build
yarn test
```

To run an integration test and update the snapshot, run:

```bash
yarn integ:ecs-deployment:deploy
```

To recreate snapshots for integration tests, run:

```bash
yarn integ:snapshot-all
```

## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

## License

This project is licensed under the Apache-2.0 License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cdklabs/cdk-ecs-codedeploy.git",
    "name": "cdklabs.ecs-codedeploy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Amazon Web Services<aws-cdk-dev@amazon.com>",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ce/fe/1a740a6fd32d52cb68d3dcd88bff243f8b2fb6999df3cb854498805df16f/cdklabs.ecs-codedeploy-0.0.278.tar.gz",
    "platform": null,
    "description": "# CDK ECS CodeDeploy\n\n[![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg)](https://constructs.dev/packages/@cdklabs/cdk-ecs-codedeploy)\n[![npm version](https://badge.fury.io/js/@cdklabs%2Fcdk-ecs-codedeploy.svg)](https://badge.fury.io/js/@cdklabs%2Fcdk-ecs-codedeploy)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.cdklabs/cdk-ecs-codedeploy/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.cdklabs/cdk-ecs-codedeploy)\n[![PyPI version](https://badge.fury.io/py/cdklabs.ecs-codedeploy.svg)](https://badge.fury.io/py/cdklabs.ecs-codedeploy)\n[![NuGet version](https://badge.fury.io/nu/Cdklabs.CdkEcsCodeDeploy.svg)](https://badge.fury.io/nu/Cdklabs.CdkEcsCodeDeploy)\n[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdklabs/cdk-ecs-codedeploy)\n[![Mergify](https://img.shields.io/endpoint.svg?url=https://api.mergify.com/badges/cdklabs/cdk-ecs-codedeploy&style=flat)](https://mergify.io)\n\nThis project contains CDK constructs to create CodeDeploy ECS deployments.\n\n## Installation\n\n<details><summary><strong>TypeScript</strong></summary>\n\n```bash\nyarn add @cdklabs/cdk-ecs-codedeploy\n```\n\n</details><details><summary><strong>Java</strong></summary>\n\nSee https://mvnrepository.com/artifact/io.github.cdklabs/cdk-ecs-codedeploy\n\n</details><details><summary><strong>Python</strong></summary>\n\nSee https://pypi.org/project/cdklabs.ecs-codedeploy/\n\n</details><details><summary><strong>C#</strong></summary>\n\nSee https://www.nuget.org/packages/Cdklabs.CdkEcsCodeDeploy/\n\n</details>\n\n### Deployments\n\nCodeDeploy for ECS can manage the deployment of new task definitions to ECS services.  Only 1 deployment construct can be defined for a given EcsDeploymentGroup.\n\n```python\n# deployment_group: codeDeploy.IEcsDeploymentGroup\n# task_definition: ecs.ITaskDefinition\n\n\nEcsDeployment(\n    deployment_group=deployment_group,\n    target_service=TargetService(\n        task_definition=task_definition,\n        container_name=\"mycontainer\",\n        container_port=80\n    )\n)\n```\n\nThe deployment will use the AutoRollbackConfig for the EcsDeploymentGroup unless it is overridden in the deployment:\n\n```python\n# deployment_group: codeDeploy.IEcsDeploymentGroup\n# task_definition: ecs.ITaskDefinition\n\n\nEcsDeployment(\n    deployment_group=deployment_group,\n    target_service=TargetService(\n        task_definition=task_definition,\n        container_name=\"mycontainer\",\n        container_port=80\n    ),\n    auto_rollback=codeDeploy.AutoRollbackConfig(\n        failed_deployment=True,\n        deployment_in_alarm=True,\n        stopped_deployment=False\n    )\n)\n```\n\nBy default, the deployment will timeout after 30 minutes. The timeout value can be overridden:\n\n```python\n# deployment_group: codeDeploy.IEcsDeploymentGroup\n# task_definition: ecs.ITaskDefinition\n\n\nEcsDeployment(\n    deployment_group=deployment_group,\n    target_service=TargetService(\n        task_definition=task_definition,\n        container_name=\"mycontainer\",\n        container_port=80\n    ),\n    timeout=Duration.minutes(60)\n)\n```\n\n### API Canaries\n\nCodeDeploy can leverage Cloudwatch Alarms to trigger automatic rollbacks. The `ApiCanary` construct simplifies the process for creating CloudWatch Synthetics Canaries to monitor APIs. The following code demonstrates a canary that monitors https://xkcd.com/908/info.0.json and checks the JSON response to assert that `safe_title` has the value of `'The Cloud'`.\n\n```python\ncanary = ApiCanary(stack, \"Canary\",\n    base_url=\"https://xkcd.com\",\n    duration_alarm_threshold=Duration.seconds(5),\n    thread_count=5,\n    steps=[ApiTestStep(\n        name=\"info\",\n        path=\"/908/info.0.json\",\n        jmes_path=\"safe_title\",\n        expected_value=\"The Cloud\"\n    )\n    ]\n)\n```\n\n### Application Load Balanced CodeDeployed Fargate Service\n\nAn L3 construct named `ApplicationLoadBalancedCodeDeployedFargateService` extends [ApplicationLoadBalancedFargateService](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs_patterns.ApplicationLoadBalancedFargateService.html) and adds support for deploying new versions of the service with AWS CodeDeploy. Additionally, an Amazon CloudWatch Synthetic canary is created via the `ApiCanary` construct and is monitored by the CodeDeploy deployment to trigger rollback if the canary begins to alarm.\n\n```python\n# cluster: ecs.ICluster\n# image: ecs.ContainerImage\n\nservice = ApplicationLoadBalancedCodeDeployedFargateService(stack, \"Service\",\n    cluster=cluster,\n    task_image_options=ApplicationLoadBalancedTaskImageOptions(\n        image=image\n    ),\n    api_test_steps=[ApiTestStep(\n        name=\"health\",\n        path=\"/health\",\n        jmes_path=\"status\",\n        expected_value=\"ok\"\n    )]\n)\n```\n\n## Local Development\n\n```bash\nyarn install\nyarn build\nyarn test\n```\n\nTo run an integration test and update the snapshot, run:\n\n```bash\nyarn integ:ecs-deployment:deploy\n```\n\nTo recreate snapshots for integration tests, run:\n\n```bash\nyarn integ:snapshot-all\n```\n\n## Security\n\nSee [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "CDK Constructs for performing ECS Deployments with CodeDeploy",
    "version": "0.0.278",
    "project_urls": {
        "Homepage": "https://github.com/cdklabs/cdk-ecs-codedeploy.git",
        "Source": "https://github.com/cdklabs/cdk-ecs-codedeploy.git"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc47ab226ce697551b69b1ce3a2ed991c845b1233a7636553595560c03b3bf27",
                "md5": "7adfc69ce4fb13b386aa2709932a9532",
                "sha256": "5c3ba8e40bb8ac3fcc9010a441c2e6a2946796a6117e648cb71d71246c17ccf9"
            },
            "downloads": -1,
            "filename": "cdklabs.ecs_codedeploy-0.0.278-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7adfc69ce4fb13b386aa2709932a9532",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 988972,
            "upload_time": "2024-05-11T18:14:34",
            "upload_time_iso_8601": "2024-05-11T18:14:34.975952Z",
            "url": "https://files.pythonhosted.org/packages/cc/47/ab226ce697551b69b1ce3a2ed991c845b1233a7636553595560c03b3bf27/cdklabs.ecs_codedeploy-0.0.278-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cefe1a740a6fd32d52cb68d3dcd88bff243f8b2fb6999df3cb854498805df16f",
                "md5": "7bfe30437ac32f872e8a08f3027a1166",
                "sha256": "f36630008e8fa174e9f695367853834ec2f6fe3adb324f7c67dadddd75642272"
            },
            "downloads": -1,
            "filename": "cdklabs.ecs-codedeploy-0.0.278.tar.gz",
            "has_sig": false,
            "md5_digest": "7bfe30437ac32f872e8a08f3027a1166",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 989817,
            "upload_time": "2024-05-11T18:14:38",
            "upload_time_iso_8601": "2024-05-11T18:14:38.754842Z",
            "url": "https://files.pythonhosted.org/packages/ce/fe/1a740a6fd32d52cb68d3dcd88bff243f8b2fb6999df3cb854498805df16f/cdklabs.ecs-codedeploy-0.0.278.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-11 18:14:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cdklabs",
    "github_project": "cdk-ecs-codedeploy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cdklabs.ecs-codedeploy"
}
        
Elapsed time: 0.28748s