@@ -14,42 +14,53 @@ To get more information about Environments, see:
14
14
15
15
* [ Cloud Composer documentation] ( https://cloud.google.com/composer/docs )
16
16
* [ 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 )
21
17
* How-to Guides (Cloud Composer 2)
22
18
* [ Creating environments] ( https://cloud.google.com/composer/docs/composer-2/create-environments )
23
19
* [ Scaling environments] ( https://cloud.google.com/composer/docs/composer-2/scale-environments )
24
20
* [ 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 )
25
26
* [ Apache Airflow Documentation] ( http://airflow.apache.org/ )
26
27
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.
42
53
43
54
## Example Usage
44
55
45
- ### Basic Usage (Cloud Composer 1 )
56
+ ### Basic Usage (Cloud Composer 3 )
46
57
``` hcl
47
58
resource "google_composer_environment" "test" {
48
59
name = "example-composer-env"
49
60
region = "us-central1"
50
- config {
61
+ config {
51
62
software_config {
52
- image_version = "composer-1 -airflow-2"
63
+ image_version = "composer-3 -airflow-2"
53
64
}
54
65
}
55
66
}
@@ -68,69 +79,105 @@ resource "google_composer_environment" "test" {
68
79
}
69
80
```
70
81
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
+
71
96
### With GKE and Compute Resource Dependencies
72
97
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 >
76
107
77
- #### GKE and Compute Resource Dependencies (Cloud Composer 1 )
108
+ #### GKE and Compute Resource Dependencies (Cloud Composer 3 )
78
109
79
110
``` hcl
111
+ provider "google" {
112
+ project = "example-project"
113
+ }
114
+
80
115
resource "google_composer_environment" "test" {
81
- name = "example-composer-env"
116
+ name = "example-composer-env-tf-c3 "
82
117
region = "us-central1"
83
118
config {
84
- node_count = 4
85
119
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"
94
122
}
95
123
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
+
98
155
}
156
+ environment_size = "ENVIRONMENT_SIZE_SMALL"
99
157
100
- web_server_config {
101
- machine_type = "composer-n1-webserver-2"
158
+ node_config {
159
+ service_account = google_service_account.test.name
102
160
}
103
161
}
104
162
}
105
163
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
-
118
164
resource "google_service_account" "test" {
119
165
account_id = "composer-env-account"
120
166
display_name = "Test Service Account for Composer Environment"
121
167
}
122
168
123
169
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}"
126
173
}
127
174
```
128
175
129
176
#### GKE and Compute Resource Dependencies (Cloud Composer 2)
130
177
131
178
``` hcl
132
179
provider "google" {
133
- project = "bigdata-writers "
180
+ project = "example-project "
134
181
}
135
182
136
183
resource "google_composer_environment" "test" {
@@ -198,6 +245,64 @@ resource "google_project_iam_member" "composer-worker" {
198
245
}
199
246
```
200
247
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
+
201
306
### With Software (Airflow) Config
202
307
203
308
``` hcl
@@ -206,8 +311,6 @@ resource "google_composer_environment" "test" {
206
311
region = "us-central1"
207
312
208
313
config {
209
- software_config {
210
- scheduler_count = 2 // only in Composer 1 with Airflow 2, use workloads_config in Composer 2
211
314
airflow_config_overrides = {
212
315
core-dags_are_paused_at_creation = "True"
213
316
}
@@ -218,7 +321,7 @@ resource "google_composer_environment" "test" {
218
321
}
219
322
220
323
env_variables = {
221
- FOO = "bar "
324
+ EXAMPLE_VARIABLE = "test "
222
325
}
223
326
}
224
327
}
@@ -249,7 +352,7 @@ The following arguments are supported:
249
352
Both keys and values must be <= 128 bytes in size.
250
353
251
354
** 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.
253
356
254
357
* ` terraform_labels ` -
255
358
The combination of labels configured directly on the resource and default labels configured on the provider.
@@ -1095,8 +1198,6 @@ The `worker` block supports:
1095
1198
1096
1199
## Argument Reference - Cloud Composer 3
1097
1200
1098
- ** Please note: This documentation corresponds to Composer 3, which is not yet released.**
1099
-
1100
1201
The following arguments are supported:
1101
1202
1102
1203
* ` name ` -
0 commit comments