Skip to content

Commit

Permalink
Support IP Range Reservation for Global Address.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisst committed Sep 18, 2018
1 parent c2d5a77 commit e47ebfe
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
45 changes: 45 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,51 @@ 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
For regional internal addresses, it can be
* GCE_ENDPOINT - VM internal IP, VM alias IP, Internal LB service IP.
This field is not applicable to external addresses.
values:
- :VPC_PEERING
- :GCE_ENDPOINT
min_version: beta
- !ruby/object:Api::Type::String
name: 'network'
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 can only be specified for a global internal address.
min_version: beta
# status is not useful for state convergence
# users[] is not useful for state convergence
- !ruby/object:Api::Resource
Expand Down
4 changes: 4 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ 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")'
network: !ruby/object:Provider::Terraform::PropertyOverride
diff_suppress_func: 'compareSelfLinkOrResourceName'
custom_code: !ruby/object:Provider::Terraform::CustomCode
post_create: templates/terraform/post_create/labels.erb
GlobalForwardingRule: !ruby/object:Provider::Terraform::ResourceOverride
Expand Down
36 changes: 36 additions & 0 deletions templates/terraform/tests/resource_compute_global_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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))
}

0 comments on commit e47ebfe

Please sign in to comment.