Skip to main content

Deployer CDK Construct

This is a CDK construct library for deploying artifacts via CodeDeploy.

This library currently supports NodeJS and Python.

Installation

Install with npm

$ npm install cdk-deployer

Install with pip

$ pip install cdk-deployer

Usage/Examples

TypeScript:

With codeDeploy.ServerDeploymentGroup:

import * as cdk from '@aws-cdk/core';
import * as autoscaling from '@aws-cdk/aws-autoscaling';
import * as codedeploy from '@aws-cdk/aws-codedeploy';
import { Ec2Deployer, Code } from 'cdk-deployer';

const asg = new autoscaling.AutoScalingGroup(this, 'Asg', {
    ...
});
const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGroup', {
    autoScalingGroups: [asg]
});

const deployer = new Ec2Deployer(this, 'Deployer', {
    code: Code.fromAsset('path/to/code/directory'),
    deploymentGroup,
});

With codeDeploy.IServerDeploymentGroup, also need to specify instanceRoles:

import * as cdk from '@aws-cdk/core';
import * as codedeploy from '@aws-cdk/aws-codedeploy';
import * as iam from '@aws-cdk/aws-iam';
import { Ec2Deployer, Code } from 'cdk-deployer';

const deploymentGroup = codedeploy.ServerDeploymentGroup.fromServerDeploymentGroupAttributes(this, 'DeploymentGroup', {
    ...
});

const instanceRole = iam.Role.fromRoleArn(this, 'Role', cdk.Arn.format({
    service: 'iam',
    resource: 'role',
    resourceName: 'instance-role-name' // role assigned to target instances associated with deployment group
}, cdk.Stack.of(this)));

const deployer = new Ec2Deployer(this, 'Deployer', {
    code: Code.fromAsset('path/to/code/directory'),
    deploymentGroup,
    instanceRoles: [instanceRole]
});

Python:

With codeDeploy.ServerDeploymentGroup:

from aws_cdk import (
    core as cdk,
    aws_codedeploy as codedeploy,
    aws_autoscaling as autoscaling,
)
from cdk_deployer import (
    Ec2Deployer,
    Code
)

asg = autoscaling.AutoScalingGroup(self, 'Asg',
    ...)
deployment_group = codedeploy.ServerDeploymentGroup(self, 'DeploymentGroup',
    auto_scaling_groups=[asg])

deployment = Ec2Deployer(self, 'Deployment',
    code=Code.from_asset('path/to/code/directory'),
    deployment_group=deployment_group)

With codeDeploy.IServerDeploymentGroup, also need to specify instance_roles:

from aws_cdk import (
    core as cdk,
    aws_autoscaling as autoscaling,
    aws_codedeploy as codedeploy,
    aws_iam as iam,
)
from cdk_deployer import (
    Ec2Deployer,
    Code
)

deployment_group = codedeploy.ServerDeploymentGroup.from_server_deployment_group_attributes(self, 'DeploymentGroup',
    ...)

instance_role = iam.Role.from_role_arn(self, 'Role', cdk.Arn.format(
    components=cdk.ArnComponents(
        service='iam',
        resource='role',
        resource_name='instance-role-name'),
    stack=cdk.Stack.of(self)
))

deployment = Ec2Deployer(self, 'Deployment',
    code=Code.from_asset('app'),
    deployment_group=deployment_group,
    instance_roles=[instance_role])

See example folder for a more complete example.

Contributing

Contributions of all kinds are welcome and celebrated. Raise an issue, submit a PR, do the right thing.

See CONTRIBUTING.md for contributing guidelines.

License

Apache 2.0

Metadata

Release files for cdk-deployer 1.0.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdk-deployer 1.0.13
File Size Uploaded Provenance Actions
cdk-deployer-1.0.13.tar.gz 42.9 kB Without provenance Details for cdk-deployer-1.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cdk-deployer 1.0.13
File Interpreter ABI Platform Actions
cdk_deployer-1.0.13-py3-none-any.whl Python 3 none any Details for cdk_deployer-1.0.13-py3-none-any.whl

Total release size: 84.1 kB

Release files / cdk-deployer-1.0.13.tar.gz

Download URL cdk-deployer-1.0.13.tar.gz
Size 42.9 kB
Tags Source
SHA-256 checksum
How to use checksums
816c4cc3a119ba5c9c542342da28690f32867d1abf2f78be41e1d8913299bdff
BLAKE2b-256 checksum
How to use checksums
21ad5a5f8248dd2e08f4d6123861d7c71849adaf37e682290ebb9226de76efc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / cdk_deployer-1.0.13-py3-none-any.whl

Download URL cdk_deployer-1.0.13-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d1c1984b23bde6f661304fbe2696831f3f841debb4d4e856d1b6842a8a92219
BLAKE2b-256 checksum
How to use checksums
08a8b6f535739ff4636107ad6f5d166b6f19d06f4bab199c231acf62d52ca284
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for cdk-deployer 1.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page