mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
format env vars correctly in terraform plan
This commit is contained in:
parent
aff3113d52
commit
78caa1e6ae
1 changed files with 10 additions and 3 deletions
13
.github/workflows/_deploy_lambda.yml
vendored
13
.github/workflows/_deploy_lambda.yml
vendored
|
|
@ -83,14 +83,21 @@ jobs:
|
|||
- name: Terraform Plan
|
||||
working-directory: ${{ inputs.lambda_path }}
|
||||
run: |
|
||||
ENV_VARS=""
|
||||
if [ -n "${{ inputs.environment_vars }}" ]; then
|
||||
# convert multi-line to JSON map: key=value -> "key"="value"
|
||||
ENV_VARS=$(echo "${{ inputs.environment_vars }}" | \
|
||||
awk -F= '{gsub(/"/,"\\\""); printf "\"%s\"=\"%s\",",$1,$2}' | \
|
||||
sed 's/,$//') # remove trailing comma
|
||||
ENV_VARS="-var='environment_vars={${ENV_VARS}}'"
|
||||
fi
|
||||
|
||||
terraform plan \
|
||||
-var="stage=${{ inputs.stage }}" \
|
||||
-var="lambda_name=${{ inputs.lambda_name }}" \
|
||||
-var="ecr_repo_url=${{ steps.repo.outputs.ecr_repo_url }}" \
|
||||
-var="image_digest=${{ inputs.image_digest }}" \
|
||||
$(if [ -n "${{ inputs.environment_vars }}" ]; then
|
||||
echo "-var=\"environment_vars=${{ inputs.environment_vars }}\""
|
||||
fi) \
|
||||
$ENV_VARS \
|
||||
-out=lambdaplan
|
||||
|
||||
- name: Terraform Apply
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue