# Continuous Integration / Continuous Delivery for CDK Applications
<!--BEGIN STABILITY BANNER-->---
![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)
> This API may emit warnings. Backward compatibility is not guaranteed.
---
<!--END STABILITY BANNER-->
This library includes a *CodePipeline* composite Action for deploying AWS CDK Applications.
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
## Replacement recommended
This library has been deprecated. We recommend you use the
[@aws-cdk/pipelines](https://docs.aws.amazon.com/cdk/api/latest/docs/pipelines-readme.html) module instead.
## Limitations
The construct library in it's current form has the following limitations:
1. It can only deploy stacks that are hosted in the same AWS account and region as the *CodePipeline* is.
2. Stacks that make use of `Asset`s cannot be deployed successfully.
## Getting Started
In order to add the `PipelineDeployStackAction` to your *CodePipeline*, you need to have a *CodePipeline* artifact that
contains the result of invoking `cdk synth -o <dir>` on your *CDK App*. You can for example achieve this using a
*CodeBuild* project.
The example below defines a *CDK App* that contains 3 stacks:
* `CodePipelineStack` manages the *CodePipeline* resources, and self-updates before deploying any other stack
* `ServiceStackA` and `ServiceStackB` are service infrastructure stacks, and need to be deployed in this order
```plaintext
┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Source ┃ ┃ Build ┃ ┃ Self-Update ┃ ┃ Deploy ┃
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃
┃ ┌────────────┐ ┃ ┃ ┌────────────┐ ┃ ┃ ┌─────────────┐ ┃ ┃ ┌─────────────┐ ┌─────────────┐ ┃
┃ │ GitHub ┣━╋━━╋━▶ CodeBuild ┣━╋━━╋━▶Deploy Stack ┣━╋━━╋━▶Deploy Stack ┣━▶Deploy Stack │ ┃
┃ │ │ ┃ ┃ │ │ ┃ ┃ │PipelineStack│ ┃ ┃ │ServiceStackA│ │ServiceStackB│ ┃
┃ └────────────┘ ┃ ┃ └────────────┘ ┃ ┃ └─────────────┘ ┃ ┃ └─────────────┘ └─────────────┘ ┃
┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
```
### `index.ts`
```python
import aws_cdk.aws_codebuild as codebuild
import aws_cdk.aws_codepipeline as codepipeline
import aws_cdk.aws_codepipeline_actions as codepipeline_actions
import aws_cdk.core as cdk
import aws_cdk.app_delivery as cicd
import aws_cdk.aws_iam as iam
class MyServiceStackA(cdk.Stack):
pass
class MyServiceStackB(cdk.Stack):
pass
app = cdk.App()
# We define a stack that contains the CodePipeline
pipeline_stack = cdk.Stack(app, "PipelineStack")
pipeline = codepipeline.Pipeline(pipeline_stack, "CodePipeline",
# Mutating a CodePipeline can cause the currently propagating state to be
# "lost". Ensure we re-run the latest change through the pipeline after it's
# been mutated so we're sure the latest state is fully deployed through.
restart_execution_on_update=True
)
# Configure the CodePipeline source - where your CDK App's source code is hosted
source_output = codepipeline.Artifact()
source = codepipeline_actions.GitHubSourceAction(
action_name="GitHub",
output=source_output,
owner="myName",
repo="myRepo",
oauth_token=cdk.SecretValue.unsafe_plain_text("secret")
)
pipeline.add_stage(
stage_name="source",
actions=[source]
)
project = codebuild.PipelineProject(pipeline_stack, "CodeBuild")
synthesized_app = codepipeline.Artifact()
build_action = codepipeline_actions.CodeBuildAction(
action_name="CodeBuild",
project=project,
input=source_output,
outputs=[synthesized_app]
)
pipeline.add_stage(
stage_name="build",
actions=[build_action]
)
# Optionally, self-update the pipeline stack
self_update_stage = pipeline.add_stage(stage_name="SelfUpdate")
self_update_stage.add_action(cicd.PipelineDeployStackAction(
stack=pipeline_stack,
input=synthesized_app,
admin_permissions=True
))
# Now add our service stacks
deploy_stage = pipeline.add_stage(stage_name="Deploy")
service_stack_a = MyServiceStackA(app, "ServiceStackA")
# Add actions to deploy the stacks in the deploy stage:
deploy_service_aAction = cicd.PipelineDeployStackAction(
stack=service_stack_a,
input=synthesized_app,
# See the note below for details about this option.
admin_permissions=False
)
deploy_stage.add_action(deploy_service_aAction)
# Add the necessary permissions for you service deploy action. This role is
# is passed to CloudFormation and needs the permissions necessary to deploy
# stack. Alternatively you can enable [Administrator](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html#jf_administrator) permissions above,
# users should understand the privileged nature of this role.
my_resource_arn = "arn:partition:service:region:account-id:resource-id"
deploy_service_aAction.add_to_deployment_role_policy(iam.PolicyStatement(
actions=["service:SomeAction"],
resources=[my_resource_arn]
))
service_stack_b = MyServiceStackB(app, "ServiceStackB")
deploy_stage.add_action(cicd.PipelineDeployStackAction(
stack=service_stack_b,
input=synthesized_app,
create_change_set_run_order=998,
admin_permissions=True
))
```
### `buildspec.yml`
The repository can contain a file at the root level named `buildspec.yml`, or
you can in-line the buildspec. Note that `buildspec.yaml` is not compatible.
For example, a *TypeScript* or *Javascript* CDK App can add the following `buildspec.yml`
at the root of the repository:
```yml
version: 0.2
phases:
install:
commands:
# Installs the npm dependencies as defined by the `package.json` file
# present in the root directory of the package
# (`cdk init app --language=typescript` would have created one for you)
- npm install
build:
commands:
# Builds the CDK App so it can be synthesized
- npm run build
# Synthesizes the CDK App and puts the resulting artifacts into `dist`
- npm run cdk synth -- -o dist
artifacts:
# The output artifact is all the files in the `dist` directory
base-directory: dist
files: '**/*'
```
The `PipelineDeployStackAction` expects it's `input` to contain the result of
synthesizing a CDK App using the `cdk synth -o <directory>`.
Raw data
{
"_id": null,
"home_page": "https://github.com/aws/aws-cdk",
"name": "aws-cdk.app-delivery",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Amazon Web Services",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/cc/05/27f0ddf04db92f8773f7ab18bfc038ca202e724cad2882020fb860e4736a/aws-cdk.app-delivery-1.203.0.tar.gz",
"platform": null,
"description": "# Continuous Integration / Continuous Delivery for CDK Applications\n\n<!--BEGIN STABILITY BANNER-->---\n\n\n![Deprecated](https://img.shields.io/badge/deprecated-critical.svg?style=for-the-badge)\n\n> This API may emit warnings. Backward compatibility is not guaranteed.\n\n---\n<!--END STABILITY BANNER-->\n\nThis library includes a *CodePipeline* composite Action for deploying AWS CDK Applications.\n\nThis module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.\n\n## Replacement recommended\n\nThis library has been deprecated. We recommend you use the\n[@aws-cdk/pipelines](https://docs.aws.amazon.com/cdk/api/latest/docs/pipelines-readme.html) module instead.\n\n## Limitations\n\nThe construct library in it's current form has the following limitations:\n\n1. It can only deploy stacks that are hosted in the same AWS account and region as the *CodePipeline* is.\n2. Stacks that make use of `Asset`s cannot be deployed successfully.\n\n## Getting Started\n\nIn order to add the `PipelineDeployStackAction` to your *CodePipeline*, you need to have a *CodePipeline* artifact that\ncontains the result of invoking `cdk synth -o <dir>` on your *CDK App*. You can for example achieve this using a\n*CodeBuild* project.\n\nThe example below defines a *CDK App* that contains 3 stacks:\n\n* `CodePipelineStack` manages the *CodePipeline* resources, and self-updates before deploying any other stack\n* `ServiceStackA` and `ServiceStackB` are service infrastructure stacks, and need to be deployed in this order\n\n```plaintext\n \u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513 \u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513 \u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513 \u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n \u2503 Source \u2503 \u2503 Build \u2503 \u2503 Self-Update \u2503 \u2503 Deploy \u2503\n \u2503 \u2503 \u2503 \u2503 \u2503 \u2503 \u2503 \u2503\n \u2503 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2503 \u2503 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2503 \u2503 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2503 \u2503 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u2503\n \u2503 \u2502 GitHub \u2523\u2501\u254b\u2501\u2501\u254b\u2501\u25b6 CodeBuild \u2523\u2501\u254b\u2501\u2501\u254b\u2501\u25b6Deploy Stack \u2523\u2501\u254b\u2501\u2501\u254b\u2501\u25b6Deploy Stack \u2523\u2501\u25b6Deploy Stack \u2502 \u2503\n \u2503 \u2502 \u2502 \u2503 \u2503 \u2502 \u2502 \u2503 \u2503 \u2502PipelineStack\u2502 \u2503 \u2503 \u2502ServiceStackA\u2502 \u2502ServiceStackB\u2502 \u2503\n \u2503 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2503 \u2503 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2503 \u2503 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2503 \u2503 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2503\n \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251b \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251b \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251b \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251b\n```\n\n### `index.ts`\n\n```python\nimport aws_cdk.aws_codebuild as codebuild\nimport aws_cdk.aws_codepipeline as codepipeline\nimport aws_cdk.aws_codepipeline_actions as codepipeline_actions\nimport aws_cdk.core as cdk\nimport aws_cdk.app_delivery as cicd\nimport aws_cdk.aws_iam as iam\n\nclass MyServiceStackA(cdk.Stack):\n pass\nclass MyServiceStackB(cdk.Stack):\n pass\n\napp = cdk.App()\n\n# We define a stack that contains the CodePipeline\npipeline_stack = cdk.Stack(app, \"PipelineStack\")\npipeline = codepipeline.Pipeline(pipeline_stack, \"CodePipeline\",\n # Mutating a CodePipeline can cause the currently propagating state to be\n # \"lost\". Ensure we re-run the latest change through the pipeline after it's\n # been mutated so we're sure the latest state is fully deployed through.\n restart_execution_on_update=True\n)\n\n# Configure the CodePipeline source - where your CDK App's source code is hosted\nsource_output = codepipeline.Artifact()\nsource = codepipeline_actions.GitHubSourceAction(\n action_name=\"GitHub\",\n output=source_output,\n owner=\"myName\",\n repo=\"myRepo\",\n oauth_token=cdk.SecretValue.unsafe_plain_text(\"secret\")\n)\npipeline.add_stage(\n stage_name=\"source\",\n actions=[source]\n)\n\nproject = codebuild.PipelineProject(pipeline_stack, \"CodeBuild\")\nsynthesized_app = codepipeline.Artifact()\nbuild_action = codepipeline_actions.CodeBuildAction(\n action_name=\"CodeBuild\",\n project=project,\n input=source_output,\n outputs=[synthesized_app]\n)\npipeline.add_stage(\n stage_name=\"build\",\n actions=[build_action]\n)\n\n# Optionally, self-update the pipeline stack\nself_update_stage = pipeline.add_stage(stage_name=\"SelfUpdate\")\nself_update_stage.add_action(cicd.PipelineDeployStackAction(\n stack=pipeline_stack,\n input=synthesized_app,\n admin_permissions=True\n))\n\n# Now add our service stacks\ndeploy_stage = pipeline.add_stage(stage_name=\"Deploy\")\nservice_stack_a = MyServiceStackA(app, \"ServiceStackA\")\n# Add actions to deploy the stacks in the deploy stage:\ndeploy_service_aAction = cicd.PipelineDeployStackAction(\n stack=service_stack_a,\n input=synthesized_app,\n # See the note below for details about this option.\n admin_permissions=False\n)\ndeploy_stage.add_action(deploy_service_aAction)\n# Add the necessary permissions for you service deploy action. This role is\n# is passed to CloudFormation and needs the permissions necessary to deploy\n# stack. Alternatively you can enable [Administrator](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html#jf_administrator) permissions above,\n# users should understand the privileged nature of this role.\nmy_resource_arn = \"arn:partition:service:region:account-id:resource-id\"\ndeploy_service_aAction.add_to_deployment_role_policy(iam.PolicyStatement(\n actions=[\"service:SomeAction\"],\n resources=[my_resource_arn]\n))\n\nservice_stack_b = MyServiceStackB(app, \"ServiceStackB\")\ndeploy_stage.add_action(cicd.PipelineDeployStackAction(\n stack=service_stack_b,\n input=synthesized_app,\n create_change_set_run_order=998,\n admin_permissions=True\n))\n```\n\n### `buildspec.yml`\n\nThe repository can contain a file at the root level named `buildspec.yml`, or\nyou can in-line the buildspec. Note that `buildspec.yaml` is not compatible.\n\nFor example, a *TypeScript* or *Javascript* CDK App can add the following `buildspec.yml`\nat the root of the repository:\n\n```yml\nversion: 0.2\nphases:\n install:\n commands:\n # Installs the npm dependencies as defined by the `package.json` file\n # present in the root directory of the package\n # (`cdk init app --language=typescript` would have created one for you)\n - npm install\n build:\n commands:\n # Builds the CDK App so it can be synthesized\n - npm run build\n # Synthesizes the CDK App and puts the resulting artifacts into `dist`\n - npm run cdk synth -- -o dist\nartifacts:\n # The output artifact is all the files in the `dist` directory\n base-directory: dist\n files: '**/*'\n```\n\nThe `PipelineDeployStackAction` expects it's `input` to contain the result of\nsynthesizing a CDK App using the `cdk synth -o <directory>`.\n\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Continuous Integration / Continuous Delivery for CDK Applications",
"version": "1.203.0",
"project_urls": {
"Homepage": "https://github.com/aws/aws-cdk",
"Source": "https://github.com/aws/aws-cdk.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "14a868836f76bcc350ea136dfa912a2bbad0e8ab08a6da3f031d5ea70881a2a6",
"md5": "03beef095e3eb5795e17d72b9aa3bf87",
"sha256": "ed5ac53f744dfd4f8e733831c80f04e0dcfbf797011916120ad40b87800e7395"
},
"downloads": -1,
"filename": "aws_cdk.app_delivery-1.203.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "03beef095e3eb5795e17d72b9aa3bf87",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.7",
"size": 46181,
"upload_time": "2023-05-31T22:52:09",
"upload_time_iso_8601": "2023-05-31T22:52:09.779469Z",
"url": "https://files.pythonhosted.org/packages/14/a8/68836f76bcc350ea136dfa912a2bbad0e8ab08a6da3f031d5ea70881a2a6/aws_cdk.app_delivery-1.203.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cc0527f0ddf04db92f8773f7ab18bfc038ca202e724cad2882020fb860e4736a",
"md5": "3b4da7940d526b1ad86d9d1c43d4cc2a",
"sha256": "1e73cd5169235aad42c4a31fa32715d8318f119323c8699f550678056441a088"
},
"downloads": -1,
"filename": "aws-cdk.app-delivery-1.203.0.tar.gz",
"has_sig": false,
"md5_digest": "3b4da7940d526b1ad86d9d1c43d4cc2a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.7",
"size": 47432,
"upload_time": "2023-05-31T23:00:16",
"upload_time_iso_8601": "2023-05-31T23:00:16.529486Z",
"url": "https://files.pythonhosted.org/packages/cc/05/27f0ddf04db92f8773f7ab18bfc038ca202e724cad2882020fb860e4736a/aws-cdk.app-delivery-1.203.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-31 23:00:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aws",
"github_project": "aws-cdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aws-cdk.app-delivery"
}