Skip to content

Commit

Permalink
feat(terraform): Migrate to Terraform Cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwilson committed Jul 1, 2024
1 parent e116f9f commit 8cd71d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:

env:
FASTLY_API_KEY: ${{ secrets.TERRAFORM_FASTLY_API_KEY }}
TF_WORKSPACE: "test"

defaults:
run:
Expand All @@ -25,15 +26,14 @@ jobs:
uses: actions/checkout@v3

- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}

- name: Set-up test workspace
run: |
terraform init
terraform workspace select -or-create test
terraform import --var-file=environments/test.tfvars module.fastly.fastly_service_vcl.cdn Fd19VLeN2NT4QGtaxR3lb2
- name: Apply test configuration
run: terraform apply -auto-approve -var-file=environments/test.tfvars
Expand All @@ -52,6 +52,7 @@ jobs:

env:
FASTLY_API_KEY: ${{ secrets.TERRAFORM_FASTLY_API_KEY }}
TF_WORKSPACE: "prod"

defaults:
run:
Expand All @@ -62,15 +63,14 @@ jobs:
uses: actions/checkout@v3

- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
cli_config_credentials_token: ${{ secrets.TERRAFORM_API_TOKEN }}

- name: Set-up prod workspace
run: |
terraform init
terraform workspace select -or-create prod
terraform import --var-file=environments/prod.tfvars module.fastly.fastly_service_vcl.cdn YNPeuDdYdC78w34AsmfIA7
- name: Apply prod configuration
run: terraform apply -auto-approve -var-file=environments/prod.tfvars
Expand Down
18 changes: 14 additions & 4 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
terraform {
cloud {
organization = "Alex_Wilson"
workspaces {
project = "platform"
tags = ["platform-environment"]
}
}
}

module "fastly" {
source = "./modules/fastly"
domains = var.domains
backends = var.backends
environment = terraform.workspace
source = "./modules/fastly"
domains = var.domains
backends = var.backends
environment = terraform.workspace
}
2 changes: 1 addition & 1 deletion terraform/modules/fastly/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
}

locals {
vcl = fileset("${path.module}/vcl", "*.vcl")
vcl = fileset("${path.module}/vcl", "*.vcl")
module_root = path.module
}

Expand Down

0 comments on commit 8cd71d9

Please sign in to comment.