-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,380 additions
and
0 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
packages/@aws-cdk/aws-ssm/test/integ.list-parameter-as-cfn-parameter.ts
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,89 @@ | ||
import * as cdk from '@aws-cdk/core'; | ||
import { IntegTest, ExpectedResult, Match } from '@aws-cdk/integ-tests'; | ||
import { Construct } from 'constructs'; | ||
import * as ssm from '../lib'; | ||
const paramName = 'integ-list-param'; | ||
const paramValue = ['value1', 'value2']; | ||
|
||
class TestCaseBase extends cdk.Stack { | ||
public readonly listParam: ssm.IStringListParameter; | ||
constructor(scope: Construct, id: string) { | ||
super(scope, id); | ||
|
||
this.listParam = new ssm.StringListParameter(this, 'ListParam', { | ||
parameterName: paramName, | ||
stringListValue: paramValue, | ||
}); | ||
} | ||
} | ||
|
||
|
||
const app = new cdk.App({ | ||
treeMetadata: false, | ||
}); | ||
/** | ||
* This test case is to verify the previous behavior of the @aws-cdk/aws-ssm:importParameterAsDynamicReference Feature Flag | ||
*/ | ||
app.node.setContext('@aws-cdk/aws-ssm:importParameterAsDynamicReference', false); | ||
app.node.setContext('@aws-cdk/core:newStyleStackSynthesis', true); | ||
const base = new TestCaseBase(app, 'base'); | ||
const testCase = new cdk.Stack(app, 'list-param'); | ||
|
||
// creates the dependency between stacks | ||
new cdk.CfnOutput(testCase, 'Output', { | ||
value: cdk.Fn.join(',', base.listParam.stringListValue), | ||
}); | ||
|
||
|
||
/** | ||
* get the value from the `base` stack and then write it to a new parameter | ||
* We will then assert that the value that is written is the correct value | ||
* This validates that the `fromXXX` and `valueForXXX` imports the value correctly | ||
*/ | ||
|
||
const fromAttrs = ssm.StringListParameter.fromListParameterAttributes(testCase, 'FromAttrs', { | ||
parameterName: paramName, | ||
elementType: ssm.ParameterValueType.STRING, | ||
}); | ||
const ssmAttrsValue = new ssm.CfnParameter(testCase, 'attrs-test', { | ||
type: 'StringList', | ||
value: cdk.Fn.join(',', fromAttrs.stringListValue), | ||
}); | ||
|
||
const value = ssm.StringListParameter.valueForTypedListParameter(testCase, paramName, ssm.ParameterValueType.STRING); | ||
const ssmValue = new ssm.CfnParameter(testCase, 'value-test', { | ||
type: 'StringList', | ||
value: cdk.Fn.join(',', value), | ||
}); | ||
|
||
const versionValue = ssm.StringListParameter.valueForTypedListParameter(testCase, paramName, ssm.ParameterValueType.STRING, 1); | ||
const ssmVersionValue = new ssm.CfnParameter(testCase, 'version-value-test', { | ||
type: 'StringList', | ||
value: cdk.Fn.join(',', versionValue), | ||
}); | ||
|
||
|
||
const integ = new IntegTest(app, 'ssm-string-param', { | ||
testCases: [ | ||
testCase, | ||
], | ||
}); | ||
|
||
// list the parameters | ||
const actualAttrs = integ.assertions.awsApiCall('SSM', 'getParameters', { | ||
Names: [ssmVersionValue.ref, ssmValue.ref, ssmAttrsValue.ref], | ||
}); | ||
|
||
actualAttrs.expect(ExpectedResult.objectLike({ | ||
Parameters: Match.arrayWith([ | ||
Match.objectLike({ | ||
Value: paramValue.join(','), | ||
}), | ||
Match.objectLike({ | ||
Value: paramValue.join(','), | ||
}), | ||
Match.objectLike({ | ||
Value: paramValue.join(','), | ||
}), | ||
]), | ||
})); |
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
Oops, something went wrong.