Skip to content

Instantly share code, notes, and snippets.

View SarahFrench's full-sized avatar
💭
PTO, I won't respond to @ mentions

Sarah French SarahFrench

💭
PTO, I won't respond to @ mentions
View GitHub Profile
@SarahFrench
SarahFrench / ec2_self_tagging.sh
Created May 29, 2024 15:24 — forked from pahud/ec2_self_tagging.sh
EC2 tag itself on instance launch with UserData
#!/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
@SarahFrench
SarahFrench / tf-cli-config-tilde-path.txt
Created February 8, 2023 17:20
In this example, `TF_CLI_CONFIG_FILE` is set to point at an existing file but it's using `~`
$ 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
@SarahFrench
SarahFrench / tf-cli-config-correct-path.txt
Created February 8, 2023 17:18
In this example, `TF_CLI_CONFIG_FILE` is set to point at an existing file
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
@SarahFrench
SarahFrench / tf-cli-config-incorrect-path.txt
Last active February 8, 2023 17:18
In this example, `TF_CLI_CONFIG_FILE` is set to point at a non-existant file
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

Terraform configurations ranging from implicit to (more) explicit

Directory contents

For all the below, the directory before running terraform init contains only main.tf

my-terraform-project/
├─ main.tf

After step 1:

  "resources": [
    {
      "mode": "managed",
      "type": "google_clouddeploy_target",
      "name": "default",
      "provider": "provider[\"registry.terraform.io/hashicorp/google\"]",
      "instances": [
@SarahFrench
SarahFrench / clouddeploy-target-issue.tf
Created August 11, 2022 08:15
TF configuration for Cloud Deploy issue test
provider "google" {
project = var.gcp_project_id
region = var.default_region
zone = var.default_zone
}
variable "gcp_project_id" {
type = string
}
variable "default_region" {
@SarahFrench
SarahFrench / update-clouddeploy-target-remove-SA.txt
Last active August 11, 2022 08:53
Terraform apply step that updates an existing `google_clouddeploy_target` resource to unset the `execution_configs.service_account` argument in the config
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.
@SarahFrench
SarahFrench / create-clouddeploy-target-with-SA.txt
Last active August 11, 2022 08:54
Terraform apply step that creates a `google_clouddeploy_target` resource with the `execution_configs.service_account` argument set in the config
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.
@SarahFrench
SarahFrench / tf-registry-override-automatic-hyperlinks.md
Last active July 26, 2022 12:47
Example markdown file to put in the Terraform Registry's Doc-Preview tool (https://registry.terraform.io/tools/doc-preview)