diff --git a/mmv1/products/compute/ansible.yaml b/mmv1/products/compute/ansible.yaml index 20efe31ead52..7c6e59892754 100644 --- a/mmv1/products/compute/ansible.yaml +++ b/mmv1/products/compute/ansible.yaml @@ -284,6 +284,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides InterconnectAttachment: !ruby/object:Overrides::Ansible::ResourceOverride tests: !ruby/object:Provider::Ansible::Tests has_autogenerated_test: false + NodeGroup: !ruby/object:Overrides::Ansible::ResourceOverride + properties: + size: !ruby/object:Overrides::Ansible::PropertyOverride + required: true + initialSize: !ruby/object:Overrides::Ansible::PropertyOverride + exclude: true RegionDisk: !ruby/object:Overrides::Ansible::ResourceOverride properties: sourceSnapshotEncryptionKey: !ruby/object:Overrides::Ansible::PropertyOverride diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index 7385e8abad6c..5f679a8c15cd 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -8396,8 +8396,16 @@ objects: name: 'size' description: | The total number of nodes in the node group. - required: true + input: true send_empty_value: true + - !ruby/object:Api::Type::Integer + name: 'initialSize' + description: | + The initial number of nodes in the node group. One of `initial_size` or `size` must be specified. + url_param_only: true + exactly_one_of: + - size + - initial_size - !ruby/object:Api::Type::String name: 'maintenancePolicy' description: | diff --git a/mmv1/products/compute/inspec.yaml b/mmv1/products/compute/inspec.yaml index f1b8cbd3753a..5c3418615289 100644 --- a/mmv1/products/compute/inspec.yaml +++ b/mmv1/products/compute/inspec.yaml @@ -116,6 +116,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides exclude: true NetworkPeeringRoutesConfig: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true + NodeGroup: !ruby/object:Overrides::Inspec::ResourceOverride + properties: + size: !ruby/object:Overrides::Inspec::PropertyOverride + required: true + initialSize: !ruby/object:Overrides::Inspec::PropertyOverride + exclude: true OrganizationSecurityPolicy: !ruby/object:Overrides::Inspec::ResourceOverride exclude: true OrganizationSecurityPolicyAssociation: !ruby/object:Overrides::Inspec::ResourceOverride diff --git a/mmv1/products/compute/terraform.yaml b/mmv1/products/compute/terraform.yaml index e51c3e465e42..bb7cd28481c3 100644 --- a/mmv1/products/compute/terraform.yaml +++ b/mmv1/products/compute/terraform.yaml @@ -1327,6 +1327,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_code: !ruby/object:Provider::Terraform::CustomCode encoder: 'templates/terraform/encoders/network_peering_routes_config.go.erb' NodeGroup: !ruby/object:Overrides::Terraform::ResourceOverride + create_url: projects/{{project}}/zones/{{zone}}/nodeGroups?initialNodeCount=PRE_CREATE_REPLACE_ME docs: !ruby/object:Provider::Terraform::Docs warning: | Due to limitations of the API, Terraform cannot update the @@ -1351,6 +1352,13 @@ overrides: !ruby/object:Overrides::ResourceOverrides required: false default_from_api: true custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb' + size: !ruby/object:Overrides::Terraform::PropertyOverride + default_from_api: true + description: | + The total number of nodes in the node group. One of `initial_size` or `size` must be specified. + exactly_one_of: + - size + - initial_size autoscalingPolicy: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true autoscalingPolicy.mode: !ruby/object:Overrides::Terraform::PropertyOverride @@ -1359,6 +1367,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides default_from_api: true autoscalingPolicy.maxNodes: !ruby/object:Overrides::Terraform::PropertyOverride default_from_api: true + custom_code: !ruby/object:Provider::Terraform::CustomCode + pre_create: templates/terraform/pre_create/compute_node_group_url_replace.go.erb NodeTemplate: !ruby/object:Overrides::Terraform::ResourceOverride examples: - !ruby/object:Provider::Terraform::Examples diff --git a/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb b/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb index a023cd40cf20..e552ec74eea4 100644 --- a/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb +++ b/mmv1/templates/terraform/examples/node_group_autoscaling_policy.tf.erb @@ -12,7 +12,7 @@ resource "google_compute_node_group" "<%= ctx[:primary_resource_id] %>" { maintenance_window { start_time = "08:00" } - size = 1 + initial_size = 1 node_template = google_compute_node_template.soletenant-tmpl.id autoscaling_policy { mode = "ONLY_SCALE_OUT" diff --git a/mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb b/mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb new file mode 100644 index 000000000000..62e4828bb500 --- /dev/null +++ b/mmv1/templates/terraform/pre_create/compute_node_group_url_replace.go.erb @@ -0,0 +1,8 @@ +var sizeParam string +if v, ok := d.GetOkExists("size"); ok { + sizeParam = fmt.Sprintf("%v", v) +} else if v, ok := d.GetOkExists("initial_size"); ok { + sizeParam = fmt.Sprintf("%v", v) +} + +url = regexp.MustCompile("PRE_CREATE_REPLACE_ME").ReplaceAllLiteralString(url, sizeParam)