// ---------------------------------------------------------------------------- // // *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** // // ---------------------------------------------------------------------------- // // This file is automatically generated by Magic Modules and manual // changes will be clobbered when the file is regenerated. // // Please read more about how to change this file in // .github/CONTRIBUTING.md. // // ---------------------------------------------------------------------------- package google import ( "fmt" "testing" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" ) func TestAccComputeAddress_AddressBasicExample(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckComputeAddressDestroy, Steps: []resource.TestStep{ { Config: testAccComputeAddress_AddressBasicExample(acctest.RandString(10)), }, { ResourceName: "google_compute_address.ip_address", ImportState: true, ImportStateVerify: true, }, }, }) } func testAccComputeAddress_AddressBasicExample(val string) string { return fmt.Sprintf(` resource "google_compute_address" "ip_address" { name = "my-address-%s" } `, val, ) } func TestAccComputeAddress_AddressWithSubnetworkExample(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckComputeAddressDestroy, Steps: []resource.TestStep{ { Config: testAccComputeAddress_AddressWithSubnetworkExample(acctest.RandString(10)), }, { ResourceName: "google_compute_address.internal_with_subnet_and_address", ImportState: true, ImportStateVerify: true, }, }, }) } func testAccComputeAddress_AddressWithSubnetworkExample(val string) string { return fmt.Sprintf(` resource "google_compute_network" "default" { name = "my-network-%s" } resource "google_compute_subnetwork" "default" { name = "my-subnet-%s" ip_cidr_range = "10.0.0.0/16" region = "us-central1" network = "${google_compute_network.default.self_link}" } resource "google_compute_address" "internal_with_subnet_and_address" { name = "my-internal-address-%s" subnetwork = "${google_compute_subnetwork.default.self_link}" address_type = "INTERNAL" address = "10.0.42.42" region = "us-central1" } `, val, val, val, ) } func TestAccComputeAddress_InstanceWithIpExample(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckComputeAddressDestroy, Steps: []resource.TestStep{ { Config: testAccComputeAddress_InstanceWithIpExample(acctest.RandString(10)), }, { ResourceName: "google_compute_address.static", ImportState: true, ImportStateVerify: true, }, }, }) } func testAccComputeAddress_InstanceWithIpExample(val string) string { return fmt.Sprintf(` resource "google_compute_address" "static" { name = "ipv4-address-%s" } data "google_compute_image" "debian_image" { family = "debian-9" project = "debian-cloud" } resource "google_compute_instance" "instance_with_ip" { name = "vm-instance-%s" machine_type = "f1-micro" zone = "us-central1-a" boot_disk { initialize_params{ image = "${data.google_compute_image.debian_image.self_link}" } } network_interface { network = "default" access_config { nat_ip = "${google_compute_address.static.address}" } } } `, val, val, ) }