Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer network config #15460

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/8533.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Adding support for connection type in private environments for Cloud Composer.
```
3 changes: 2 additions & 1 deletion google/resource_composer_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,13 +1134,14 @@ resource "google_composer_environment" "test" {
subnetwork = google_compute_subnetwork.test.self_link
enable_ip_masq_agent = true
ip_allocation_policy {
cluster_ipv4_cidr_block = "10.0.0.0/16"
cluster_ipv4_cidr_block = "10.56.0.0/14"
}
}
software_config {
image_version = "composer-2-airflow-2"
}
private_environment_config {
connection_type = "VPC_PEERING"
enable_private_endpoint = true
enable_privately_used_public_ips = true
}
Expand Down
19 changes: 19 additions & 0 deletions google/services/composer/resource_composer_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ var (
}

composerPrivateEnvironmentConfig = []string{
"config.0.private_environment_config.0.connection_type",
"config.0.private_environment_config.0.enable_private_endpoint",
"config.0.private_environment_config.0.master_ipv4_cidr_block",
"config.0.private_environment_config.0.cloud_sql_ipv4_cidr_block",
Expand Down Expand Up @@ -438,6 +439,15 @@ func ResourceComposerEnvironment() *schema.Resource {
Description: `The configuration used for the Private IP Cloud Composer environment.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"connection_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
AtLeastOneOf: composerPrivateEnvironmentConfig,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"VPC_PEERING", "PRIVATE_SERVICE_CONNECT"}, false),
Description: `Mode of internal communication within the Composer environment. Must be one of "VPC_PEERING" or "PRIVATE_SERVICE_CONNECT".`,
},
"enable_private_endpoint": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -1383,6 +1393,9 @@ func flattenComposerEnvironmentConfigPrivateEnvironmentConfig(envCfg *composer.P
}

transformed := make(map[string]interface{})
if envCfg.NetworkingConfig != nil {
transformed["connection_type"] = envCfg.NetworkingConfig.ConnectionType
}
transformed["enable_private_endpoint"] = envCfg.PrivateClusterConfig.EnablePrivateEndpoint
transformed["master_ipv4_cidr_block"] = envCfg.PrivateClusterConfig.MasterIpv4CidrBlock
transformed["cloud_sql_ipv4_cidr_block"] = envCfg.CloudSqlIpv4CidrBlock
Expand Down Expand Up @@ -1802,6 +1815,11 @@ func expandComposerEnvironmentConfigPrivateEnvironmentConfig(v interface{}, d *s
}

subBlock := &composer.PrivateClusterConfig{}
networkConfig := &composer.NetworkingConfig{}

if v, ok := original["connection_type"]; ok {
networkConfig.ConnectionType = v.(string)
}

if v, ok := original["enable_private_endpoint"]; ok {
subBlock.EnablePrivateEndpoint = v.(bool)
Expand Down Expand Up @@ -1830,6 +1848,7 @@ func expandComposerEnvironmentConfigPrivateEnvironmentConfig(v interface{}, d *s
}

transformed.PrivateClusterConfig = subBlock
transformed.NetworkingConfig = networkConfig

return transformed, nil
}
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/composer_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,11 @@ The following arguments are supported:

See [documentation](https://cloud.google.com/composer/docs/how-to/managing/configuring-private-ip) for setting up private environments. <a name="nested_private_environment_config"></a>The `private_environment_config` block supports:

* `connection_type` -
(Optional, Cloud Composer 2 only)
Mode of internal communication within the Composer environment. Must be one
of `"VPC_PEERING"` or `"PRIVATE_SERVICE_CONNECT"`.

* `enable_private_endpoint` -
If true, access to the public endpoint of the GKE cluster is denied.
If this field is set to true, the `ip_allocation_policy.use_ip_aliases` field must
Expand Down