Skip to content

Commit

Permalink
Adding mmv1 generated Resource: google_composer_user_workloads_config…
Browse files Browse the repository at this point in the history
…_map (#10865) (#18378)

[upstream:7f78f530c63a52654dfcbc2719867a50ceb95cfa]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jun 10, 2024
1 parent 510ddd1 commit 3c456fc
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 10 deletions.
2 changes: 1 addition & 1 deletion google/fwmodels/provider_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type ProviderModel struct {
CloudRunV2CustomEndpoint types.String `tfsdk:"cloud_run_v2_custom_endpoint"`
CloudSchedulerCustomEndpoint types.String `tfsdk:"cloud_scheduler_custom_endpoint"`
CloudTasksCustomEndpoint types.String `tfsdk:"cloud_tasks_custom_endpoint"`
ComposerCustomEndpoint types.String `tfsdk:"composer_custom_endpoint"`
ComputeCustomEndpoint types.String `tfsdk:"compute_custom_endpoint"`
ContainerAnalysisCustomEndpoint types.String `tfsdk:"container_analysis_custom_endpoint"`
ContainerAttachedCustomEndpoint types.String `tfsdk:"container_attached_custom_endpoint"`
Expand Down Expand Up @@ -147,7 +148,6 @@ type ProviderModel struct {

// Handwritten Products / Versioned / Atypical Entries
CloudBillingCustomEndpoint types.String `tfsdk:"cloud_billing_custom_endpoint"`
ComposerCustomEndpoint types.String `tfsdk:"composer_custom_endpoint"`
ContainerCustomEndpoint types.String `tfsdk:"container_custom_endpoint"`
DataflowCustomEndpoint types.String `tfsdk:"dataflow_custom_endpoint"`
IamCredentialsCustomEndpoint types.String `tfsdk:"iam_credentials_custom_endpoint"`
Expand Down
12 changes: 6 additions & 6 deletions google/fwprovider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"composer_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"compute_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down Expand Up @@ -848,12 +854,6 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"composer_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"container_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
10 changes: 10 additions & 0 deletions google/fwtransport/framework_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type FrameworkProviderConfig struct {
CloudRunV2BasePath string
CloudSchedulerBasePath string
CloudTasksBasePath string
ComposerBasePath string
ComputeBasePath string
ContainerAnalysisBasePath string
ContainerAttachedBasePath string
Expand Down Expand Up @@ -241,6 +242,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context,
p.CloudRunV2BasePath = data.CloudRunV2CustomEndpoint.ValueString()
p.CloudSchedulerBasePath = data.CloudSchedulerCustomEndpoint.ValueString()
p.CloudTasksBasePath = data.CloudTasksCustomEndpoint.ValueString()
p.ComposerBasePath = data.ComposerCustomEndpoint.ValueString()
p.ComputeBasePath = data.ComputeCustomEndpoint.ValueString()
p.ContainerAnalysisBasePath = data.ContainerAnalysisCustomEndpoint.ValueString()
p.ContainerAttachedBasePath = data.ContainerAttachedCustomEndpoint.ValueString()
Expand Down Expand Up @@ -729,6 +731,14 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
data.CloudTasksCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.ComposerCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_COMPOSER_CUSTOM_ENDPOINT",
}, transport_tpg.DefaultBasePaths[transport_tpg.ComposerBasePathKey])
if customEndpoint != nil {
data.ComposerCustomEndpoint = types.StringValue(customEndpoint.(string))
}
}
if data.ComputeCustomEndpoint.IsNull() {
customEndpoint := transport_tpg.MultiEnvDefault([]string{
"GOOGLE_COMPUTE_CUSTOM_ENDPOINT",
Expand Down
6 changes: 6 additions & 0 deletions google/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"composer_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"compute_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -951,6 +956,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.CloudRunV2BasePath = d.Get("cloud_run_v2_custom_endpoint").(string)
config.CloudSchedulerBasePath = d.Get("cloud_scheduler_custom_endpoint").(string)
config.CloudTasksBasePath = d.Get("cloud_tasks_custom_endpoint").(string)
config.ComposerBasePath = d.Get("composer_custom_endpoint").(string)
config.ComputeBasePath = d.Get("compute_custom_endpoint").(string)
config.ContainerAnalysisBasePath = d.Get("container_analysis_custom_endpoint").(string)
config.ContainerAttachedBasePath = d.Get("container_attached_custom_endpoint").(string)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package composer_test
1 change: 1 addition & 0 deletions google/sweeper/gcp_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
_ "github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2"
_ "github.com/hashicorp/terraform-provider-google/google/services/cloudscheduler"
_ "github.com/hashicorp/terraform-provider-google/google/services/cloudtasks"
_ "github.com/hashicorp/terraform-provider-google/google/services/composer"
_ "github.com/hashicorp/terraform-provider-google/google/services/compute"
_ "github.com/hashicorp/terraform-provider-google/google/services/containeranalysis"
_ "github.com/hashicorp/terraform-provider-google/google/services/containerattached"
Expand Down
12 changes: 9 additions & 3 deletions google/transport/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ type Config struct {
CloudRunV2BasePath string
CloudSchedulerBasePath string
CloudTasksBasePath string
ComposerBasePath string
ComputeBasePath string
ContainerAnalysisBasePath string
ContainerAttachedBasePath string
Expand Down Expand Up @@ -305,7 +306,6 @@ type Config struct {
WorkflowsBasePath string

CloudBillingBasePath string
ComposerBasePath string
ContainerBasePath string
DataflowBasePath string
IamCredentialsBasePath string
Expand Down Expand Up @@ -359,6 +359,7 @@ const CloudRunBasePathKey = "CloudRun"
const CloudRunV2BasePathKey = "CloudRunV2"
const CloudSchedulerBasePathKey = "CloudScheduler"
const CloudTasksBasePathKey = "CloudTasks"
const ComposerBasePathKey = "Composer"
const ComputeBasePathKey = "Compute"
const ContainerAnalysisBasePathKey = "ContainerAnalysis"
const ContainerAttachedBasePathKey = "ContainerAttached"
Expand Down Expand Up @@ -441,7 +442,6 @@ const VPCAccessBasePathKey = "VPCAccess"
const WorkbenchBasePathKey = "Workbench"
const WorkflowsBasePathKey = "Workflows"
const CloudBillingBasePathKey = "CloudBilling"
const ComposerBasePathKey = "Composer"
const ContainerBasePathKey = "Container"
const DataflowBasePathKey = "Dataflow"
const IAMBasePathKey = "IAM"
Expand Down Expand Up @@ -490,6 +490,7 @@ var DefaultBasePaths = map[string]string{
CloudRunV2BasePathKey: "https://run.googleapis.com/v2/",
CloudSchedulerBasePathKey: "https://cloudscheduler.googleapis.com/v1/",
CloudTasksBasePathKey: "https://cloudtasks.googleapis.com/v2/",
ComposerBasePathKey: "https://composer.googleapis.com/v1/",
ComputeBasePathKey: "https://compute.googleapis.com/compute/v1/",
ContainerAnalysisBasePathKey: "https://containeranalysis.googleapis.com/v1/",
ContainerAttachedBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/",
Expand Down Expand Up @@ -572,7 +573,6 @@ var DefaultBasePaths = map[string]string{
WorkbenchBasePathKey: "https://notebooks.googleapis.com/v2/",
WorkflowsBasePathKey: "https://workflows.googleapis.com/v1/",
CloudBillingBasePathKey: "https://cloudbilling.googleapis.com/v1/",
ComposerBasePathKey: "https://composer.googleapis.com/v1/",
ContainerBasePathKey: "https://container.googleapis.com/v1/",
DataflowBasePathKey: "https://dataflow.googleapis.com/v1b3/",
IAMBasePathKey: "https://iam.googleapis.com/v1/",
Expand Down Expand Up @@ -832,6 +832,11 @@ func SetEndpointDefaults(d *schema.ResourceData) error {
"GOOGLE_CLOUD_TASKS_CUSTOM_ENDPOINT",
}, DefaultBasePaths[CloudTasksBasePathKey]))
}
if d.Get("composer_custom_endpoint") == "" {
d.Set("composer_custom_endpoint", MultiEnvDefault([]string{
"GOOGLE_COMPOSER_CUSTOM_ENDPOINT",
}, DefaultBasePaths[ComposerBasePathKey]))
}
if d.Get("compute_custom_endpoint") == "" {
d.Set("compute_custom_endpoint", MultiEnvDefault([]string{
"GOOGLE_COMPUTE_CUSTOM_ENDPOINT",
Expand Down Expand Up @@ -2165,6 +2170,7 @@ func ConfigureBasePaths(c *Config) {
c.CloudRunV2BasePath = DefaultBasePaths[CloudRunV2BasePathKey]
c.CloudSchedulerBasePath = DefaultBasePaths[CloudSchedulerBasePathKey]
c.CloudTasksBasePath = DefaultBasePaths[CloudTasksBasePathKey]
c.ComposerBasePath = DefaultBasePaths[ComposerBasePathKey]
c.ComputeBasePath = DefaultBasePaths[ComputeBasePathKey]
c.ContainerAnalysisBasePath = DefaultBasePaths[ContainerAnalysisBasePathKey]
c.ContainerAttachedBasePath = DefaultBasePaths[ContainerAttachedBasePathKey]
Expand Down
140 changes: 140 additions & 0 deletions website/docs/r/composer_user_workloads_config_map.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
subcategory: "Cloud Composer"
description: |-
User workloads ConfigMap used by Airflow tasks that run with Kubernetes Executor or KubernetesPodOperator.
---

# google_composer_user_workloads_config_map

User workloads ConfigMap used by Airflow tasks that run with Kubernetes Executor or KubernetesPodOperator.
Intended for Composer 3 Environments.

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.

To get more information about UserWorkloadsConfigMap, see:

* [API documentation](https://cloud.google.com/composer/docs/reference/rest/v1beta1/projects.locations.environments.userWorkloadsConfigMaps)

<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgit.luolix.top%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=composer_user_workloads_config_map_basic&open_in_editor=main.tf" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Composer User Workloads Config Map Basic


```hcl
resource "google_composer_environment" "environment" {
provider = google-beta
name = "test-environment"
region = "us-central1"
config {
software_config {
image_version = "composer-3-airflow-2"
}
}
}
resource "google_composer_user_workloads_config_map" "config_map" {
provider = google-beta
name = "test-config-map"
region = "us-central1"
environment = google_composer_environment.environment.name
data = {
api_host: "apihost:443",
}
}
```

## Argument Reference

The following arguments are supported:


* `name` -
(Required)
Name of the Kubernetes ConfigMap.

* `environment` -
(Required)
Environment where the Kubernetes ConfigMap will be stored and used.


- - -


* `data` -
(Optional)
The "data" field of Kubernetes ConfigMap, organized in key-value pairs.
For details see: https://kubernetes.io/docs/concepts/configuration/configmap/

* `region` -
(Optional)
The location or Compute Engine region for the environment.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.


## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{region}}/environments/{{environment}}/userWorkloadsConfigMaps/{{name}}`


## Timeouts

This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:

- `create` - Default is 1 minutes.
- `update` - Default is 1 minutes.
- `delete` - Default is 1 minutes.

## Import


UserWorkloadsConfigMap can be imported using any of these accepted formats:

* `projects/{{project}}/locations/{{region}}/environments/{{environment}}/userWorkloadsConfigMaps/{{name}}`
* `{{project}}/{{region}}/{{environment}}/{{name}}`
* `{{region}}/{{environment}}/{{name}}`
* `{{environment}}/{{name}}`


In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import UserWorkloadsConfigMap using one of the formats above. For example:

```tf
import {
id = "projects/{{project}}/locations/{{region}}/environments/{{environment}}/userWorkloadsConfigMaps/{{name}}"
to = google_composer_user_workloads_config_map.default
}
```

When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), UserWorkloadsConfigMap can be imported using one of the formats above. For example:

```
$ terraform import google_composer_user_workloads_config_map.default projects/{{project}}/locations/{{region}}/environments/{{environment}}/userWorkloadsConfigMaps/{{name}}
$ terraform import google_composer_user_workloads_config_map.default {{project}}/{{region}}/{{environment}}/{{name}}
$ terraform import google_composer_user_workloads_config_map.default {{region}}/{{environment}}/{{name}}
$ terraform import google_composer_user_workloads_config_map.default {{environment}}/{{name}}
```

## User Project Overrides

This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 comments on commit 3c456fc

Please sign in to comment.