From 281c141de864a7f280bbff848e0ac97a3eaf7210 Mon Sep 17 00:00:00 2001 From: Shiv Lakshminarayan Date: Wed, 16 Oct 2019 11:15:02 -0700 Subject: [PATCH] chore: add an integ test for deploy with notification ARNs --- .../test-cdk-deploy-with-notification-arns.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 packages/aws-cdk/test/integ/cli/test-cdk-deploy-with-notification-arns.sh diff --git a/packages/aws-cdk/test/integ/cli/test-cdk-deploy-with-notification-arns.sh b/packages/aws-cdk/test/integ/cli/test-cdk-deploy-with-notification-arns.sh new file mode 100755 index 0000000000000..8e9be952ef2dc --- /dev/null +++ b/packages/aws-cdk/test/integ/cli/test-cdk-deploy-with-notification-arns.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -euo pipefail +scriptdir=$(cd $(dirname $0) && pwd) +source ${scriptdir}/common.bash +# ---------------------------------------------------------- +sns_topic_name=${STACK_NAME_PREFIX}-test-topic + +response_json=$(mktemp).json +aws sns create-topic --name ${sns_topic_name} > ${response_json} +sns_arn=$(node -e "console.log(require('${response_json}').TopicArn)") + +setup + +stack_arn=$(cdk deploy ${STACK_NAME_PREFIX}-test-2 --notification-arns ${sns_arn}) +echo "Stack deployed successfully" + +# verify that the stack we deployed has our notification ARN +aws cloudformation describe-stacks --stack-name ${stack_arn} > ${response_json} + +notification_count=$(node -e "console.log(require('${response_json}').Stacks[0].NotificationARNs.length)") +if [[ "${notification_count}" -ne 1 ]]; then + fail "stack has ${notification_count} SNS notification ARNs, and we expected one" +fi + +notification_arn=$(node -e "console.log(require('${response_json}').Stacks[0].NotificationARNs[0])") +if [[ "${notification_arn}" != "${sns_arn}" ]]; then + fail "stack has ${notification_arn} SNS notification ARN, and we expected ${sns_arn}" +fi + +# destroy stack and delete SNS topic +cdk destroy -f ${STACK_NAME_PREFIX}-test-2 +aws sns delete-topic --topic-arn ${sns_arn} + +echo "✅ success"