fix: Add create_tfvars script and update pipeline configuration
This commit is contained in:
parent
2ab7872af1
commit
e0891f6c09
3 changed files with 54 additions and 0 deletions
32
gcloud/tf/scripts/create_tfvars.sh
Executable file
32
gcloud/tf/scripts/create_tfvars.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -a
|
||||
|
||||
# read environment variables from .env file
|
||||
# for value $PROJECT_NAME
|
||||
. .env
|
||||
|
||||
|
||||
# Check if PROJECT_NAME environment variable is set
|
||||
if [ -z "$PROJECT_NAME" ]; then
|
||||
echo "Error: PROJECT_NAME environment variable is not set."
|
||||
echo "Please set the PROJECT_NAME variable and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the directory where the script is located
|
||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||
cd "$SCRIPT_DIR" || { echo "Failed to change directory to $SCRIPT_DIR"; exit 1; }
|
||||
# Define the template file path and output file path
|
||||
TEMPLATE_FILE="../terraform.tfvars.template"
|
||||
OUTPUT_FILE="../terraform.tfvars"
|
||||
|
||||
|
||||
# Use envsubst to substitute the PROJECT_NAME variable into the template
|
||||
envsubst < "$TEMPLATE_FILE" > "$OUTPUT_FILE"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to substitute variables in the template."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "tfvars has been created at $OUTPUT_FILE"
|
||||
Loading…
Add table
Add a link
Reference in a new issue