-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Multiple bugs in terraform deploy.sh
.
Version: bitops:2.0.0
.
-
Verbose logging flag is always set for
deploy.sh
irrespective of BitOps log level resulting in lots of noisy output:
Lines 1 to 3 in cbb125c
#!/bin/bash # No set -e here because we want to get a non-zero exit code from terraform_plan.sh set -ex
In production, it'll be annoying to have all that in the logs by default. Instead of setting-x
, we should do granular logging based on theBITOPS_LOGGING_LEVEL
value. -
TERRAFORM_VERSION
is not passed or used in thedeploy.sh
:
Lines 47 to 48 in cbb125c
# Set terraform version echo "Using terraform version $TERRAFORM_VERSION"
Example log:
+ echo 'Using terraform version '
I don't see how we pass the version from anywhere. -
If
terraform init
failed it'll fall-back into the versioned terraform init:
Lines 52 to 53 in cbb125c
echo "Running terraform init" terraform init -input=false || /usr/local/bin/terraform-$TERRAFORM_VERSION init -input=false
Example log:
+ echo 'Running terraform init'
+ terraform init -input=false
Error refreshing state: AccessDenied: Access Denied
status code: 403, request id: WTGWPGEV8EDCBEWQ, host id: ZPY5+1vZA4Mo6Hx4xhAh9OiWaFBZv/6O8IIX3i8JnkkHOIE4eipPnouvb2p3LRx2jJ6cGR9VJLI=
+ /usr/local/bin/terraform- init -input=false
/opt/bitops/scripts/plugins/terraform/deploy.sh: line 53: /usr/local/bin/terraform-: No such file or directory
The logic should be changed to check the default binary presence first.
Full Log
docker run \
-e BITOPS_ENVIRONMENT="test" \
-e BITOPS_LOGGING_LEVEL=ERROR \
-e AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
-e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
-e AWS_DEFAULT_REGION="us-east-2" \
-e TF_STATE_BUCKET="heyemoji_blog" \
-e HEYEMOJI_SLACK_API_TOKEN="YOUR SLACK API TOKEN" \
-v $(pwd):/opt/bitops_deployment \
bitovi/bitops:2.0.0
2022-10-11 20:42:43,036 root ERROR + echo 'Running Terraform Plugin deployment script...'
+ export TERRAFORM_ROOT_SCRIPTS=/opt/bitops/scripts/plugins/terraform
+ TERRAFORM_ROOT_SCRIPTS=/opt/bitops/scripts/plugins/terraform
+ export TERRAFORM_ROOT_OPERATIONS=/tmp/tmpzm0trzjo/test/terraform
+ TERRAFORM_ROOT_OPERATIONS=/tmp/tmpzm0trzjo/test/terraform
+ export BITOPS_SCHEMA_ENV_FILE=/tmp/tmpzm0trzjo/test/terraform/ENV_FILE
+ BITOPS_SCHEMA_ENV_FILE=/tmp/tmpzm0trzjo/test/terraform/ENV_FILE
+ export SCRIPTS_DIR=/opt/bitops/scripts/plugins/terraform/scripts
+ SCRIPTS_DIR=/opt/bitops/scripts/plugins/terraform/scripts
+ '[' '!' -d /tmp/tmpzm0trzjo/test/terraform ']'
+ printf 'Deploying terraform...'
+ find /opt/bitops/scripts/plugins/terraform/scripts -name '*.sh' -exec chmod +x '{}' +
+ '[' '!' -f /tmp/tmpzm0trzjo/test/terraform/ENV_FILE ']'
+ echo 'No terraform ENV file found'
+ echo 'DEBUGGING: [/opt/bitops/scripts/plugins/terraform/scripts]'
+ bash /opt/bitops/scripts/plugins/terraform/scripts/validate_env.sh
+ echo 'Copying defaults'
+ /opt/bitops/scripts/plugins/terraform/scripts/copy_defaults.sh ''
+ echo 'DEBUGGING: [/opt/bitops/scripts/plugins/terraform/scripts]'
+ echo 'cd Terraform Root: /tmp/tmpzm0trzjo/test/terraform'
+ cd /tmp/tmpzm0trzjo/test/terraform
+ echo 'Listing contents of Terraform Root: /tmp/tmpzm0trzjo/test/terraform'
+ ls -al .
+ echo 'Using terraform version '
+ echo 'Running terraform init'
+ terraform init -input=false
Error refreshing state: AccessDenied: Access Denied
status code: 403, request id: WTGWPGEV8EDCBEWQ, host id: ZPY5+1vZA4Mo6Hx4xhAh9OiWaFBZv/6O8IIX3i8JnkkHOIE4eipPnouvb2p3LRx2jJ6cGR9VJLI=
+ /usr/local/bin/terraform- init -input=false
/opt/bitops/scripts/plugins/terraform/deploy.sh: line 53: /usr/local/bin/terraform-: No such file or directory
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working