-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for optional role_session_name
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"assume_role_arn": { | ||
"value": "" | ||
}, | ||
"aws_cli_commands": { | ||
"value": [ | ||
"s3api", | ||
"list-objects", | ||
"--bucket", | ||
"ryft-public-sample-data", | ||
"--no-sign-request" | ||
] | ||
}, | ||
"aws_cli_query": { | ||
"value": "max_by(Contents, &Size)" | ||
}, | ||
"debug_log_filename": { | ||
"value": "" | ||
}, | ||
"role_session_name": { | ||
"value": "" | ||
} | ||
} |
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 @@ | ||
// ryft-public-sample-data is a publicly accessible S3 bucket. | ||
aws_cli_commands = ["s3api", "list-objects", "--bucket", "ryft-public-sample-data", "--no-sign-request"] | ||
aws_cli_query = "max_by(Contents, &Size)" |
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,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
function run_test() { | ||
if [[ ! -f $PLAN_FILE ]]; then | ||
echo "Failed to generate a plan - $PLAN_FILE"; | ||
exit 1; | ||
fi | ||
|
||
if [[ ! "$(terraform show -json $PLAN_FILE | jq -MSr .variables)" == "$(cat $EXPECTED_VARIABLES)" ]]; then | ||
echo 'Failed to incorporate expected variable values into plan.'; | ||
exit 2; | ||
fi | ||
|
||
terraform apply -auto-approve -backup=- -state-out $STATE_FILE -var-file $TERRAFORM_TFVARS > $APPLY_LOG_FILE 2> $APPLY_ERROR_FILE | ||
|
||
if [[ ! -f $STATE_FILE ]]; then | ||
echo "Failed to generate state file - $STATE_FILE"; | ||
exit 3; | ||
fi | ||
|
||
# Extract some content the state file. | ||
if [[ ! "$(cat $STATE_FILE)" == *'0ae8f910a30bc83fd81c4e3c1a6bbd9bab0afe4e0762b56a2807d22fcd77d517'* ]]; then | ||
echo 'Failed to retrieve expected content from AWS.'; | ||
exit 4; | ||
fi | ||
|
||
# Extract some content from the apply log. | ||
if [[ ! "$(cat $APPLY_LOG_FILE)" == *"0ae8f910a30bc83fd81c4e3c1a6bbd9bab0afe4e0762b56a2807d22fcd77d517"* ]]; then | ||
echo 'Failed to present expected content to Terraform.'; | ||
exit 5; | ||
fi | ||
|
||
# Validate the absence of the debug log. | ||
if [[ -f $DEBUG_LOG_FILE ]]; then | ||
echo "Incorrectly generated debug.log file - $DEBUG_LOG_FILE"; | ||
exit 6; | ||
fi | ||
} | ||
|
||
. tests/common.sh $0 |