Skip to main content

cdk-stack-resource-rename

Project description

NPM version PyPI version Release

StackResourceRenamer

A CDK aspect, StackResourceRenamer renames CDK stack name and stack's subordinate resources' custom physical names, so that a CDK stack can be used to create multiple stacks in same AWS environment without confliction.

Sample

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
app = core.App()

stack = core.Stack(app, "my-stack")

alias = stack.node.try_get_context("alias")
if alias !== undefined:
    # if alias is defined, rename stack and resources' custom names
    # with the "rename" function/method.
    StackResourceRenamer.rename(stack,
        rename=(origName, _)=>{
                        return origName+'-'+alias;
                    }
    )

# resources in stack
bucket = s3.Bucket(stack, "bucket",
    bucket_name="my-bucket"
)

To create multiple stacks:

cdk -c alias=a1 deploy will create a stack: my-stack-a1 with my-bucket-a1.

To create more stacks: my-stack-a2 with my-bucket-a2, my-stack-a3 with my-bucket-a3:

cdk -c alias=a2 deploy

cdk -c alias=a3 deploy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdk-stack-resource-rename-0.0.7.tar.gz (53.9 kB view hashes)

Uploaded Source

Built Distribution

cdk_stack_resource_rename-0.0.7-py3-none-any.whl (57.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page