diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 0e5c867e7..b33c9b109 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -21,6 +21,20 @@ jobs: with: # terraform_version: 0.13.0: cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + + - name: Test var + id: testvar + run: echo "${{ vars.TF_VAR_STATE_BUCKET }}" + + - name: Download backend + id: s3d + run: aws s3api get-object --bucket ${{ vars.TF_VAR_STATE_BUCKET }} --key backend.personal.tfvars backend.personal.tfvars - name: Terraform Format id: fmt @@ -28,7 +42,7 @@ jobs: - name: Terraform Init id: init - run: terraform init + run: terraform init -backend-config="backend.personal.tfvars" - name: Terraform Validate id: validate diff --git a/.gitignore b/.gitignore index 15ab5efe7..71c2d32d7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,8 +17,8 @@ crash.*.log # password, private keys, and other secrets. These should not be part of version # control as they are data points which are potentially sensitive and subject # to change depending on the environment. -*.tfvars -*.tfvars.json +# *.tfvars +# *.tfvars.json # Ignore override files as they are usually used to override resources locally and so # are not checked in diff --git a/main.tf b/main.tf index cacd40f1d..81c365363 100644 --- a/main.tf +++ b/main.tf @@ -13,13 +13,16 @@ terraform { } } required_version = ">= 1.1.0" + # cloud { + # organization = "cornebester" - cloud { - organization = "REPLACE_ME" + # workspaces { + # name = "gh-actions-demo" + # } + # } - workspaces { - name = "gh-actions-demo" - } + backend "s3" { + bucket = var.state_bucket } }