Skip to content

Commit bb60bf2

Browse files
Enhancing documentation for composer v1 and v2 (beta) (#10284) (#5303) (#10372)
* fixing zone, work in progress * Desired version * added private_ip_google_access=true to subnetwork configuration in composer_v2 test * test fix * remove old commented code * updated docs * fixed use_ip_aliases * added atLeastOneOf to ip_allocation_policy Signed-off-by: Modular Magician <[email protected]>
1 parent a920319 commit bb60bf2

File tree

4 files changed

+456
-134
lines changed

4 files changed

+456
-134
lines changed

.changelog/5303.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```release-note:none
2+
```

google/resource_composer_environment.go

+17-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ var (
5151
"config.0.software_config",
5252
"config.0.private_environment_config",
5353
}
54+
55+
composerIpAllocationPolicyKeys = []string{
56+
"config.0.node_config.0.ip_allocation_policy.0.use_ip_aliases",
57+
"config.0.node_config.0.ip_allocation_policy.0.cluster_secondary_range_name",
58+
"config.0.node_config.0.ip_allocation_policy.0.services_secondary_range_name",
59+
"config.0.node_config.0.ip_allocation_policy.0.cluster_ipv4_cidr_block",
60+
"config.0.node_config.0.ip_allocation_policy.0.services_ipv4_cidr_block",
61+
}
5462
)
5563

5664
func resourceComposerEnvironment() *schema.Resource {
@@ -196,29 +204,33 @@ func resourceComposerEnvironment() *schema.Resource {
196204
Elem: &schema.Resource{
197205
Schema: map[string]*schema.Schema{
198206
"use_ip_aliases": {
199-
Type: schema.TypeBool,
200-
Required: true,
201-
ForceNew: true,
202-
Description: `Whether or not to enable Alias IPs in the GKE cluster. If true, a VPC-native cluster is created. Defaults to true if the ip_allocation_policy block is present in config. This field is only supported for Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*. Environments in newer versions always use VPC-native GKE clusters.`,
207+
Type: schema.TypeBool,
208+
Optional: true,
209+
ForceNew: true,
210+
AtLeastOneOf: composerIpAllocationPolicyKeys,
211+
Description: `Whether or not to enable Alias IPs in the GKE cluster. If true, a VPC-native cluster is created. Defaults to true if the ip_allocation_policy block is present in config. This field is only supported for Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*. Environments in newer versions always use VPC-native GKE clusters.`,
203212
},
204213
"cluster_secondary_range_name": {
205214
Type: schema.TypeString,
206215
Optional: true,
207216
ForceNew: true,
217+
AtLeastOneOf: composerIpAllocationPolicyKeys,
208218
Description: `The name of the cluster's secondary range used to allocate IP addresses to pods. Specify either cluster_secondary_range_name or cluster_ipv4_cidr_block but not both. For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, this field is applicable only when use_ip_aliases is true.`,
209219
ConflictsWith: []string{"config.0.node_config.0.ip_allocation_policy.0.cluster_ipv4_cidr_block"},
210220
},
211221
"services_secondary_range_name": {
212222
Type: schema.TypeString,
213223
Optional: true,
214224
ForceNew: true,
225+
AtLeastOneOf: composerIpAllocationPolicyKeys,
215226
Description: `The name of the services' secondary range used to allocate IP addresses to the cluster. Specify either services_secondary_range_name or services_ipv4_cidr_block but not both. For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, this field is applicable only when use_ip_aliases is true.`,
216227
ConflictsWith: []string{"config.0.node_config.0.ip_allocation_policy.0.services_ipv4_cidr_block"},
217228
},
218229
"cluster_ipv4_cidr_block": {
219230
Type: schema.TypeString,
220231
Optional: true,
221232
ForceNew: true,
233+
AtLeastOneOf: composerIpAllocationPolicyKeys,
222234
Description: `The IP address range used to allocate IP addresses to pods in the cluster. For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, this field is applicable only when use_ip_aliases is true. Set to blank to have GKE choose a range with the default size. Set to /netmask (e.g. /14) to have GKE choose a range with a specific netmask. Set to a CIDR notation (e.g. 10.96.0.0/14) from the RFC-1918 private networks (e.g. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) to pick a specific range to use. Specify either cluster_secondary_range_name or cluster_ipv4_cidr_block but not both.`,
223235
DiffSuppressFunc: cidrOrSizeDiffSuppress,
224236
ConflictsWith: []string{"config.0.node_config.0.ip_allocation_policy.0.cluster_secondary_range_name"},
@@ -227,6 +239,7 @@ func resourceComposerEnvironment() *schema.Resource {
227239
Type: schema.TypeString,
228240
Optional: true,
229241
ForceNew: true,
242+
AtLeastOneOf: composerIpAllocationPolicyKeys,
230243
Description: `The IP address range used to allocate IP addresses in this cluster. For Cloud Composer environments in versions composer-1.*.*-airflow-*.*.*, this field is applicable only when use_ip_aliases is true. Set to blank to have GKE choose a range with the default size. Set to /netmask (e.g. /14) to have GKE choose a range with a specific netmask. Set to a CIDR notation (e.g. 10.96.0.0/14) from the RFC-1918 private networks (e.g. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) to pick a specific range to use. Specify either services_secondary_range_name or services_ipv4_cidr_block but not both.`,
231244
DiffSuppressFunc: cidrOrSizeDiffSuppress,
232245
ConflictsWith: []string{"config.0.node_config.0.ip_allocation_policy.0.services_secondary_range_name"},

google/resource_composer_environment_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ resource "google_composer_environment" "test" {
346346
subnetwork = google_compute_subnetwork.test.self_link
347347
zone = "us-central1-a"
348348
machine_type = "n1-standard-1"
349+
ip_allocation_policy {
350+
use_ip_aliases = true
351+
cluster_ipv4_cidr_block = "10.0.0.0/16"
352+
}
349353
}
350354
}
351355
}

0 commit comments

Comments
 (0)