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

Add supported values for 'peeringCidrRange' on 'google_apigee_instance' resource #10636

Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .changelog/5472.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Google Apigee Instance: Add supported values for 'peeringCidrRange'.
```
11 changes: 5 additions & 6 deletions google/resource_apigee_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

func resourceApigeeInstance() *schema.Resource {
Expand Down Expand Up @@ -82,11 +81,11 @@ Use the following format: 'projects/([^/]+)/locations/([^/]+)/keyRings/([^/]+)/c
Description: `Display name of the instance.`,
},
"peering_cidr_range": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"SLASH_16", "SLASH_20", "SLASH_22", ""}, false),
Description: `The size of the CIDR block range that will be reserved by the instance. Possible values: ["SLASH_16", "SLASH_20", "SLASH_22"]`,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `The size of the CIDR block range that will be reserved by the instance. For valid values,
see [CidrRange](https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.instances#CidrRange) on the documentation.`,
},
"host": {
Type: schema.TypeString,
Expand Down
93 changes: 93 additions & 0 deletions google/resource_apigee_instance_generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,99 @@ resource "google_apigee_instance" "apigee_instance" {
`, context)
}

func TestAccApigeeInstance_apigeeInstanceCidrRangeTestExample(t *testing.T) {
skipIfVcr(t)
t.Parallel()

context := map[string]interface{}{
"org_id": getTestOrgFromEnv(t),
"billing_account": getTestBillingAccountFromEnv(t),
"random_suffix": randString(t, 10),
}

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckApigeeInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccApigeeInstance_apigeeInstanceCidrRangeTestExample(context),
},
{
ResourceName: "google_apigee_instance.apigee_instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"org_id"},
},
},
})
}

func testAccApigeeInstance_apigeeInstanceCidrRangeTestExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_project" "project" {
project_id = "tf-test%{random_suffix}"
name = "tf-test%{random_suffix}"
org_id = "%{org_id}"
billing_account = "%{billing_account}"
}

resource "google_project_service" "apigee" {
project = google_project.project.project_id
service = "apigee.googleapis.com"
}

resource "google_project_service" "compute" {
project = google_project.project.project_id
service = "compute.googleapis.com"
}

resource "google_project_service" "servicenetworking" {
project = google_project.project.project_id
service = "servicenetworking.googleapis.com"
}

resource "google_compute_network" "apigee_network" {
name = "apigee-network"
project = google_project.project.project_id
depends_on = [google_project_service.compute]
}

resource "google_compute_global_address" "apigee_range" {
name = "apigee-range"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 22
network = google_compute_network.apigee_network.id
project = google_project.project.project_id
}

resource "google_service_networking_connection" "apigee_vpc_connection" {
network = google_compute_network.apigee_network.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.apigee_range.name]
depends_on = [google_project_service.servicenetworking]
}

resource "google_apigee_organization" "apigee_org" {
analytics_region = "us-central1"
project_id = google_project.project.project_id
authorized_network = google_compute_network.apigee_network.id
depends_on = [
google_service_networking_connection.apigee_vpc_connection,
google_project_service.apigee,
]
}

resource "google_apigee_instance" "apigee_instance" {
name = "tf-test%{random_suffix}"
location = "us-central1"
org_id = google_apigee_organization.apigee_org.id
peering_cidr_range = "SLASH_22"
}
`, context)
}

func testAccCheckApigeeInstanceDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
Expand Down
42 changes: 40 additions & 2 deletions website/docs/r/apigee_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,44 @@ resource "google_apigee_instance" "apigee_instance" {
org_id = google_apigee_organization.apigee_org.id
}
```
## Example Usage - Apigee Instance Cidr Range


```hcl
data "google_client_config" "current" {}

resource "google_compute_network" "apigee_network" {
name = "apigee-network"
}

resource "google_compute_global_address" "apigee_range" {
name = "apigee-range"
purpose = "VPC_PEERING"
address_type = "INTERNAL"
prefix_length = 22
network = google_compute_network.apigee_network.id
}

resource "google_service_networking_connection" "apigee_vpc_connection" {
network = google_compute_network.apigee_network.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.apigee_range.name]
}

resource "google_apigee_organization" "apigee_org" {
analytics_region = "us-central1"
project_id = data.google_client_config.current.project
authorized_network = google_compute_network.apigee_network.id
depends_on = [google_service_networking_connection.apigee_vpc_connection]
}

resource "google_apigee_instance" "apigee_instance" {
name = "tf-test%{random_suffix}"
location = "us-central1-b"
org_id = google_apigee_organization.apigee_org.id
peering_cidr_range = "SLASH_22"
}
```
## Example Usage - Apigee Instance Full


Expand Down Expand Up @@ -171,8 +209,8 @@ The following arguments are supported:

* `peering_cidr_range` -
(Optional)
The size of the CIDR block range that will be reserved by the instance.
Possible values are `SLASH_16`, `SLASH_20`, and `SLASH_22`.
The size of the CIDR block range that will be reserved by the instance. For valid values,
see [CidrRange](https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.instances#CidrRange) on the documentation.

* `description` -
(Optional)
Expand Down