-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for resolving dynamic ssm values (#268)
This adds support for resolving the two types of SSM dynamic references: 1. [SSM PlainText](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references-ssm.html) 2. [SSM SecureString](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references-ssm-secure-strings.html) closes #200
- Loading branch information
Showing
14 changed files
with
3,283 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: pulumi-aws-ssm-dynamic | ||
runtime: nodejs | ||
description: ssm-dynamic integration test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as pulumi from '@pulumi/pulumi'; | ||
import * as ssm from 'aws-cdk-lib/aws-ssm'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
|
||
const config = new pulumi.Config(); | ||
const prefix = config.get('prefix') ?? pulumi.getStack(); | ||
class SsmDynamicStack extends pulumicdk.Stack { | ||
public readonly stringValue: pulumi.Output<string>; | ||
public readonly stringListValue: pulumi.Output<string[]>; | ||
constructor(app: pulumicdk.App, id: string, options?: pulumicdk.StackOptions) { | ||
super(app, id, options); | ||
|
||
const stringParam = new ssm.StringParameter(this, 'testparam', { | ||
parameterName: `${prefix}-param`, | ||
stringValue: 'testvalue', | ||
}); | ||
this.stringValue = this.asOutput(stringParam.stringValue); | ||
|
||
const listParam = new ssm.StringListParameter(this, 'testparamlist', { | ||
parameterName: `${prefix}-listparam`, | ||
stringListValue: ['abcd', 'xyz'], | ||
}); | ||
this.stringListValue = this.asOutput(listParam.stringListValue); | ||
} | ||
} | ||
|
||
const app = new pulumicdk.App('app', (scope: pulumicdk.App) => { | ||
const stack = new SsmDynamicStack(scope, `${prefix}-misc`); | ||
return { | ||
stringValue: stack.stringValue, | ||
stringListValue: stack.stringListValue, | ||
}; | ||
}); | ||
export const stringValue = app.outputs['stringValue']; | ||
export const stringListValue = app.outputs['stringListValue']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "pulumi-aws-cdk", | ||
"devDependencies": { | ||
"@types/node": "^10.0.0" | ||
}, | ||
"dependencies": { | ||
"@pulumi/aws": "6.61.0", | ||
"@pulumi/aws-native": "^1.11.0", | ||
"@pulumi/cdk": "^1.0.0", | ||
"@pulumi/pulumi": "^3.0.0", | ||
"aws-cdk-lib": "2.156.0", | ||
"constructs": "10.3.0", | ||
"esbuild": "^0.24.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as pulumi from '@pulumi/pulumi'; | ||
import * as ssm from 'aws-cdk-lib/aws-ssm'; | ||
import * as pulumicdk from '@pulumi/cdk'; | ||
import { CfnDynamicReference, CfnDynamicReferenceService } from 'aws-cdk-lib'; | ||
|
||
const config = new pulumi.Config(); | ||
const prefix = config.get('prefix') ?? pulumi.getStack(); | ||
class SsmDynamicStack extends pulumicdk.Stack { | ||
public readonly stringValue: pulumi.Output<string>; | ||
public readonly stringListValue: pulumi.Output<string[]>; | ||
public readonly dynamicStringValue: pulumi.Output<string>; | ||
public readonly dynamicStringListValue: pulumi.Output<string[]>; | ||
constructor(app: pulumicdk.App, id: string, options?: pulumicdk.StackOptions) { | ||
super(app, id, options); | ||
|
||
const stringParam = new ssm.StringParameter(this, 'testparam', { | ||
parameterName: `${prefix}-param`, | ||
stringValue: 'testvalue', | ||
}); | ||
this.stringValue = this.asOutput(stringParam.stringValue); | ||
|
||
const listParam = new ssm.StringListParameter(this, 'testparamlist', { | ||
parameterName: `${prefix}-listparam`, | ||
stringListValue: ['abcd', 'xyz'], | ||
}); | ||
this.stringListValue = this.asOutput(listParam.stringListValue); | ||
|
||
const stringValue = new CfnDynamicReference(CfnDynamicReferenceService.SSM, `${prefix}-param`).toString(); | ||
const stringDynamicParam = new ssm.StringParameter(this, 'stringDynamicParam', { | ||
stringValue: stringValue, | ||
}); | ||
this.dynamicStringValue = this.asOutput(stringDynamicParam.stringValue); | ||
|
||
const stringListValue = new CfnDynamicReference( | ||
CfnDynamicReferenceService.SSM, | ||
`${prefix}-listparam`, | ||
).toString(); | ||
const stringListDynamicParam = new ssm.StringParameter(this, 'stringListDynamicParam', { | ||
stringValue: stringListValue, | ||
}); | ||
this.dynamicStringListValue = this.asOutput(stringListDynamicParam.stringValue).apply((v) => v.split(',')); | ||
} | ||
} | ||
|
||
const app = new pulumicdk.App('app', (scope: pulumicdk.App) => { | ||
const stack = new SsmDynamicStack(scope, `${prefix}-misc`); | ||
return { | ||
stringValue: stack.stringValue, | ||
stringListValue: stack.stringListValue, | ||
dynamicStringValue: stack.dynamicStringValue, | ||
dynamicStringListValue: stack.dynamicStringListValue, | ||
}; | ||
}); | ||
export const stringValue = app.outputs['stringValue']; | ||
export const stringListValue = app.outputs['stringListValue']; | ||
export const dynamicStringValue = app.outputs['dynamicStringValue']; | ||
export const dynamicStringListValue = app.outputs['dynamicStringListValue']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"outDir": "bin", | ||
"target": "es2019", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"pretty": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"include": [ | ||
"./*.ts" | ||
] | ||
} |
Oops, something went wrong.