diff --git a/products/compute/api.yaml b/products/compute/api.yaml index 965a0ba06647..5ca0b17e0029 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -1088,6 +1088,48 @@ objects: description: | A reference to the region where the regional address resides. output: true + - !ruby/object:Api::Type::Integer + name: 'prefixLength' + description: | + The prefix length of the IP range. If not present, it means the + address field is a single IP address. + + This field is not applicable to addresses with addressType=EXTERNAL. + min_version: beta + - !ruby/object:Api::Type::Enum + name: 'addressType' + description: | + The type of the address to reserve, default is EXTERNAL. + + * EXTERNAL indicates public/external single IP address. + * INTERNAL indicates internal IP ranges belonging to some network. + values: + - :EXTERNAL + - :INTERNAL + default_value: :EXTERNAL + min_version: beta + - !ruby/object:Api::Type::Enum + name: 'purpose' + description: | + The purpose of the resource. For global internal addresses it can be + + * VPC_PEERING - for peer networks + + This should only be set when using an Internal address. + values: + - :VPC_PEERING + min_version: beta + - !ruby/object:Api::Type::ResourceRef + name: 'network' + resource: 'Network' + imports: 'selfLink' + description: | + The URL of the network in which to reserve the IP range. The IP range + must be in RFC1918 space. The network cannot be deleted if there are + any reserved IP ranges referring to it. + + This should only be set when using an Internal address. + min_version: beta # status is not useful for state convergence # users[] is not useful for state convergence - !ruby/object:Api::Resource diff --git a/products/compute/terraform.yaml b/products/compute/terraform.yaml index 0cbbd95ede35..04d08f88a296 100644 --- a/products/compute/terraform.yaml +++ b/products/compute/terraform.yaml @@ -348,6 +348,8 @@ overrides: !ruby/object:Provider::ResourceOverrides exclude: false region: !ruby/object:Provider::Terraform::PropertyOverride exclude: true + addressType: !ruby/object:Provider::Terraform::PropertyOverride + diff_suppress_func: 'emptyOrDefaultStringSuppress("EXTERNAL")' custom_code: !ruby/object:Provider::Terraform::CustomCode post_create: templates/terraform/post_create/labels.erb GlobalForwardingRule: !ruby/object:Provider::Terraform::ResourceOverride diff --git a/templates/terraform/tests/resource_compute_global_address_test.go b/templates/terraform/tests/resource_compute_global_address_test.go index c93d724c3cac..7d78c2ce633e 100644 --- a/templates/terraform/tests/resource_compute_global_address_test.go +++ b/templates/terraform/tests/resource_compute_global_address_test.go @@ -67,6 +67,26 @@ func TestAccComputeGlobalAddress_ipv6(t *testing.T) { }) } +func TestAccComputeGlobalAddress_internal(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeGlobalAddressDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccComputeGlobalAddress_internal(), + }, + resource.TestStep{ + ResourceName: "google_compute_global_address.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckComputeGlobalAddressDestroy(s *terraform.State) error { config := testAccProvider.Meta().(*Config) @@ -156,3 +176,19 @@ resource "google_compute_global_address" "foobar" { ip_version = "IPV6" }`, acctest.RandString(10)) } + +func testAccComputeGlobalAddress_internal() string { + return fmt.Sprintf(` +resource "google_compute_network" "foobar" { + name = "address-test-%s" +} + + +resource "google_compute_global_address" "foobar" { + name = "address-test-%s" + address_type = "INTERNAL" + purpose = "VPC_PEERING" + prefix_length = 24 + network = "${google_compute_network.foobar.self_link}" +}`, acctest.RandString(10), acctest.RandString(10)) +}