Skip to content

Commit 0b8855f

Browse files
Update Documentation for Composer (#11236) (#18830)
[upstream:2b6e2fac92b47dca3c9f5b6e86cfac64923d9a36] Signed-off-by: Modular Magician <[email protected]>
1 parent f6c05c0 commit 0b8855f

File tree

2 files changed

+165
-61
lines changed

2 files changed

+165
-61
lines changed

.changelog/11236.txt

+3
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

+162-61
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,53 @@ To get more information about Environments, see:
1414

1515
* [Cloud Composer documentation](https://cloud.google.com/composer/docs)
1616
* [Cloud Composer API documentation](https://cloud.google.com/composer/docs/reference/rest/v1beta1/projects.locations.environments)
17-
* How-to Guides (Cloud Composer 1)
18-
* [Creating environments](https://cloud.google.com/composer/docs/how-to/managing/creating)
19-
* [Scaling environments](https://cloud.google.com/composer/docs/scale-environments)
20-
* [Configuring Shared VPC for Composer Environments](https://cloud.google.com/composer/docs/how-to/managing/configuring-shared-vpc)
2117
* How-to Guides (Cloud Composer 2)
2218
* [Creating environments](https://cloud.google.com/composer/docs/composer-2/create-environments)
2319
* [Scaling environments](https://cloud.google.com/composer/docs/composer-2/scale-environments)
2420
* [Configuring Shared VPC for Composer Environments](https://cloud.google.com/composer/docs/composer-2/configure-shared-vpc)
21+
* How-to Guides (Cloud Composer 3)
22+
* [Creating environments](https://cloud.google.com/composer/docs/composer-3/create-environments)
23+
* [Scaling environments](https://cloud.google.com/composer/docs/composer-3/scale-environments)
24+
* [Change environment networking type (Private or Public IP)](https://cloud.google.com/composer/docs/composer-3/change-networking-type)
25+
* [Connect an environment to a VPC network](https://cloud.google.com/composer/docs/composer-3/connect-vpc-network)
2526
* [Apache Airflow Documentation](http://airflow.apache.org/)
2627

27-
We **STRONGLY** recommend you read the [GCP
28-
guides](https://cloud.google.com/composer/docs/how-to) as the Environment resource requires a long
29-
deployment process and involves several layers of GCP infrastructure, including a Kubernetes Engine
30-
cluster, Cloud Storage, and Compute networking resources. Due to limitations of the API, Terraform
31-
will not be able to find or manage many of these underlying resources automatically. In particular:
32-
* Creating or updating an environment resource can take up to one hour. In addition, GCP may only
33-
detect some errors in the configuration when they are used (e.g., ~40-50 minutes into the creation
34-
process), and is prone to limited error reporting. If you encounter confusing or uninformative
35-
errors, please verify your configuration is valid against GCP Cloud Composer before filing bugs
36-
against the Terraform provider.
37-
* **Environments create Google Cloud Storage buckets that are not automatically cleaned up** on environment deletion. [More about Composer's use of Cloud
38-
Storage](https://cloud.google.com/composer/docs/concepts/cloud-storage).
39-
* Please review the [known
40-
issues](https://cloud.google.com/composer/docs/known-issues) for Composer if you are having
41-
problems.
28+
<Note>
29+
Cloud Composer 1 is in the post-maintenance mode. Google does
30+
not release any further updates to Cloud Composer 1, including new versions
31+
of Airflow, bugfixes, and security updates. We recommend using
32+
Cloud Composer 2 or Cloud Composer 3 instead.
33+
</Note>
34+
35+
Several special considerations apply to managing Cloud Composer environments
36+
with Terraform:
37+
38+
* The Environment resource is based on several layers of GCP infrastructure.
39+
Terraform does not manage these underlying resources. For example, in Cloud
40+
Composer 2, this includes a Kubernetes Engine cluster, Cloud Storage, and
41+
Compute networking resources.
42+
* Creating or updating an environment usually takes around 25 minutes.
43+
* In some cases errors in the configuration will be detected and reported only
44+
during the process of the environment creation. If you encounter such
45+
errors, please verify your configuration is valid against GCP Cloud Composer before filing bugs for the Terraform provider.
46+
* **Environments have Google Cloud Storage buckets that are not automatically
47+
deleted** with the environment.
48+
See [Delete environments](https://cloud.google.com/composer/docs/composer-2/delete-environments)
49+
for more information.
50+
* Please refer to
51+
[Troubleshooting pages](https://cloud.devsite.corp.google.com/composer/docs/composer-2/troubleshooting-environment-creation) if you encounter
52+
problems.
4253

4354
## Example Usage
4455

45-
### Basic Usage (Cloud Composer 1)
56+
### Basic Usage (Cloud Composer 3)
4657
```hcl
4758
resource "google_composer_environment" "test" {
4859
name = "example-composer-env"
4960
region = "us-central1"
50-
config {
61+
config {
5162
software_config {
52-
image_version = "composer-1-airflow-2"
63+
image_version = "composer-3-airflow-2"
5364
}
5465
}
5566
}
@@ -68,69 +79,105 @@ resource "google_composer_environment" "test" {
6879
}
6980
```
7081

82+
### Basic Usage (Cloud Composer 1)
83+
```hcl
84+
resource "google_composer_environment" "test" {
85+
name = "example-composer-env"
86+
region = "us-central1"
87+
config {
88+
software_config {
89+
image_version = "composer-1-airflow-2"
90+
}
91+
}
92+
}
93+
```
94+
95+
7196
### With GKE and Compute Resource Dependencies
7297

73-
**NOTE** To use custom service accounts, you must give at least `role/composer.worker` to the service account used by the GKE Nodes on the Composer project.
74-
For more information, see the [Access Control](https://cloud.devsite.corp.google.com/composer/docs/how-to/access-control) page in the Cloud Composer documentation.
75-
You may need to assign additional roles depending on what the Airflow DAGs will be running.
98+
<Note>
99+
To use custom service accounts, you must give at least the
100+
`role/composer.worker` role to the service account of the Cloud Composer
101+
environment. For more information, see the
102+
[Access Control](https://cloud.google.com/composer/docs/how-to/access-control)
103+
page in the Cloud Composer documentation.
104+
You might need to assign additional roles depending on specific workflows
105+
that the Airflow DAGs will be running.
106+
<Note>
76107

77-
#### GKE and Compute Resource Dependencies (Cloud Composer 1)
108+
#### GKE and Compute Resource Dependencies (Cloud Composer 3)
78109

79110
```hcl
111+
provider "google" {
112+
project = "example-project"
113+
}
114+
80115
resource "google_composer_environment" "test" {
81-
name = "example-composer-env"
116+
name = "example-composer-env-tf-c3"
82117
region = "us-central1"
83118
config {
84-
node_count = 4
85119
86-
node_config {
87-
zone = "us-central1-a"
88-
machine_type = "n1-standard-1"
89-
90-
network = google_compute_network.test.id
91-
subnetwork = google_compute_subnetwork.test.id
92-
93-
service_account = google_service_account.test.name
120+
software_config {
121+
image_version = "composer-3-airflow-2"
94122
}
95123
96-
database_config {
97-
machine_type = "db-n1-standard-2"
124+
workloads_config {
125+
scheduler {
126+
cpu = 0.5
127+
memory_gb = 2
128+
storage_gb = 1
129+
count = 1
130+
}
131+
triggerer {
132+
cpu = 0.5
133+
memory_gb = 1
134+
count = 1
135+
}
136+
dag_processor {
137+
cpu = 1
138+
memory_gb = 2
139+
storage_gb = 1
140+
count = 1
141+
}
142+
web_server {
143+
cpu = 0.5
144+
memory_gb = 2
145+
storage_gb = 1
146+
}
147+
worker {
148+
cpu = 0.5
149+
memory_gb = 2
150+
storage_gb = 1
151+
min_count = 1
152+
max_count = 3
153+
}
154+
98155
}
156+
environment_size = "ENVIRONMENT_SIZE_SMALL"
99157
100-
web_server_config {
101-
machine_type = "composer-n1-webserver-2"
158+
node_config {
159+
service_account = google_service_account.test.name
102160
}
103161
}
104162
}
105163
106-
resource "google_compute_network" "test" {
107-
name = "composer-test-network"
108-
auto_create_subnetworks = false
109-
}
110-
111-
resource "google_compute_subnetwork" "test" {
112-
name = "composer-test-subnetwork"
113-
ip_cidr_range = "10.2.0.0/16"
114-
region = "us-central1"
115-
network = google_compute_network.test.id
116-
}
117-
118164
resource "google_service_account" "test" {
119165
account_id = "composer-env-account"
120166
display_name = "Test Service Account for Composer Environment"
121167
}
122168
123169
resource "google_project_iam_member" "composer-worker" {
124-
role = "roles/composer.worker"
125-
member = "serviceAccount:${google_service_account.test.email}"
170+
project = "your-project-id"
171+
role = "roles/composer.worker"
172+
member = "serviceAccount:${google_service_account.test.email}"
126173
}
127174
```
128175

129176
#### GKE and Compute Resource Dependencies (Cloud Composer 2)
130177

131178
```hcl
132179
provider "google" {
133-
project = "bigdata-writers"
180+
project = "example-project"
134181
}
135182
136183
resource "google_composer_environment" "test" {
@@ -198,6 +245,64 @@ resource "google_project_iam_member" "composer-worker" {
198245
}
199246
```
200247

248+
#### GKE and Compute Resource Dependencies (Cloud Composer 1)
249+
250+
```hcl
251+
resource "google_composer_environment" "test" {
252+
name = "example-composer-env"
253+
region = "us-central1"
254+
config {
255+
256+
software_config {
257+
image_version = "composer-1-airflow-2"
258+
}
259+
260+
node_count = 4
261+
262+
node_config {
263+
zone = "us-central1-a"
264+
machine_type = "n1-standard-1"
265+
266+
network = google_compute_network.test.id
267+
subnetwork = google_compute_subnetwork.test.id
268+
269+
service_account = google_service_account.test.name
270+
}
271+
272+
database_config {
273+
machine_type = "db-n1-standard-2"
274+
}
275+
276+
web_server_config {
277+
machine_type = "composer-n1-webserver-2"
278+
}
279+
}
280+
}
281+
282+
resource "google_compute_network" "test" {
283+
name = "composer-test-network"
284+
auto_create_subnetworks = false
285+
}
286+
287+
resource "google_compute_subnetwork" "test" {
288+
name = "composer-test-subnetwork"
289+
ip_cidr_range = "10.2.0.0/16"
290+
region = "us-central1"
291+
network = google_compute_network.test.id
292+
}
293+
294+
resource "google_service_account" "test" {
295+
account_id = "composer-env-account"
296+
display_name = "Test Service Account for Composer Environment"
297+
}
298+
299+
resource "google_project_iam_member" "composer-worker" {
300+
role = "roles/composer.worker"
301+
member = "serviceAccount:${google_service_account.test.email}"
302+
}
303+
```
304+
305+
201306
### With Software (Airflow) Config
202307

203308
```hcl
@@ -206,8 +311,6 @@ resource "google_composer_environment" "test" {
206311
region = "us-central1"
207312
208313
config {
209-
software_config {
210-
scheduler_count = 2 // only in Composer 1 with Airflow 2, use workloads_config in Composer 2
211314
airflow_config_overrides = {
212315
core-dags_are_paused_at_creation = "True"
213316
}
@@ -218,7 +321,7 @@ resource "google_composer_environment" "test" {
218321
}
219322
220323
env_variables = {
221-
FOO = "bar"
324+
EXAMPLE_VARIABLE = "test"
222325
}
223326
}
224327
}
@@ -249,7 +352,7 @@ The following arguments are supported:
249352
Both keys and values must be <= 128 bytes in size.
250353

251354
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
252-
Please refer to the field 'effective_labels' for all of the labels present on the resource.
355+
Please refer to the field 'effective_labels' for all of the labels present on the resource.
253356

254357
* `terraform_labels` -
255358
The combination of labels configured directly on the resource and default labels configured on the provider.
@@ -1095,8 +1198,6 @@ The `worker` block supports:
10951198

10961199
## Argument Reference - Cloud Composer 3
10971200

1098-
**Please note: This documentation corresponds to Composer 3, which is not yet released.**
1099-
11001201
The following arguments are supported:
11011202

11021203
* `name` -

0 commit comments

Comments
 (0)