From 9ebdfa1071b0f71c9955f8a23851e25ced878154 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 5 May 2024 16:36:34 -0400 Subject: [PATCH] fix: tf backend can't be a variable --- .github/workflows/arrow-aws.yml | 7 ++++--- hosts/arrow/aws/main.tf | 2 -- hosts/arrow/aws/variables.tf | 10 ---------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/arrow-aws.yml b/.github/workflows/arrow-aws.yml index 7305fcc..505994d 100644 --- a/.github/workflows/arrow-aws.yml +++ b/.github/workflows/arrow-aws.yml @@ -91,15 +91,16 @@ jobs: # Connects to remote state backend and download providers. - name: Terraform Init working-directory: ${{ env.TERRAFORM_DIRECTORY }} - run: terraform init + run: | + terraform init \ + -backend-config="bucket=${{ secrets.TERRAFORM_STATE_BUCKET }}" \ + -backend-config="key=arrow.tfstate" # Deploys infrastructure or changes to infrastructure. - name: Terraform Apply if: inputs.action == 'create' working-directory: ${{ env.TERRAFORM_DIRECTORY }} env: - TF_VAR_terraform_state_bucket: ${{ secrets.TERRAFORM_STATE_BUCKET }} - TF_VAR_terraform_state_key: arrow.tfstate TF_VAR_ec2_size: ${{ inputs.size }} run: | terraform apply \ diff --git a/hosts/arrow/aws/main.tf b/hosts/arrow/aws/main.tf index efe2196..650e71a 100644 --- a/hosts/arrow/aws/main.tf +++ b/hosts/arrow/aws/main.tf @@ -1,7 +1,5 @@ terraform { backend "s3" { - bucket = var.terraform_state_bucket - key = var.terraform_state_key region = "us-east-1" dynamodb_table = "terraform-state-lock" } diff --git a/hosts/arrow/aws/variables.tf b/hosts/arrow/aws/variables.tf index ecef5a3..f330123 100644 --- a/hosts/arrow/aws/variables.tf +++ b/hosts/arrow/aws/variables.tf @@ -8,13 +8,3 @@ variable "images_bucket" { description = "Name of the bucket in which to store the NixOS VM images." type = string } - -variable "terraform_state_bucket" { - description = "Name of the bucket in which to store the Terraform state information." - type = string -} - -variable "terraform_state_key" { - description = "Path of the file in which to store the Terraform state information." - type = string -}