From 368b52a4dd82437d0ba57d336b202730b9311c0d Mon Sep 17 00:00:00 2001 From: 3u13r Date: Mon, 10 Mar 2025 13:21:19 +0100 Subject: [PATCH] terraform: remove legacy infrastructure modules (#3691) --- bazel/ci/terraform.sh.in | 1 - terraform/legacy-module/README.md | 6 - .../legacy-module/aws-constellation/main.tf | 68 ------- .../aws-constellation/variables.tf | 77 ------- .../legacy-module/azure-constellation/main.tf | 68 ------- .../azure-constellation/variables.tf | 94 --------- .../legacy-module/common/fetch-image/main.tf | 38 ---- .../common/fetch-image/output.tf | 4 - .../common/fetch-image/variables.tf | 20 -- terraform/legacy-module/common/install-yq.sh | 43 ---- .../install-constellation.sh | 34 ---- .../constellation-cluster/main.tf | 191 ------------------ .../constellation-cluster/variables.tf | 133 ------------ .../legacy-module/gcp-constellation/main.tf | 71 ------- .../gcp-constellation/variables.tf | 86 -------- 15 files changed, 934 deletions(-) delete mode 100644 terraform/legacy-module/README.md delete mode 100644 terraform/legacy-module/aws-constellation/main.tf delete mode 100644 terraform/legacy-module/aws-constellation/variables.tf delete mode 100644 terraform/legacy-module/azure-constellation/main.tf delete mode 100644 terraform/legacy-module/azure-constellation/variables.tf delete mode 100644 terraform/legacy-module/common/fetch-image/main.tf delete mode 100644 terraform/legacy-module/common/fetch-image/output.tf delete mode 100644 terraform/legacy-module/common/fetch-image/variables.tf delete mode 100755 terraform/legacy-module/common/install-yq.sh delete mode 100755 terraform/legacy-module/constellation-cluster/install-constellation.sh delete mode 100644 terraform/legacy-module/constellation-cluster/main.tf delete mode 100644 terraform/legacy-module/constellation-cluster/variables.tf delete mode 100644 terraform/legacy-module/gcp-constellation/main.tf delete mode 100644 terraform/legacy-module/gcp-constellation/variables.tf diff --git a/bazel/ci/terraform.sh.in b/bazel/ci/terraform.sh.in index 456e312c4..777049106 100644 --- a/bazel/ci/terraform.sh.in +++ b/bazel/ci/terraform.sh.in @@ -46,7 +46,6 @@ excludeDirs=( excludeLockDirs=( "build" "terraform-provider-constellation" - "terraform/legacy-module" ) excludeCheckDirs=( diff --git a/terraform/legacy-module/README.md b/terraform/legacy-module/README.md deleted file mode 100644 index c755b0a54..000000000 --- a/terraform/legacy-module/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Constellation Terraform Modules - -> [!WARNING] -> The Constellation Terraform modules are deprecated, and support will be discontinued in v2.15.0. -> To continue managing Constellation clusters through Terraform, you can use the [Constellation Terraform provider](https://docs.edgeless.systems/constellation/workflows/terraform-provider). -> Clusters created through the Constellation Terraform modules can also be [imported](https://registry.terraform.io/providers/edgelesssys/constellation/latest/docs/resources/cluster#import) to the Constellation Terraform provider. diff --git a/terraform/legacy-module/aws-constellation/main.tf b/terraform/legacy-module/aws-constellation/main.tf deleted file mode 100644 index 83c92528a..000000000 --- a/terraform/legacy-module/aws-constellation/main.tf +++ /dev/null @@ -1,68 +0,0 @@ -locals { - region = substr(var.zone, 0, length(var.zone) - 1) -} - -module "aws_iam" { - source = "../../infrastructure/iam/aws" - name_prefix = var.name_prefix - region = local.region -} - -resource "null_resource" "ensure_yq" { - provisioner "local-exec" { - command = < "image.txt" - - if [ '${var.csp}' = 'azure' ]; then - sed -i 's/CommunityGalleries/communityGalleries/g' image.txt - sed -i 's/Images/images/g' image.txt - sed -i 's/Versions/versions/g' image.txt - fi - EOT -} - - -resource "null_resource" "fetch_image" { - provisioner "local-exec" { - command = local.fetch_image_command - - environment = { - attestation_variant = var.attestation_variant - } - } - provisioner "local-exec" { - when = destroy - command = "rm image.txt" - } - triggers = { - always_run = "${timestamp()}" - } -} - -data "local_file" "image" { - filename = "image.txt" - depends_on = [null_resource.fetch_image] -} diff --git a/terraform/legacy-module/common/fetch-image/output.tf b/terraform/legacy-module/common/fetch-image/output.tf deleted file mode 100644 index 8fcdc030f..000000000 --- a/terraform/legacy-module/common/fetch-image/output.tf +++ /dev/null @@ -1,4 +0,0 @@ -output "image" { - description = "The resolved image ID of the CSP." - value = data.local_file.image.content -} diff --git a/terraform/legacy-module/common/fetch-image/variables.tf b/terraform/legacy-module/common/fetch-image/variables.tf deleted file mode 100644 index 25b88bd1b..000000000 --- a/terraform/legacy-module/common/fetch-image/variables.tf +++ /dev/null @@ -1,20 +0,0 @@ -variable "csp" { - description = "The cloud service provider to fetch image data for." - type = string -} - -variable "attestation_variant" { - description = "The attestation variant to fetch image data for." - type = string -} - -variable "region" { - description = "The region to fetch image data for." - type = string - default = "" -} - -variable "image" { - description = "The image reference or semantical release version to fetch image data for." - type = string -} diff --git a/terraform/legacy-module/common/install-yq.sh b/terraform/legacy-module/common/install-yq.sh deleted file mode 100755 index 14c375fd9..000000000 --- a/terraform/legacy-module/common/install-yq.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -version="v4.35.2" -if [[ -f ./yq ]] && ./yq --version | grep -q "${version}"; then - echo "yq is already available and up to date." - exit 0 -fi -if [[ -f ./yq ]]; then - echo "yq is already available but not at the required version. Replacing with ${version}." - rm -f yq -fi - -echo "Fetching yq ${version}" -os=$(uname -s) -arch=$(uname -m) -url="" - -if [[ ${os} == "Darwin" ]]; then - if [[ ${arch} == "arm64" ]]; then - url="https://github.com/mikefarah/yq/releases/download/${version}/yq_darwin_arm64" - elif [[ ${arch} == "x86_64" ]]; then - url="https://github.com/mikefarah/yq/releases/download/${version}/yq_darwin_amd64" - fi -elif [[ ${os} == "Linux" ]]; then - if [[ ${arch} == "x86_64" ]]; then - url="https://github.com/mikefarah/yq/releases/download/${version}/yq_linux_amd64" - elif [[ ${arch} == "arm64" ]]; then - url="https://github.com/mikefarah/yq/releases/download/${version}/yq_linux_arm64" - fi -fi - -if [[ -z ${url} ]]; then - echo "os \"${os}\" and/or architecture \"${arch}\" is not supported." - exit 1 -else - echo "Downloading yq from ${url}" - curl -o yq -L "${url}" - chmod +x ./yq - ./yq --version - if ! ./yq --version | grep -q "${version}"; then # check that yq was installed correctly - echo "Version is incorrect" - exit 1 - fi -fi diff --git a/terraform/legacy-module/constellation-cluster/install-constellation.sh b/terraform/legacy-module/constellation-cluster/install-constellation.sh deleted file mode 100755 index b056db21a..000000000 --- a/terraform/legacy-module/constellation-cluster/install-constellation.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -if [[ -f ./constellation ]]; then - echo "constellation CLI is already available." - exit 0 -fi - -os=$(uname -s) -arch=$(uname -m) -version=$1 -url="" - -echo "Fetching constellation ${version}" - -if [[ ${os} == "Darwin" ]]; then - if [[ ${arch} == "arm64" ]]; then - url="https://github.com/edgelesssys/constellation/releases/${version}/download/constellation-darwin-arm64" - elif [[ ${arch} == "x86_64" ]]; then - url="https://github.com/edgelesssys/constellation/releases/${version}/download/constellation-darwin-amd64" - fi -elif [[ ${os} == "Linux" ]]; then - if [[ ${arch} == "x86_64" ]]; then - url="https://github.com/edgelesssys/constellation/releases/${version}/download/constellation-linux-amd64" - elif [[ ${arch} == "arm64" ]]; then - url="https://github.com/edgelesssys/constellation/releases/${version}/download/constellation-linux-arm64" - fi -fi - -if [[ -z ${url} ]]; then - echo "os \"${os}\" and/or architecture \"${arch}\" is not supported." - exit 1 -else - curl -o constellation -L "${url}" - chmod +x constellation -fi diff --git a/terraform/legacy-module/constellation-cluster/main.tf b/terraform/legacy-module/constellation-cluster/main.tf deleted file mode 100644 index f84406f16..000000000 --- a/terraform/legacy-module/constellation-cluster/main.tf +++ /dev/null @@ -1,191 +0,0 @@ -locals { - yq_node_groups = join("\n", flatten([ - for name, group in var.node_groups : [ - "./yq eval '.nodeGroups.${name}.role = \"${group.role}\"' -i constellation-conf.yaml", - "./yq eval '.nodeGroups.${name}.zone = \"${group.zone}\"' -i constellation-conf.yaml", - "./yq eval '.nodeGroups.${name}.instanceType = \"${group.instance_type}\"' -i constellation-conf.yaml", - "./yq eval '.nodeGroups.${name}.stateDiskSizeGB = ${group.disk_size}' -i constellation-conf.yaml", - "./yq eval '.nodeGroups.${name}.stateDiskType = \"${group.disk_type}\"' -i constellation-conf.yaml", - "./yq eval '.nodeGroups.${name}.initialCount = ${group.initial_count}' -i constellation-conf.yaml" - ] - ])) - gcp_sa_file_path = "service_account_file.json" -} - -resource "null_resource" "ensure_cli" { - provisioner "local-exec" { - command = < "${local.gcp_sa_file_path}" - EOT - } - provisioner "local-exec" { - when = destroy - command = "rm ${self.triggers.file_path}" - } - triggers = { - always_run = timestamp() - file_path = local.gcp_sa_file_path - } -} - -resource "null_resource" "gcp_config" { - count = var.gcp_config != null ? 1 : 0 - provisioner "local-exec" { - command = <