Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate upgrade scripts for Terraform #4126

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
FEATURES:

ENHANCEMENTS:
* Split log entries with [Log chunk X of Y] for better readability. ([[#3992](https://github.com/microsoft/AzureTRE/issues/3992)
* Split log entries with [Log chunk X of Y] for better readability. ([#3992](https://github.com/microsoft/AzureTRE/issues/3992))
* Expose APP_SERVICE_SKU build variable to allow enablement of App Gateway WAF ([#4111](https://github.com/microsoft/AzureTRE/pull/4111))
* Update Terraform to use Azure AD authentication rather than storage account keys ([#4103](https://github.com/microsoft/AzureTRE/issues/4103))
* Consolidate Terraform upgrade scripts ([#4099](https://github.com/microsoft/AzureTRE/issues/4099))

BUG FIXES:
- Update KeyVault references in API to use the version so Terraform cascades the update ([#4112](https://github.com/microsoft/AzureTRE/pull/4112))
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ terraform-upgrade:
&& . ${MAKEFILE_DIR}/devops/scripts/check_dependencies.sh env \
&& . ${MAKEFILE_DIR}/devops/scripts/load_and_validate_env.sh \
&& . ${MAKEFILE_DIR}/devops/scripts/load_env.sh ${DIR}/.env \
&& cd ${DIR}/terraform/ && ./upgrade.sh
&& ./devops/scripts/upgrade.sh ${DIR}

terraform-import:
$(call target_title, "Importing ${DIR} with Terraform") \
Expand Down
13 changes: 0 additions & 13 deletions core/terraform/upgrade.sh

This file was deleted.

2 changes: 1 addition & 1 deletion core/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.10.12"
__version__ = "0.10.13"
61 changes: 61 additions & 0 deletions devops/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
set -e

# This script is used to upgrade terraform providers in a specified directory

# Usage: ./upgrade.sh <directory>

DIR=$1

# Load environment variables from .env file
if [ -f "$DIR/.env" ]; then
set -a
# shellcheck source=/dev/null
. "$DIR/.env"
set +a
fi

# Ensure TF_VAR_mgmt_resource_group_name is set
if [ -z "${TF_VAR_mgmt_resource_group_name}" ]; then
echo "Error: TF_VAR_mgmt_resource_group_name is not set."
exit 1
fi

# Ensure TF_VAR_mgmt_storage_account_name is set
if [ -z "${TF_VAR_mgmt_storage_account_name}" ]; then
echo "Error: TF_VAR_mgmt_storage_account_name is not set."
exit 1
fi

# Ensure TF_VAR_terraform_state_container_name is set
if [ -z "${TF_VAR_terraform_state_container_name}" ]; then
echo "Error: TF_VAR_terraform_state_container_name is not set."
exit 1
fi

# Ensure TRE_ID is set
if [ -z "${TRE_ID}" ]; then
echo "Error: TRE_ID is not set."
exit 1
fi

# Infer the key from the directory names
PARENT_DIR=$(basename "$(dirname "$DIR")")
GRANDPARENT_DIR=$(basename "$(dirname "$(dirname "$DIR")")")

if [[ "$GRANDPARENT_DIR" == "workspaces" || "$GRANDPARENT_DIR" == "shared_services" ]]; then
KEY="${TRE_ID?}_${TF_VAR_id?}_${PARENT_DIR}"
elif [[ "$GRANDPARENT_DIR" == "workspace_services" ]]; then
KEY="${TRE_ID?}_${TF_VAR_workspace_id?}_${TF_VAR_id?}_${PARENT_DIR}"
elif [[ "$GRANDPARENT_DIR" == "user_resources" ]]; then
KEY="${TRE_ID?}_${TF_VAR_workspace_id?}_${TF_VAR_workspace_service_id?}_${TF_VAR_id?}_${PARENT_DIR}"
else
KEY="${TRE_ID?}_${PARENT_DIR}"
fi

# Run terraform init with upgrade and reconfigure options
terraform -chdir="$DIR/terraform" init -upgrade -reconfigure -input=false -backend=true \
-backend-config="resource_group_name=${TF_VAR_mgmt_resource_group_name}" \
-backend-config="storage_account_name=${TF_VAR_mgmt_storage_account_name}" \
-backend-config="container_name=${TF_VAR_terraform_state_container_name}" \
-backend-config="key=${KEY}"
13 changes: 0 additions & 13 deletions devops/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/admin-vm/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/airlock_notifier/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/certs/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/cyclecloud/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/databricks-auth/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/firewall/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/gitea/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/shared_services/sonatype-nexus-vm/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/workspace_services/databricks/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/workspace_services/gitea/terraform/upgrade.sh

This file was deleted.

13 changes: 0 additions & 13 deletions templates/workspace_services/guacamole/terraform/upgrade.sh

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading