cdk-stack-resource-rename
Project description
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
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
@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))
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cdk-stack-resource-rename-0.0.8.tar.gz
.
File metadata
- Download URL: cdk-stack-resource-rename-0.0.8.tar.gz
- Upload date:
- Size: 34.8 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b62f4945505addf9c94e12d2517f0322c7fa90d706b68cd844c8076e6b2f7183 |
|
MD5 | 8e326279f428bcd454d99051e3a849b1 |
|
BLAKE2b-256 | ce7fafa85e3506717ddc90ee76841646434f6e181161f24b6c35a0f676e00ebe |
File details
Details for the file cdk_stack_resource_rename-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: cdk_stack_resource_rename-0.0.8-py3-none-any.whl
- Upload date:
- Size: 38.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b96847e34b1b10ef1eebed2aa2becd73efd95d7ccc1fd8291179cb069da0e45c |
|
MD5 | 6d1095b4aaf3f0a40460eed14183395e |
|
BLAKE2b-256 | 365359bad0cd1096acf2bd8e606389b5d5afc4541a2f226cadaef0481c9b3211 |