For all the below, the directory before running terraform init
contains only main.tf
my-terraform-project/
├─ main.tf
#!/bin/bash | |
az=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) | |
region=${az%%?} | |
instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
aws ec2 create-tags --resources $instance_id --region $region --tags \ | |
Key=foo,Value=bar \ | |
Key=Name,Value=myname |
$ TF_LOG=trace TF_CLI_CONFIG_FILE="~/tfc-test-repos/tf-goog-manual-tests/dev.tfrc" terraform plan | |
2023-02-08T17:19:13.285Z [INFO] Terraform version: 1.3.5 dev | |
2023-02-08T17:19:13.285Z [DEBUG] using github.com/hashicorp/go-tfe v1.9.0 | |
2023-02-08T17:19:13.285Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.15.0 | |
2023-02-08T17:19:13.285Z [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 | |
2023-02-08T17:19:13.285Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 | |
2023-02-08T17:19:13.285Z [DEBUG] using github.com/zclconf/go-cty v1.12.1 | |
2023-02-08T17:19:13.285Z [INFO] Go runtime version: go1.18.3 |
In this example, `TF_CLI_CONFIG_FILE` is set to point at an existing file | |
$ TF_LOG=trace TF_CLI_CONFIG_FILE="/Users/sarahfrench/tfc-test-repos/tf-goog-manual-tests/dev.tfrc" terraform plan | |
2023-02-08T17:11:47.825Z [INFO] Terraform version: 1.3.5 dev | |
2023-02-08T17:11:47.827Z [DEBUG] using github.com/hashicorp/go-tfe v1.9.0 | |
2023-02-08T17:11:47.827Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.15.0 |
In this example, `TF_CLI_CONFIG_FILE` is set to point at a non-existant file | |
$ TF_LOG=trace TF_CLI_CONFIG_FILE="/Users/sarahfrench/tfc-test-repos/tf-goog-manual-tests/file-doesnt-exist.tfrc" terraform plan | |
2023-02-08T17:12:43.804Z [INFO] Terraform version: 1.3.5 dev | |
2023-02-08T17:12:43.804Z [DEBUG] using github.com/hashicorp/go-tfe v1.9.0 | |
2023-02-08T17:12:43.804Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.15.0 | |
2023-02-08T17:12:43.804Z [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 |
After step 1:
"resources": [
{
"mode": "managed",
"type": "google_clouddeploy_target",
"name": "default",
"provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
"instances": [
provider "google" { | |
project = var.gcp_project_id | |
region = var.default_region | |
zone = var.default_zone | |
} | |
variable "gcp_project_id" { | |
type = string | |
} | |
variable "default_region" { |
2022-08-11T09:06:19.958+0100 [INFO] Terraform version: 1.2.5 | |
2022-08-11T09:06:19.958+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.0.0 | |
2022-08-11T09:06:19.958+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.12.0 | |
2022-08-11T09:06:19.958+0100 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 | |
2022-08-11T09:06:19.958+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 | |
2022-08-11T09:06:19.958+0100 [DEBUG] using github.com/zclconf/go-cty v1.10.0 | |
2022-08-11T09:06:19.958+0100 [INFO] Go runtime version: go1.18.3 | |
2022-08-11T09:06:19.958+0100 [INFO] CLI args: []string{"terraform", "apply"} | |
2022-08-11T09:06:19.958+0100 [DEBUG] Attempting to open CLI config file: /Users/sarahfrench/.terraformrc | |
2022-08-11T09:06:19.958+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. |
2022-08-11T09:04:09.450+0100 [INFO] Terraform version: 1.2.5 | |
2022-08-11T09:04:09.451+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.0.0 | |
2022-08-11T09:04:09.451+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.12.0 | |
2022-08-11T09:04:09.451+0100 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2 | |
2022-08-11T09:04:09.451+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 | |
2022-08-11T09:04:09.451+0100 [DEBUG] using github.com/zclconf/go-cty v1.10.0 | |
2022-08-11T09:04:09.451+0100 [INFO] Go runtime version: go1.18.3 | |
2022-08-11T09:04:09.451+0100 [INFO] CLI args: []string{"terraform", "apply"} | |
2022-08-11T09:04:09.451+0100 [DEBUG] Attempting to open CLI config file: /Users/sarahfrench/.terraformrc | |
2022-08-11T09:04:09.451+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. |