xregion-ssm-parameter-reader
Project description
Cross-region cross-account SSM parameter reader construct for AWS CDK
Easy-to-use CDK construct for reading SSM parameters in a cross-account cross-region fashion, overcoming the limits of the native SSM parameter.
Introduction
This construct has been created to be able to share pieces of information across regions (and accounts) in deployment pipelines but it can be used also outside of the CI/CD context.
Cross-region example
This strategy is particularly useful in case of a deployment pipeline where you want to share the same parameter across regions within the same account.
As part of a stack deployed in region-1, create the parameter as usual:
new StringParameter(this, 'param', {
parameterName: '/param/name'
stringValue: 'param value',
});
When in region-2, use the following to read the parameter value:
const paramValue = new SSMParameterReader(this, 'SSMParameterReader', {
parameterName: '/param/name',
region: 'region-1',
}).retrieveParameterValue();
Cross-account example
This strategy is useful still in a deployment pipeline but to share a parameter across regions and accounts. For example, let's assume we want to share the same transit gateway across accounts and regions. The pipeline can be deployed in a CICD account, separated from the usual target accounts (i.e. dev, test and prod).
In this case you would share the resource using Resource Access Manager (out of scope for this example) and you will create two parameters in region-1 and in the CICD account, to share the transit gateway ID and the shared resource ARN:
const principals = [ new AccountPrincipal(devAccount), new AccountPrincipal(testAccount), new AccountPrincipal(prodAccount)];
const transitGWParam = new StringParameter(this, 'transitGWParam', {
parameterName: 'transitGW',
stringValue: transitGW.attrId,
});
const transitShareParam = new StringParameter(this, 'transitShareParam', {
parameterName: 'transitShare',
stringValue: resourceShare.attrArn,
});
new Role(this,'transitRole',{
assumedBy: new CompositePrincipal(...principals),
roleName: 'transit-role-region-1'
}).addToPrincipalPolicy(new PolicyStatement({
actions: [ 'ssm:GetParameter*' ],
resources: [ transitGWParam.parameterArn, transitShareParam.parameterArn ]
}));
When in region-2 and in one of the target accounts, to read the parameters value:
const cicdAccount = 12345678;
const cicdRegion = region-1;
const transitGW = new SSMParameterReader(this, 'transitGWReader', {
parameterName: 'transitGW',
region: cicdRegion,
roleArn: `arn:aws:iam::${cicdAccount}:role/transit-role-${cicdRegion}`
}).retrieveParameterValue();
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xregion_ssm_parameter_reader-0.0.7.tar.gz.
File metadata
- Download URL: xregion_ssm_parameter_reader-0.0.7.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a73b3547e473a7f4214836ce7d428240251537d07dc839ea63bb5261a38635a7
|
|
| MD5 |
9f451995ad6c947b1c1c9c71cac97968
|
|
| BLAKE2b-256 |
28e6f1ab6c1f73b0e96952f5d4c4526ae05ac740d7a9244d5e72479613ee7c17
|
File details
Details for the file xregion_ssm_parameter_reader-0.0.7-py3-none-any.whl.
File metadata
- Download URL: xregion_ssm_parameter_reader-0.0.7-py3-none-any.whl
- Upload date:
- Size: 30.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21a4f2fba4a2f9fcddab4d3bb21fce21b421ecc7e8b080bac4eb3f6ce88cb86e
|
|
| MD5 |
a07d640bc1680f2f4cb1725774237d22
|
|
| BLAKE2b-256 |
32576e1916d9efafe2c1b4b6e3ab8e25487a6ddccc3fdeb1746de612b2c7b5cb
|