Skip to content

Commit

Permalink
Pass local AWS env vars to Terraform, tf fmt
Browse files Browse the repository at this point in the history
Also rearrange the order of the validation scripts to fmt first
  • Loading branch information
obscurerichard committed Sep 13, 2022
1 parent fde7251 commit 5858fb8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function get_env_tmpfile() {
local TMPFILE
TMPFILE="$(mktemp)"
grep ^export "$DIR/../env.sh" | cut -c8- > "$TMPFILE"
printenv | grep '^AWS' >> "$TMPFILE"
echo "$TMPFILE"
}

Expand Down
16 changes: 8 additions & 8 deletions bin/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ echo "Linting packer files"
$DOCKER_PACKER validate app/packer/machines/web-server.json

# Ensure that `terraform fmt` comes up clean
if [[ "$SKIP_TERRAFORM" == "false" ]]; then
echo "Linting terraform files for correctness"
if [[ "${SKIP_TERRAFORM:-false}" == "false" ]]; then
DOCKER_TERRAFORM=$(get_docker_terraform)
init_terraform
$DOCKER_TERRAFORM validate \
-var 'newrelic_license_key=ZZZZ' \
-var 'newrelic_api_key=ZZZZ' \
-var '[email protected]' \
echo "Linting terraform files for formatting"
fmt=$($DOCKER_TERRAFORM fmt)
if [[ -n "$fmt" ]]; then
echo 'ERROR: these files are not formatted correctly. Run "terraform fmt"'
echo "$fmt"
git diff
exit 1
fi
echo "Linting terraform files for correctness"
init_terraform
$DOCKER_TERRAFORM validate \
-var 'newrelic_license_key=ZZZZ' \
-var 'newrelic_api_key=ZZZZ' \
-var '[email protected]' \
echo "Linting terraform files for formatting"
fi

echo "Linting shell scripts"
Expand Down
1 change: 1 addition & 0 deletions terraform/aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
provider "aws" {
region = "${var.aws_region}"
version = "~> 1.57"

assume_role = {
role_arn = "arn:aws:iam::587267277416:role/terraform_sandbox_backend_admin"
}
Expand Down

0 comments on commit 5858fb8

Please sign in to comment.