From d3b918352b20106404b65d145bc986e8f1e45308 Mon Sep 17 00:00:00 2001 From: David Sibley Date: Wed, 23 Nov 2022 16:28:30 +0000 Subject: [PATCH] removed reliance on remote backend --- .github/workflows/go-terratest.yml | 5 ----- test/unit-test/backend.tf | 13 ------------- test/unit-test/locals.tf | 4 ++-- test/unit-test/main.tf | 3 ++- test/unit-test/providers.tf | 2 +- 5 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 test/unit-test/backend.tf diff --git a/.github/workflows/go-terratest.yml b/.github/workflows/go-terratest.yml index 0cdc0e0c..7d191dd9 100644 --- a/.github/workflows/go-terratest.yml +++ b/.github/workflows/go-terratest.yml @@ -18,11 +18,6 @@ jobs: with: terraform_version: 1.0.1 terraform_wrapper: false - - name: set terraform workspace - run: | - #CONFIGURE TERRAFORM AND WORKSPACE - terraform -chdir="test/unit-test" init - terraform -chdir="test/unit-test" workspace select testing-test - name: Download Go Modules working-directory: test run: go mod download diff --git a/test/unit-test/backend.tf b/test/unit-test/backend.tf deleted file mode 100644 index c5904984..00000000 --- a/test/unit-test/backend.tf +++ /dev/null @@ -1,13 +0,0 @@ -# Backend -terraform { - # `backend` blocks do not support variables, so the following are hard-coded here: - # - S3 bucket name, which is created in modernisation-platform-account/s3.tf - backend "s3" { - acl = "bucket-owner-full-control" - bucket = "modernisation-platform-terraform-state" - encrypt = true - key = "terraform.tfstate" - region = "eu-west-2" - workspace_key_prefix = "environments/members/testing" # This will store the object as environments/members/testing/${workspace}/terraform.tfstate - } -} diff --git a/test/unit-test/locals.tf b/test/unit-test/locals.tf index b9046980..7362f34c 100644 --- a/test/unit-test/locals.tf +++ b/test/unit-test/locals.tf @@ -22,13 +22,13 @@ locals { # Merge tags from the environment json file with additional ones tags = merge( - jsondecode(data.http.environments_file.body).tags, + jsondecode(data.http.environments_file.response_body).tags, { "is-production" = local.is-production }, { "environment-name" = terraform.workspace }, { "source-code" = "https://github.com/ministryofjustice/modernisation-platform" } ) - environment = trimprefix(terraform.workspace, "${var.networking[0].application}-") + environment = trimprefix("testing-test", "${var.networking[0].application}-") vpc_name = var.networking[0].business-unit subnet_set = var.networking[0].set vpc_all = "${local.vpc_name}-${local.environment}" diff --git a/test/unit-test/main.tf b/test/unit-test/main.tf index c8655f76..f38bf5dc 100644 --- a/test/unit-test/main.tf +++ b/test/unit-test/main.tf @@ -29,6 +29,7 @@ locals { } } } + data "aws_vpc" "shared" { tags = { "Name" = "${var.networking[0].business-unit}-${local.environment}" @@ -69,7 +70,7 @@ module "lb_access_logs_enabled" { loadbalancer_ingress_rules = local.loadbalancer_ingress_rules loadbalancer_egress_rules = local.loadbalancer_egress_rules tags = local.tags - account_number = local.environment_management.account_ids[terraform.workspace] + account_number = local.environment_management.account_ids["testing-test"] region = "eu-west-2" enable_deletion_protection = false idle_timeout = 60 diff --git a/test/unit-test/providers.tf b/test/unit-test/providers.tf index a64d4c62..5e63b8b8 100644 --- a/test/unit-test/providers.tf +++ b/test/unit-test/providers.tf @@ -2,7 +2,7 @@ provider "aws" { region = "eu-west-2" assume_role { - role_arn = "arn:aws:iam::${local.environment_management.account_ids[terraform.workspace]}:role/MemberInfrastructureAccess" + role_arn = "arn:aws:iam::${local.environment_management.account_ids["testing-test"]}:role/MemberInfrastructureAccess" } }