Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support IP Range Reservation for Global Address. #469

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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")'
chrisst marked this conversation as resolved.
Show resolved Hide resolved
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))
}