Skip to main content

cdk-stack-resource-rename

Project description

NPM version PyPI version Nuget 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.

API: API.md

Samples

typescript

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from cdk_stack_resource_rename import StackResourceRenamer

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

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

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

python

from cdk_stack_resource_rename import (StackResourceRenamer, IRenameOperation)

@jsii.implements(IRenameOperation)
class RenameOper:
    def __init__(self, alias):
        self.alias=alias
    def rename(self, origName, typeName):
        return origName+'-'+self.alias

class AppStack(core.Stack):
    def __init__(self, scope: core.Construct, construct_id: str, **kwargs) -> None:
        ......
        alias = self.node.try_get_context("alias")
        if alias != None:
            # if alias is defined, rename stack/resources' custom names
            StackResourceRenamer.rename(self, RenameOper(alias))

java

import cdkutils.aspects.resourcerename.StackResourceRenamer;
import cdkutils.aspects.resourcerename.IRenameOperation;

public class AppStack extends Stack {
    ......
    String alias = (String) this.getNode().tryGetContext("alias");
    if (alias != null) {
        StackResourceRenamer.rename(this, new IRenameOperation() {
            public String rename(String origName, String typeName) {
                return origName + "-"+alias;
            }
        });
    }

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.10.tar.gz (563.5 kB view details)

Uploaded Source

Built Distribution

cdk_stack_resource_rename-0.0.10-py3-none-any.whl (566.7 kB view details)

Uploaded Python 3

File details

Details for the file cdk-stack-resource-rename-0.0.10.tar.gz.

File metadata

  • Download URL: cdk-stack-resource-rename-0.0.10.tar.gz
  • Upload date:
  • Size: 563.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.9

File hashes

Hashes for cdk-stack-resource-rename-0.0.10.tar.gz
Algorithm Hash digest
SHA256 96fee1de5ab6b35c6154733be349f9fab81ae85374a4d36e71e896ade211c9a9
MD5 39dcfe51d97713dfcdbb33ce64bd45cc
BLAKE2b-256 23637b000a92aca933e4f2cbbbc07e9651586008a7d785796e4b4f2d5bf64ec7

See more details on using hashes here.

File details

Details for the file cdk_stack_resource_rename-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: cdk_stack_resource_rename-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 566.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.9

File hashes

Hashes for cdk_stack_resource_rename-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 9848e422da1b035aa495f300e83e94b4ff5cc0f0a814ec3a26121953ee0f6901
MD5 17f21504a21b12579bcbab628301eec0
BLAKE2b-256 cff6984a3f04aa6a0c9c456a3ad3b378bf8c4cc761941c128bd28973fc04bd47

See more details on using hashes here.

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