Last active
September 22, 2023 17:03
-
-
Save alexjmoore/0bfb62718f872e6fb72e73dedda2ca3e to your computer and use it in GitHub Desktop.
Tag binding issue example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
project_id = "{{YOUR PROJECT ID}}" | |
region = "europe-west2" | |
zone = "europe-west2-a" | |
} | |
provider "google" { | |
project = local.project_id | |
region = local.region | |
zone = local.zone | |
} | |
data "google_project" "project" { | |
} | |
resource "google_tags_tag_key" "key" { | |
description = "Example key" | |
parent = "projects/${local.project_id}" | |
purpose = "GCE_FIREWALL" | |
short_name = "example-key" | |
purpose_data = { | |
network = "${local.project_id}/${google_compute_network.network.name}" | |
} | |
} | |
resource "google_tags_tag_value" "value" { | |
parent = google_tags_tag_key.key.id | |
short_name = "example" | |
description = "Example value" | |
} | |
resource "google_tags_location_tag_binding" "binding" { | |
parent = "//compute.googleapis.com/projects/${data.google_project.project.number}/zones/${google_compute_instance.vm.zone}/instances/${google_compute_instance.vm.instance_id}" | |
tag_value = google_tags_tag_value.value.id | |
location = local.zone | |
} | |
resource "google_compute_instance" "vm" { | |
name = "my-vm" | |
machine_type = "e2-standard-2" | |
zone = local.zone | |
network_interface { | |
subnetwork = google_compute_subnetwork.subnet.id | |
} | |
shielded_instance_config { | |
enable_secure_boot = true | |
} | |
boot_disk { | |
initialize_params { | |
image = "debian-cloud/debian-10" | |
} | |
} | |
} | |
resource "google_compute_network" "network" { | |
name = "my-vpc" | |
auto_create_subnetworks = false | |
} | |
resource "google_compute_subnetwork" "subnet" { | |
name = "my-subnet" | |
network = google_compute_network.network.id | |
ip_cidr_range = "10.0.0.0/24" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment