|
| 1 | +# Copyright 2023 Google Inc. |
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | +# you may not use this file except in compliance with the License. |
| 4 | +# You may obtain a copy of the License at |
| 5 | +# |
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +# |
| 8 | +# Unless required by applicable law or agreed to in writing, software |
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +# See the License for the specific language governing permissions and |
| 12 | +# limitations under the License. |
| 13 | + |
| 14 | +--- !ruby/object:Api::Resource |
| 15 | +name: 'RouterNatAddress' |
| 16 | +base_url: projects/{{project}}/regions/{{region}}/routers/{{router}} |
| 17 | +self_link: projects/{{project}}/regions/{{region}}/routers/{{router}} |
| 18 | +create_url: projects/{{project}}/regions/{{region}}/routers/{{router}} |
| 19 | +update_url: projects/{{project}}/regions/{{region}}/routers/{{router}} |
| 20 | +delete_url: projects/{{project}}/regions/{{region}}/routers/{{router}} |
| 21 | +create_verb: :PATCH |
| 22 | +update_verb: :PATCH |
| 23 | +delete_verb: :PATCH |
| 24 | +identity: |
| 25 | + - routerNat |
| 26 | +collection_url_key: nats |
| 27 | +nested_query: !ruby/object:Api::Resource::NestedQuery |
| 28 | + modify_by_patch: true |
| 29 | + keys: |
| 30 | + - nats |
| 31 | +description: | |
| 32 | + A resource used to set the list of IP addresses to be used in a NAT service and manage the draining of destroyed IPs. |
| 33 | +
|
| 34 | + ~> **Note:** This resource is to be used alongside a `google_compute_router_nat` resource, |
| 35 | + the router nat resource must have no defined `nat_ips` or `drain_nat_ips` parameters, |
| 36 | + instead using the `initial_nat_ips` parameter to set at least one IP for the creation of the resource. |
| 37 | +references: !ruby/object:Api::Resource::ReferenceLinks |
| 38 | + guides: |
| 39 | + 'Google Cloud Router': 'https://cloud.google.com/router/docs/' |
| 40 | + api: 'https://cloud.google.com/compute/docs/reference/rest/v1/routers' |
| 41 | +async: !ruby/object:Api::OpAsync |
| 42 | + operation: !ruby/object:Api::OpAsync::Operation |
| 43 | + kind: 'compute#operation' |
| 44 | + path: 'routerNat' |
| 45 | + base_url: 'projects/{{project}}/regions/{{regions}}/operations/{{op_id}}' |
| 46 | + wait_ms: 1000 |
| 47 | + result: !ruby/object:Api::OpAsync::Result |
| 48 | + path: 'targetLink' |
| 49 | + status: !ruby/object:Api::OpAsync::Status |
| 50 | + path: 'status' |
| 51 | + complete: 'DONE' |
| 52 | + allowed: |
| 53 | + - 'PENDING' |
| 54 | + - 'RUNNING' |
| 55 | + - 'DONE' |
| 56 | + error: !ruby/object:Api::OpAsync::Error |
| 57 | + path: 'error/errors' |
| 58 | + message: 'message' |
| 59 | +exclude_tgc: true |
| 60 | +id_format: 'projects/{{project}}/regions/{{region}}/routers/{{router}}/{{router_nat}}' |
| 61 | +mutex: router/{{region}}/{{router}} |
| 62 | +examples: |
| 63 | + - !ruby/object:Provider::Terraform::Examples |
| 64 | + name: 'router_nat_address_count' |
| 65 | + primary_resource_id: 'nat_address' |
| 66 | + skip_test: true |
| 67 | + vars: |
| 68 | + router_name: 'my-router' |
| 69 | + nat_name: 'my-router-nat' |
| 70 | + network_name: 'my-network' |
| 71 | + subnet_name: 'my-subnetwork' |
| 72 | + address_name: 'nat-manual-ip' |
| 73 | +# ToDo: We use a custom code for CREATE since the generated code is erroneously not replacing the generated encoder with the custom one provided |
| 74 | +custom_code: !ruby/object:Provider::Terraform::CustomCode |
| 75 | + constants: 'templates/terraform/constants/router_nat_address.go.erb' |
| 76 | + custom_create: templates/terraform/custom_create/router_nat_address_nested_query_create_encoder.go.erb |
| 77 | + pre_delete: templates/terraform/pre_delete/compute_router_nat_address_delete_nat_ips_only.go.erb |
| 78 | + encoder: 'templates/terraform/encoders/router_nat_address_patch_on_create.go.erb' |
| 79 | + update_encoder: 'templates/terraform/encoders/router_nat_address_update_skip_encoder.go.erb' |
| 80 | +custom_diff: [ |
| 81 | + 'resourceComputeRouterNatAddressDrainNatIpsCustomDiff', |
| 82 | +] |
| 83 | +parameters: |
| 84 | + - !ruby/object:Api::Type::ResourceRef |
| 85 | + name: 'router' |
| 86 | + resource: 'Router' |
| 87 | + imports: 'name' |
| 88 | + description: | |
| 89 | + The name of the Cloud Router in which the referenced NAT service is configured. |
| 90 | + required: true |
| 91 | + immutable: true |
| 92 | + url_param_only: true |
| 93 | + - !ruby/object:Api::Type::ResourceRef |
| 94 | + name: 'routerNat' |
| 95 | + resource: 'RouterNat' |
| 96 | + imports: 'name' |
| 97 | + api_name: 'name' |
| 98 | + description: | |
| 99 | + The name of the Nat service in which this address will be configured. |
| 100 | + required: true |
| 101 | + immutable: true |
| 102 | + - !ruby/object:Api::Type::ResourceRef |
| 103 | + name: region |
| 104 | + resource: Region |
| 105 | + imports: name |
| 106 | + description: Region where the NAT service reside. |
| 107 | + immutable: true |
| 108 | + required: false |
| 109 | + url_param_only: true |
| 110 | + default_from_api: true |
| 111 | + custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb' |
| 112 | +properties: |
| 113 | + - !ruby/object:Api::Type::Array |
| 114 | + name: 'natIps' |
| 115 | + description: | |
| 116 | + Self-links of NAT IPs to be used in a Nat service. Only valid if the referenced RouterNat |
| 117 | + natIpAllocateOption is set to MANUAL_ONLY. |
| 118 | + send_empty_value: true |
| 119 | + required: true |
| 120 | + is_set: true |
| 121 | + set_hash_func: computeRouterNatIPsHash |
| 122 | + item_type: !ruby/object:Api::Type::ResourceRef |
| 123 | + name: 'address' |
| 124 | + resource: 'Address' |
| 125 | + imports: 'selfLink' |
| 126 | + description: 'A reference to an address to be associated with this NAT' |
| 127 | + custom_expand: 'templates/terraform/custom_expand/array_resourceref_with_validation.go.erb' |
| 128 | + - !ruby/object:Api::Type::Array |
| 129 | + name: 'drainNatIps' |
| 130 | + description: | |
| 131 | + A list of URLs of the IP resources to be drained. These IPs must be |
| 132 | + valid static external IPs that have been assigned to the NAT. |
| 133 | + send_empty_value: true |
| 134 | + is_set: true |
| 135 | + item_type: !ruby/object:Api::Type::ResourceRef |
| 136 | + name: 'address' |
| 137 | + resource: 'Address' |
| 138 | + imports: 'selfLink' |
| 139 | + description: 'A reference to an address associated with this NAT' |
| 140 | + custom_expand: 'templates/terraform/custom_expand/array_resourceref_with_validation.go.erb' |
0 commit comments