User Tools

Site Tools


lession_terraform_gcp_dual_stack

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

lession_terraform_gcp_dual_stack [2025/07/26 17:09] – - Imported by DokuWiki Advanced Plugin wikiadmlession_terraform_gcp_dual_stack [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== Lição dual stack CGP ====== 
-<file tf provider.tf> 
-$ vim provider.tf 
-terraform { 
-  required_providers { 
-    google = { 
-      source  = "hashicorp/google" 
-      version = "4.51.0" 
-    } 
-  } 
-} 
  
-provider "google" { 
-  credentials = "/home/gean/gcp/svc-account/singular-carver-376919-f09b67c64df6.json" 
-  project     = "singular-carver-376919" 
-  region      = "us-central1" 
-} 
-</file> 
- 
-<file tf network.tf> 
-$ vim network.tf 
-resource "google_compute_network" "vpc_network_dual" { 
-  name                     = "vpc-network-dual" 
-  auto_create_subnetworks  = false 
-  enable_ula_internal_ipv6 = true 
-} 
-</file> 
- 
-<file tf subnet.tf> 
-$ vim subnet.tf 
-resource "google_compute_subnetwork" "subnetwork_external_dual" { 
-  name = "subnetwork-external-dual" 
- 
-  ip_cidr_range = "10.0.4.0/22" 
-  region        = "us-central1" 
- 
-  stack_type       = "IPV4_IPV6" 
-  ipv6_access_type = "EXTERNAL" 
- 
-  network = google_compute_network.vpc_network_dual.self_link 
-} 
-</file> 
- 
-<file tf firewall.tf> 
-$ vim firewall.tf 
-resource "google_compute_firewall" "allow-icmp-ssh-ipv4" { 
-  name    = "allow-icmp-ssh-ipv4" 
-  network = google_compute_network.vpc_network_dual.self_link 
- 
-  allow { 
-    protocol = "icmp" 
-  } 
- 
-  allow { 
-    protocol = "tcp" 
-    ports    = ["22"] 
-  } 
- 
-  source_ranges = ["0.0.0.0/0"] 
-} 
- 
-resource "google_compute_firewall" "allow-ssh-icmp-ipv6" { 
-  name    = "allow-ssh-icmp-ipv6" 
-  network = google_compute_network.vpc_network_dual.self_link 
- 
-  allow { 
-    protocol = "tcp" 
-    ports    = ["22"] 
-  } 
- 
-  allow { 
-    protocol = "58" /* ipv6-icmp */ 
-  } 
- 
-  source_ranges = ["::/0"] 
-} 
-</file> 
- 
-<file tf instance.tf> 
-$ vim instance.tf 
-resource "google_compute_instance" "gcp-vm-01" { 
-  name         = "gcp-vm-01" 
-  machine_type = "e2-small" 
-  zone         = "us-central1-a" 
- 
-  boot_disk { 
-    initialize_params { 
-      image = "debian-cloud/debian-11" 
-    } 
-  } 
- 
-  network_interface { 
-    subnetwork = google_compute_subnetwork.subnetwork_external_dual.self_link 
-    stack_type = "IPV4_IPV6" 
- 
-    access_config { 
-      network_tier = "PREMIUM" 
-    } 
- 
-    ipv6_access_config { 
-      network_tier = "PREMIUM" 
-    } 
- 
-  } 
-  allow_stopping_for_update = true 
-} 
-</file> 
- 
-<code bash> 
-$ terraform fmt 
-$ terraform validate 
-$ terraform plan 
-$ terraform apply -auto-approve 
-$ terraform state list 
-$ terraform show 
-$ terraform destroy -auto-approve 
-</code> 
- 
-===== Referências ===== 
-  - [[https://mihaibojin.medium.com/deploy-and-configure-google-compute-engine-vms-with-terraform-f6b708b226c1|Deploy and configure Google Compute Engine VMs with Terraform]] 
-  - [[https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_subnetwork|google_compute_subnetwork]] 
lession_terraform_gcp_dual_stack.1753560544.txt.gz · Last modified: by wikiadm