Skip to content

Commit f53032d

Browse files
Add an example of Composer 3 configuration with network attachment (#11288) (#18966)
[upstream:6a9d8c19ec6af03bbf6704ddce35aed5e3c21b3a] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 22ca227 commit f53032d

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

.changelog/11288.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

website/docs/r/composer_environment.html.markdown

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ To get more information about Environments, see:
2525
* [Connect an environment to a VPC network](https://cloud.google.com/composer/docs/composer-3/connect-vpc-network)
2626
* [Apache Airflow Documentation](http://airflow.apache.org/)
2727

28-
<Note>
28+
-> **Note**
2929
Cloud Composer 1 is in the post-maintenance mode. Google does
3030
not release any further updates to Cloud Composer 1, including new versions
3131
of Airflow, bugfixes, and security updates. We recommend using
3232
Cloud Composer 2 or Cloud Composer 3 instead.
33-
</Note>
3433

3534
Several special considerations apply to managing Cloud Composer environments
3635
with Terraform:
@@ -92,18 +91,16 @@ resource "google_composer_environment" "test" {
9291
}
9392
```
9493

95-
9694
### With GKE and Compute Resource Dependencies
9795

98-
<Note>
96+
-> **Note**
9997
To use custom service accounts, you must give at least the
10098
`role/composer.worker` role to the service account of the Cloud Composer
10199
environment. For more information, see the
102100
[Access Control](https://cloud.google.com/composer/docs/how-to/access-control)
103101
page in the Cloud Composer documentation.
104102
You might need to assign additional roles depending on specific workflows
105103
that the Airflow DAGs will be running.
106-
<Note>
107104

108105
#### GKE and Compute Resource Dependencies (Cloud Composer 3)
109106

@@ -302,6 +299,69 @@ resource "google_project_iam_member" "composer-worker" {
302299
}
303300
```
304301

302+
### Cloud Composer 3 networking configuration
303+
304+
In Cloud Composer 3, networking configuration is simplified compared to
305+
previous versions. You don't need to specify network ranges, and can attach
306+
custom VPC networks to your environment.
307+
308+
-> **Note**
309+
It's not possible to detach a VPC network using Terraform. Instead, you can
310+
attach a different VPC network in its place, or detach the network using
311+
other tools like Google Cloud CLI.
312+
313+
Use Private IP networking:
314+
315+
```hcl
316+
resource "google_composer_environment" "example" {
317+
name = "example-environment"
318+
region = "us-central1"
319+
320+
config {
321+
322+
enable_private_ip_environment = true
323+
324+
# ... other configuration parameters
325+
}
326+
}
327+
```
328+
329+
Attach a custom VPC network (Cloud Composer creates a new network attachment):
330+
331+
```hcl
332+
resource "google_composer_environment" "example" {
333+
name = "example-environment"
334+
region = "us-central1"
335+
336+
config {
337+
338+
node_config {
339+
network = "projects/example-project/global/networks/example-network"
340+
subnetwork = "projects/example-project/regions/us-central1/subnetworks/example-subnetwork"
341+
}
342+
343+
# ... other configuration parameters
344+
}
345+
}
346+
```
347+
348+
Attach a custom VPC network (use existing network attachment):
349+
350+
```hcl
351+
resource "google_composer_environment" "example" {
352+
name = "example-environment"
353+
region = "us-central1"
354+
355+
config {
356+
357+
node_config {
358+
composer_network_attachment = projects/example-project/regions/us-central1/networkAttachments/example-network-attachment
359+
}
360+
361+
# ... other configuration parameters
362+
}
363+
}
364+
```
305365

306366
### With Software (Airflow) Config
307367

@@ -327,6 +387,7 @@ resource "google_composer_environment" "test" {
327387
}
328388
}
329389
```
390+
330391
## Argument Reference - Cloud Composer 1
331392

332393
The following arguments are supported:

0 commit comments

Comments
 (0)