Skip to content

Commit

Permalink
feat: capacity to parametrize TF parameters file at infra deployment …
Browse files Browse the repository at this point in the history
…and destruction
  • Loading branch information
tschneider-aneo committed Dec 19, 2024
1 parent 0c69318 commit ba4e67c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
16 changes: 14 additions & 2 deletions deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ inputs:
required: false
default: ""
working-directory:
descriptiont: "Working directory (should be the ArmoniK repo root folder)"
description: "Working directory (should be the ArmoniK repo root folder)"
required: false
default: ${{ github.workspace }}
shared-data-folder:
Expand All @@ -48,6 +48,11 @@ inputs:
description: "Suffix to append to the terraform output artifact"
required: false
default: "default"
parameters-file-path:
description: "Relative path for the Terraform configuration file, root being the ArmoniK repository. Empty keeps it to the default parameters.tfvars associated with your deployment type"
required: false
default: ""

outputs:
terraform-output:
description: "Terraform output of the deployment"
Expand Down Expand Up @@ -115,11 +120,18 @@ runs:
env:
INPUT_TYPE: ${{ inputs.type }}
INPUT_PREFIX: ${{ inputs.prefix }}
PARAMETERS_FILE_PATH: ${{ inputs.parameters-file-path }}
run: |
set -ex
if [ -n "$PARAMETERS_FILE_PATH" ]; then
PARAMETERS_FILE="$(pwd)/$PARAMETERS_FILE"
fi
cd infrastructure/quick-deploy/
cd "$INPUT_TYPE"
make PREFIX="$INPUT_PREFIX" deploy
if [ -z "$PARAMETERS_FILE_PATH" ]; then
PARAMETERS_FILE=parameters.tfvars
fi
make PREFIX="$INPUT_PREFIX" PARAMETERS_FILE="$PARAMETERS_FILE" deploy
{
echo 'terraform-output<<__GITHUB_EOF__'
cat generated/armonik-output.json
Expand Down
19 changes: 15 additions & 4 deletions destroy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: "Working directory (should be the ArmoniK repo root folder)"
required: false
default: ${{ github.workspace }}
parameters-file-path:
description: "Relative path for the Terraform configuration file, root being the ArmoniK repository. Empty keeps it to the default parameters.tfvars associated with your deployment type"
required: false
default: ""

runs:
using: composite
Expand All @@ -23,13 +27,20 @@ runs:
env:
INPUT_TYPE: ${{ inputs.type }}
INPUT_PREFIX: ${{ inputs.prefix }}
PARAMETERS_FILE_PATH: ${{ inputs.parameters-file-path }}
run: |
set -ex
if [ -n "$PARAMETERS_FILE_PATH" ]; then
PARAMETERS_FILE="$(pwd)/$PARAMETERS_FILE"
fi
cd infrastructure/quick-deploy/
cd "$INPUT_TYPE"
make PREFIX="$INPUT_PREFIX" get-modules
make PREFIX="$INPUT_PREFIX" init
make PREFIX="$INPUT_PREFIX" output
if [ -z "$PARAMETERS_FILE_PATH" ]; then
PARAMETERS_FILE=parameters.tfvars
fi
make PREFIX="$INPUT_PREFIX" PARAMETERS_FILE="$PARAMETERS_FILE" get-modules
make PREFIX="$INPUT_PREFIX" PARAMETERS_FILE="$PARAMETERS_FILE" init
make PREFIX="$INPUT_PREFIX" PARAMETERS_FILE="$PARAMETERS_FILE" output
EKS_NAME="$(jq -r .eks.name generated/armonik-output.json)"
EKS_REGION="$(jq -r .eks.region generated/armonik-output.json)"
[ "$EKS_NAME" != null ] || EKS_NAME=
Expand All @@ -41,4 +52,4 @@ runs:
# Ignore the update_kubeconfig if there is no more EKS
TF_DATA_DIR=generated terraform state rm module.eks.null_resource.update_kubeconfig > /dev/null 2>&1 || true
fi
make PREFIX="$INPUT_PREFIX" delete
make PREFIX="$INPUT_PREFIX" PARAMETERS_FILE="$PARAMETERS_FILE" delete

0 comments on commit ba4e67c

Please sign in to comment.