Skip to content

Commit

Permalink
Merge branch 'master' into benisrae/nested-fix-multi-level-refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel authored Apr 16, 2020
2 parents 5f043cc + 4ab3ffa commit 8f55171
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 13 deletions.
6 changes: 1 addition & 5 deletions packages/@aws-cdk/aws-kinesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

![cfn-resources: Stable](https://img.shields.io/badge/cfn--resources-stable-success.svg?style=for-the-badge)

> All classes with the `Cfn` prefix in this module ([CFN Resources](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) are always stable and safe to use.
![cdk-constructs: Developer Preview](https://img.shields.io/badge/cdk--constructs-developer--preview-informational.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are in **developer preview** before they become stable. We will only make breaking changes to address unforeseen API issues. Therefore, these APIs are not subject to [Semantic Versioning](https://semver.org/), and breaking changes will be announced in release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)

---
<!--END STABILITY BANNER-->
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-kinesis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
"engines": {
"node": ">= 10.12.0"
},
"stability": "experimental",
"maturity": "developer-preview",
"stability": "stable",
"maturity": "stable",
"awscdkio": {
"announce": false
}
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ async function initCommandLine() {
const parameterMap: { [name: string]: string | undefined } = {};
for (const parameter of args.parameters) {
if (typeof parameter === 'string') {
const keyValue = (parameter as string).split('=', 2);
parameterMap[keyValue[0]] = keyValue[1];
const keyValue = (parameter as string).split('=');
parameterMap[keyValue[0]] = keyValue.slice(1).join('=');
}
}
return await cli.deploy({
Expand Down
Empty file modified packages/aws-cdk/scripts/integ-cli.sh
100644 → 100755
Empty file.
6 changes: 4 additions & 2 deletions packages/aws-cdk/test/api/deploy-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ test('correctly passes CFN parameters, ignoring ones with empty values', async (
resolvedEnvironment: mockResolvedEnvironment(),
parameters: {
A: 'A-value',
B: undefined,
C: '',
B: 'B=value',
C: undefined,
D: '',
},
});

// THEN
expect(cfnMocks.createChangeSet).toHaveBeenCalledWith(expect.objectContaining({
Parameters: [
{ ParameterKey: 'A', ParameterValue: 'A-value' },
{ ParameterKey: 'B', ParameterValue: 'B=value' },
]
}));
});
Expand Down
15 changes: 15 additions & 0 deletions packages/aws-cdk/test/integ/cli/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ class OtherParameterStack extends cdk.Stack {
}
}

class MultiParameterStack extends cdk.Stack {
constructor(parent, id, props) {
super(parent, id, props);

new sns.Topic(this, 'TopicParameter', {
displayName: new cdk.CfnParameter(this, 'DisplayNameParam')
});
new sns.Topic(this, 'OtherTopicParameter', {
displayName: new cdk.CfnParameter(this, 'OtherDisplayNameParam')
});
}
}

class OutputsStack extends cdk.Stack {
constructor(parent, id, props) {
super(parent, id, props);
Expand Down Expand Up @@ -236,6 +249,8 @@ new YourStack(app, `${stackPrefix}-test-2`);
// Deploy wildcard with parameters does ${stackPrefix}-param-test-*
new ParameterStack(app, `${stackPrefix}-param-test-1`);
new OtherParameterStack(app, `${stackPrefix}-param-test-2`);
// Deploy stack with multiple parameters
new MultiParameterStack(app, `${stackPrefix}-param-test-3`);
// Deploy stack with outputs does ${stackPrefix}-outputs-test-*
new OutputsStack(app, `${stackPrefix}-outputs-test-1`);
new AnotherOutputsStack(app, `${stackPrefix}-outputs-test-2`);
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-cdk/test/integ/cli/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ function prepare_fixture() {
function cleanup() {
cleanup_stack ${STACK_NAME_PREFIX}-test-1
cleanup_stack ${STACK_NAME_PREFIX}-test-2
cleanup_stack ${STACK_NAME_PREFIX}-param-test-1
cleanup_stack ${STACK_NAME_PREFIX}-param-test-2
cleanup_stack ${STACK_NAME_PREFIX}-param-test-3
cleanup_stack ${STACK_NAME_PREFIX}-iam-test
cleanup_stack ${STACK_NAME_PREFIX}-with-nested-stack
cleanup_stack ${STACK_NAME_PREFIX}-outputs-test-1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ setup

# STACK_NAME_PREFIX is used in OtherTopicNameParam to allow multiple instances
# of this test to run in parallel, othewise they will attempt to create the same SNS topic.
stack_arns=$(cdk deploy ${STACK_NAME_PREFIX}-param-test-\* --parameters "${STACK_NAME_PREFIX}-param-test-1:TopicNameParam=${STACK_NAME_PREFIX}bazinga" --parameters "${STACK_NAME_PREFIX}-param-test-2:OtherTopicNameParam=${STACK_NAME_PREFIX}ThatsMySpot")
stack_arns=$(cdk deploy ${STACK_NAME_PREFIX}-param-test-\* --parameters "${STACK_NAME_PREFIX}-param-test-1:TopicNameParam=${STACK_NAME_PREFIX}bazinga" --parameters "${STACK_NAME_PREFIX}-param-test-2:OtherTopicNameParam=${STACK_NAME_PREFIX}ThatsMySpot" --parameters "${STACK_NAME_PREFIX}-param-test-3:DisplayNameParam=${STACK_NAME_PREFIX}HeyThere" --parameters "${STACK_NAME_PREFIX}-param-test-3:OtherDisplayNameParam=${STACK_NAME_PREFIX}AnotherOne")
echo "Stack deployed successfully"

# verify that we only deployed a single stack (there's a single ARN in the output)
lines="$(echo "${stack_arns}" | wc -l)"
if [ "${lines}" -ne 2 ]; then
if [ "${lines}" -ne 3 ]; then
echo "-- output -----------"
echo "${stack_arns}"
echo "---------------------"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -euo pipefail
scriptdir=$(cd $(dirname $0) && pwd)
source ${scriptdir}/common.bash
# ----------------------------------------------------------

setup

paramVal1="${STACK_NAME_PREFIX}bazinga"
paramVal2="${STACK_NAME_PREFIX}=jagshemash"

stack_arn=$(cdk deploy -v ${STACK_NAME_PREFIX}-param-test-3 --parameters "DisplayNameParam=${paramVal1}" --parameters "OtherDisplayNameParam=${paramVal2}")
echo "Stack deployed successfully"

# verify that we only deployed a single stack (there's a single ARN in the output)
assert_lines "${stack_arn}" 1

# retrieve stack parameters
response_json=$(mktemp).json
aws cloudformation describe-stacks --stack-name ${stack_arn} > ${response_json}
parameter_count=$(node -e "console.log(require('${response_json}').Stacks[0].Parameters.length)")

# verify stack parameter count
if [ "${parameter_count}" -ne 2 ]; then
fail "stack has ${parameter_count} parameters, and we expected two"
fi

# verify stack parameters
for (( i=0; i<$parameter_count; i++ )); do
passedParameterVal=$(node -e "console.log(require('${response_json}').Stacks[0].Parameters[$i].ParameterValue)")
if ! [[ "${passedParameterVal}" =~ ^($paramVal1|$paramVal2)$ ]]; then
fail "Unexpected parameter: '${passedParameterVal}'. Expected parameter values: '${paramVal1}' or '${paramVal2}'"
fi
done;

# destroy
cdk destroy -f ${STACK_NAME_PREFIX}-param-test-3


echo "✅ success"
1 change: 1 addition & 0 deletions packages/aws-cdk/test/integ/cli/test-cdk-ls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ${STACK_NAME_PREFIX}-outputs-test-1
${STACK_NAME_PREFIX}-outputs-test-2
${STACK_NAME_PREFIX}-param-test-1
${STACK_NAME_PREFIX}-param-test-2
${STACK_NAME_PREFIX}-param-test-3
${STACK_NAME_PREFIX}-test-1
${STACK_NAME_PREFIX}-test-2
${STACK_NAME_PREFIX}-with-nested-stack
Expand Down

0 comments on commit 8f55171

Please sign in to comment.