diff --git a/cfn-resources/flex-cluster/test/cfn-test-create-inputs.sh b/cfn-resources/flex-cluster/test/cfn-test-create-inputs.sh index 8a7f935a5..a74224134 100755 --- a/cfn-resources/flex-cluster/test/cfn-test-create-inputs.sh +++ b/cfn-resources/flex-cluster/test/cfn-test-create-inputs.sh @@ -9,8 +9,8 @@ set -o nounset set -o pipefail function usage { - echo "usage:$0 " - echo "Adjust flex cluster test input files" + echo "usage:$0 " + echo "Generates test input files for flex cluster" exit 0 } @@ -27,7 +27,15 @@ if [ ${MONGODB_ATLAS_PROFILE+x} ]; then profile=${MONGODB_ATLAS_PROFILE} fi -projectId="${1}" +projectName="${1}" +projectId=$(atlas projects list --output json | jq --arg NAME "${projectName}" -r '.results[] | select(.name==$NAME) | .id') +if [ -z "$projectId" ]; then + projectId=$(atlas projects create "${projectName}" --output=json | jq -r '.id') + echo -e "Created project \"${projectName}\" with id: ${projectId}\n" +else + echo -e "FOUND project \"${projectName}\" with id: ${projectId}\n" +fi + clusterName="cfn-test-bot-$((1 + RANDOM % 10000))" echo "clusterName: $clusterName" diff --git a/cfn-resources/flex-cluster/test/cfn-test-delete-inputs.sh b/cfn-resources/flex-cluster/test/cfn-test-delete-inputs.sh new file mode 100755 index 000000000..e53aeb41d --- /dev/null +++ b/cfn-resources/flex-cluster/test/cfn-test-delete-inputs.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# cfn-test-delete-inputs.sh +# +# Needs to exist to be called in Publish, but no cleanup is needed. diff --git a/cfn-resources/flex-cluster/test/contract-testing/cfn-test-create.sh b/cfn-resources/flex-cluster/test/contract-testing/cfn-test-create.sh index 5bea545bc..601dea3d7 100755 --- a/cfn-resources/flex-cluster/test/contract-testing/cfn-test-create.sh +++ b/cfn-resources/flex-cluster/test/contract-testing/cfn-test-create.sh @@ -13,4 +13,4 @@ projectId=$(atlas projects create "${projectName}" --output=json | jq -r '.id') echo "projectId: $projectId" echo "projectName: $projectName" -./test/cfn-test-create-inputs.sh "$projectId" +./test/cfn-test-create-inputs.sh "$projectName"