Skip to content

Commit 7a721c1

Browse files
Add Network Attachment resource (#8688) (#15648)
* first draft for new Network Attachment resource * updated NetworkAttachment specification file * added usage example for Network Attachment with GCE Instance * verified attributes and descriptions * enhanced network attachment examples Signed-off-by: Modular Magician <[email protected]>
1 parent a9cfeea commit 7a721c1

File tree

2 files changed

+212
-0
lines changed

2 files changed

+212
-0
lines changed

.changelog/8688.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
google_compute_network_attachment
3+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This file is automatically generated by Magic Modules and manual
9+
# changes will be clobbered when the file is regenerated.
10+
#
11+
# Please read more about how to change this file in
12+
# .github/CONTRIBUTING.md.
13+
#
14+
# ----------------------------------------------------------------------------
15+
subcategory: "Compute Engine"
16+
description: |-
17+
A network attachment is a resource that lets a producer Virtual Private Cloud (VPC) network initiate connections to a consumer VPC network through a Private Service Connect interface.
18+
---
19+
20+
# google\_compute\_network\_attachment
21+
22+
A network attachment is a resource that lets a producer Virtual Private Cloud (VPC) network initiate connections to a consumer VPC network through a Private Service Connect interface.
23+
24+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
25+
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
26+
27+
To get more information about NetworkAttachment, see:
28+
29+
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/networkAttachments)
30+
* How-to Guides
31+
* [Official Documentation](https://cloud.google.com/vpc/docs/about-network-attachments)
32+
33+
## Example Usage - Network Attachment Basic
34+
35+
36+
```hcl
37+
resource "google_compute_network_attachment" "default" {
38+
provider = google-beta
39+
name = "basic-network-attachment"
40+
region = "us-central1"
41+
description = "basic network attachment description"
42+
connection_preference = "ACCEPT_MANUAL"
43+
44+
subnetworks = [
45+
google_compute_subnetwork.default.self_link
46+
]
47+
48+
producer_accept_lists = [
49+
google_project.accepted_producer_project.project_id
50+
]
51+
52+
producer_reject_lists = [
53+
google_project.rejected_producer_project.project_id
54+
]
55+
}
56+
57+
resource "google_compute_network" "default" {
58+
provider = google-beta
59+
name = "basic-network"
60+
auto_create_subnetworks = false
61+
}
62+
63+
resource "google_compute_subnetwork" "default" {
64+
provider = google-beta
65+
name = "basic-subnetwork"
66+
region = "us-central1"
67+
68+
network = google_compute_network.default.id
69+
ip_cidr_range = "10.0.0.0/16"
70+
}
71+
72+
resource "google_project" "rejected_producer_project" {
73+
provider = google-beta
74+
project_id = "prj-rejected%{random_suffix}"
75+
name = "prj-rejected%{random_suffix}"
76+
org_id = "123456789"
77+
billing_account = "000000-0000000-0000000-000000"
78+
}
79+
80+
resource "google_project" "accepted_producer_project" {
81+
provider = google-beta
82+
project_id = "prj-accepted%{random_suffix}"
83+
name = "prj-accepted%{random_suffix}"
84+
org_id = "123456789"
85+
billing_account = "000000-0000000-0000000-000000"
86+
}
87+
```
88+
89+
## Argument Reference
90+
91+
The following arguments are supported:
92+
93+
94+
* `connection_preference` -
95+
(Required)
96+
The connection preference of service attachment. The value can be set to ACCEPT_AUTOMATIC. An ACCEPT_AUTOMATIC service attachment is one that always accepts the connection from consumer forwarding rules.
97+
Possible values are: `ACCEPT_AUTOMATIC`, `ACCEPT_MANUAL`, `INVALID`.
98+
99+
* `subnetworks` -
100+
(Required)
101+
An array of URLs where each entry is the URL of a subnet provided by the service consumer to use for endpoints in the producers that connect to this network attachment.
102+
103+
* `name` -
104+
(Required)
105+
Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
106+
107+
* `region` -
108+
(Required)
109+
URL of the region where the network attachment resides. This field applies only to the region resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body.
110+
111+
112+
- - -
113+
114+
115+
* `description` -
116+
(Optional)
117+
An optional description of this resource. Provide this property when you create the resource.
118+
119+
* `producer_reject_lists` -
120+
(Optional)
121+
Projects that are not allowed to connect to this network attachment. The project can be specified using its id or number.
122+
123+
* `producer_accept_lists` -
124+
(Optional)
125+
Projects that are allowed to connect to this network attachment. The project can be specified using its id or number.
126+
127+
* `project` - (Optional) The ID of the project in which the resource belongs.
128+
If it is not provided, the provider project is used.
129+
130+
131+
## Attributes Reference
132+
133+
In addition to the arguments listed above, the following computed attributes are exported:
134+
135+
* `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}`
136+
137+
* `kind` -
138+
Type of the resource.
139+
140+
* `id` -
141+
The unique identifier for the resource type. The server generates this identifier.
142+
143+
* `creation_timestamp` -
144+
Creation timestamp in RFC3339 text format.
145+
146+
* `self_link` -
147+
Server-defined URL for the resource.
148+
149+
* `self_link_with_id` -
150+
Server-defined URL for this resource's resource id.
151+
152+
* `connection_endpoints` -
153+
An array of connections for all the producers connected to this network attachment.
154+
Structure is [documented below](#nested_connection_endpoints).
155+
156+
* `fingerprint` -
157+
Fingerprint of this resource. A hash of the contents stored in this object. This
158+
field is used in optimistic locking. An up-to-date fingerprint must be provided in order to patch.
159+
160+
* `network` -
161+
The URL of the network which the Network Attachment belongs to. Practically it is inferred by fetching the network of the first subnetwork associated.
162+
Because it is required that all the subnetworks must be from the same network, it is assured that the Network Attachment belongs to the same network as all the subnetworks.
163+
164+
165+
<a name="nested_connection_endpoints"></a>The `connection_endpoints` block contains:
166+
167+
* `status` -
168+
(Output)
169+
The status of a connected endpoint to this network attachment.
170+
171+
* `project_id_or_num` -
172+
(Output)
173+
The project id or number of the interface to which the IP was assigned.
174+
175+
* `subnetwork` -
176+
(Output)
177+
The subnetwork used to assign the IP to the producer instance network interface.
178+
179+
* `ip_address` -
180+
(Output)
181+
The IPv4 address assigned to the producer instance network interface. This value will be a range in case of Serverless.
182+
183+
* `secondary_ip_cidr_ranges` -
184+
(Output)
185+
Alias IP ranges from the same subnetwork.
186+
187+
## Timeouts
188+
189+
This resource provides the following
190+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
191+
192+
- `create` - Default is 20 minutes.
193+
- `delete` - Default is 20 minutes.
194+
195+
## Import
196+
197+
198+
NetworkAttachment can be imported using any of these accepted formats:
199+
200+
```
201+
$ terraform import google_compute_network_attachment.default projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}
202+
$ terraform import google_compute_network_attachment.default {{project}}/{{region}}/{{name}}
203+
$ terraform import google_compute_network_attachment.default {{region}}/{{name}}
204+
$ terraform import google_compute_network_attachment.default {{name}}
205+
```
206+
207+
## User Project Overrides
208+
209+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)