diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index ca5ad9da961b..0fcdf7e15b80 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -2748,7 +2748,7 @@ objects: name: 'idleTimeoutSec' description: | Specifies how long to keep a Connection Tracking entry while there is - no matching traffic (in seconds). + no matching traffic (in seconds). For L4 ILB the minimum(default) is 10 minutes and maximum is 16 hours. @@ -2759,7 +2759,7 @@ objects: Specifies the key used for connection tracking. There are two options: `PER_CONNECTION`: The Connection Tracking is performed as per the Connection Key (default Hash Method) for the specific protocol. - + `PER_SESSION`: The Connection Tracking is performed as per the configured Session Affinity. It matches the configured Session Affinity. default_value: :PER_CONNECTION @@ -14214,6 +14214,32 @@ objects: output: true description: | The status of the reservation. + - !ruby/object:Api::Type::NestedObject + name: 'shareSettings' + description: | + The share setting for reservations. + properties: + - !ruby/object:Api::Type::Enum + name: 'shareType' + values: + - :LOCAL + - :SPECIFIC_PROJECTS + description: | + Type of sharing for this shared-reservation + - !ruby/object:Api::Type::Map + name: 'projectMap' + description: | + A map of project number and project config. This is only valid when shareType's value is SPECIFIC_PROJECTS. + key_name: id + key_description: | + The project id/number which is deleting or adding to the project list. Only project number is acceptable. + value_type: !ruby/object:Api::Type::NestedObject + name: projectConfig + properties: + - !ruby/object:Api::Type::String + name: 'projectId' + description: | + The project id/number, should be same as the key of this project config in the project map. - !ruby/object:Api::Type::NestedObject name: 'specificReservation' required: true @@ -14656,7 +14682,7 @@ objects: description: | The purpose of the resource. A subnetwork with purpose set to INTERNAL_HTTPS_LOAD_BALANCER is a user-created subnetwork that is - reserved for Internal HTTP(S) Load Balancing. + reserved for Internal HTTP(S) Load Balancing. If set to INTERNAL_HTTPS_LOAD_BALANCER you must also set the `role` field. - !ruby/object:Api::Type::Enum diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index 24316c37f671..328e606c287e 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -2237,6 +2237,18 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_id: "gce_reservation" vars: reservation_name: "gce-reservation" + - !ruby/object:Provider::Terraform::Examples + name: "shared_reservation_basic" + primary_resource_id: "gce_reservation" + test_env_vars: + project: :PROJECT_NAME + org_id: :ORG_ID + billing_account: :BILLING_ACCT + vars: + reservation_name: "gce-shared-reservation" + skip_docs: true + # Resource creation race + skip_vcr: true custom_code: !ruby/object:Provider::Terraform::CustomCode update_encoder: templates/terraform/update_encoder/reservation.go.erb properties: @@ -2247,6 +2259,17 @@ overrides: !ruby/object:Overrides::ResourceOverrides specificReservation.count: !ruby/object:Overrides::Terraform::PropertyOverride validation: !ruby/object:Provider::Terraform::Validation function: 'validation.IntAtLeast(1)' + shareSettings: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true + ignore_read: true + shareSettings.shareType: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true + shareSettings.projectMap: !ruby/object:Overrides::Terraform::PropertyOverride + key_description: | + The project id/number which is deleting or adding to the project list. + shareSettings.projectMap.projectId: !ruby/object:Overrides::Terraform::PropertyOverride + description: | + The project id/number, should be same as the key of this project config in the project map. Route: !ruby/object:Overrides::Terraform::ResourceOverride # Route cannot be added while a peering is on progress on the network mutex: 'projects/{{project}}/global/networks/{{network}}/peerings' diff --git a/mmv1/templates/terraform/examples/shared_reservation_basic.tf.erb b/mmv1/templates/terraform/examples/shared_reservation_basic.tf.erb new file mode 100644 index 000000000000..5980471808c0 --- /dev/null +++ b/mmv1/templates/terraform/examples/shared_reservation_basic.tf.erb @@ -0,0 +1,51 @@ +resource "google_project" "owner_project" { + project_id = "tf-test%{random_suffix}" + name = "tf-test%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + billing_account = "<%= ctx[:test_env_vars]['billing_account'] %>" +} + + +resource "google_project_service" "compute" { + project = google_project.owner_project.project_id + service = "compute.googleapis.com" + disable_on_destroy = false +} + +resource "google_project" "guest_project" { + project_id = "tf-test-2%{random_suffix}" + name = "tf-test-2%{random_suffix}" + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" +} + +resource "google_organization_policy" "shared_reservation_org_policy" { + org_id = "<%= ctx[:test_env_vars]['org_id'] %>" + constraint = "constraints/compute.sharedReservationsOwnerProjects" + list_policy { + allow { + values = ["projects/${google_project.owner_project.number}"] + } + } +} + +resource "google_compute_reservation" "<%= ctx[:primary_resource_id] %>" { + project = google_project.owner_project.project_id + name = "<%= ctx[:vars]['reservation_name'] %>" + zone = "us-central1-a" + + specific_reservation { + count = 1 + instance_properties { + min_cpu_platform = "Intel Cascade Lake" + machine_type = "n2-standard-2" + } + } + share_settings { + share_type = "SPECIFIC_PROJECTS" + project_map { + id = google_project.guest_project.project_id + project_id = google_project.guest_project.project_id + } + } + depends_on = [google_organization_policy.shared_reservation_org_policy,google_project_service.compute] +} \ No newline at end of file diff --git a/mmv1/templates/terraform/update_encoder/reservation.go.erb b/mmv1/templates/terraform/update_encoder/reservation.go.erb index 4460c69fb67d..7fffbe00d02f 100644 --- a/mmv1/templates/terraform/update_encoder/reservation.go.erb +++ b/mmv1/templates/terraform/update_encoder/reservation.go.erb @@ -15,4 +15,4 @@ newObj := make(map[string]interface{}) newObj["specificSkuCount"] = obj["specificReservation"].(map[string]interface{})["count"] -return newObj, nil +return newObj, nil \ No newline at end of file diff --git a/mmv1/third_party/terraform/tests/resource_compute_instance_test.go.erb b/mmv1/third_party/terraform/tests/resource_compute_instance_test.go.erb index f96e8354747d..98efeb3e4df2 100644 --- a/mmv1/third_party/terraform/tests/resource_compute_instance_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_compute_instance_test.go.erb @@ -5691,7 +5691,6 @@ resource "google_compute_reservation" "reservation" { machine_type = "n1-standard-1" } } - specific_reservation_required = true }