Skip to content

Commit

Permalink
Deprecate createSampleWorkflows and provisionGmek fields. Add createS…
Browse files Browse the repository at this point in the history
…ampleIntegrations (#10478) (#17945)

[upstream:41c94af5b71deda5f8778d29095ab5b13a7a874c]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Apr 24, 2024
1 parent fc84d7e commit 82eda93
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigAdvanceExample(context
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "asia-east2"
provision_gmek = true
}
resource "google_integrations_auth_config" "advance_example" {
Expand Down Expand Up @@ -110,7 +109,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigUsernameAndPasswordExam
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "northamerica-northeast2"
provision_gmek = true
}
resource "google_integrations_auth_config" "username_and_password_example" {
Expand Down Expand Up @@ -158,7 +156,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigOauth2AuthorizationCode
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "asia-east1"
provision_gmek = true
}
resource "google_integrations_auth_config" "oauth2_authotization_code_example" {
Expand Down Expand Up @@ -209,7 +206,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigOauth2ClientCredentials
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "southamerica-east1"
provision_gmek = true
}
resource "google_integrations_auth_config" "oauth2_client_credentials_example" {
Expand Down Expand Up @@ -274,7 +270,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigJwtExample(context map[
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "us-west4"
provision_gmek = true
}
resource "google_integrations_auth_config" "jwt_example" {
Expand Down Expand Up @@ -323,7 +318,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigAuthTokenExample(contex
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "us-west2"
provision_gmek = true
}
resource "google_integrations_auth_config" "auth_token_example" {
Expand Down Expand Up @@ -371,7 +365,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigServiceAccountExample(c
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "northamerica-northeast1"
provision_gmek = true
}
resource "google_service_account" "service_account" {
Expand Down Expand Up @@ -424,7 +417,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigOidcTokenExample(contex
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "us-south1"
provision_gmek = true
}
resource "google_service_account" "service_account" {
Expand Down Expand Up @@ -477,7 +469,6 @@ func testAccIntegrationsAuthConfig_integrationsAuthConfigClientCertificateOnlyEx
return acctest.Nprintf(`
resource "google_integrations_client" "client" {
location = "us-west3"
provision_gmek = true
}
resource "google_integrations_auth_config" "client_certificate_example" {
Expand Down
43 changes: 35 additions & 8 deletions google/services/integrations/resource_integrations_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,30 @@ encrypted with GMEK.`,
},
},
},
ConflictsWith: []string{"provision_gmek"},
},
"create_sample_integrations": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Description: `Indicates if sample integrations should be created along with provisioning.`,
ConflictsWith: []string{"create_sample_workflows"},
},
"create_sample_workflows": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Description: `Indicates if sample workflow should be created along with provisioning.`,
Type: schema.TypeBool,
Optional: true,
Deprecated: "`create_sample_workflows` is deprecated and will be removed in a future major release. Use `create_sample_integrations` instead.",
ForceNew: true,
Description: `Indicates if sample workflow should be created along with provisioning.`,
ConflictsWith: []string{"create_sample_integrations"},
},
"provision_gmek": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Description: `Indicates provision with GMEK or CMEK.`,
Type: schema.TypeBool,
Optional: true,
Deprecated: "`provision_gmek` is deprecated and will be removed in a future major release. Client would be provisioned as gmek if `cloud_kms_config` is not given.",
ForceNew: true,
Description: `Indicates provision with GMEK or CMEK.`,
ConflictsWith: []string{"cloud_kms_config"},
},
"run_as_service_account": {
Type: schema.TypeString,
Expand Down Expand Up @@ -157,6 +169,12 @@ func resourceIntegrationsClientCreate(d *schema.ResourceData, meta interface{})
} else if v, ok := d.GetOkExists("create_sample_workflows"); !tpgresource.IsEmptyValue(reflect.ValueOf(createSampleWorkflowsProp)) && (ok || !reflect.DeepEqual(v, createSampleWorkflowsProp)) {
obj["createSampleWorkflows"] = createSampleWorkflowsProp
}
createSampleIntegrationsProp, err := expandIntegrationsClientCreateSampleIntegrations(d.Get("create_sample_integrations"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("create_sample_integrations"); !tpgresource.IsEmptyValue(reflect.ValueOf(createSampleIntegrationsProp)) && (ok || !reflect.DeepEqual(v, createSampleIntegrationsProp)) {
obj["createSampleIntegrations"] = createSampleIntegrationsProp
}
provisionGmekProp, err := expandIntegrationsClientProvisionGmek(d.Get("provision_gmek"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -197,6 +215,11 @@ func resourceIntegrationsClientCreate(d *schema.ResourceData, meta interface{})
}

headers := make(http.Header)
// Translate `createSampleIntegrations` to `createSampleWorkflows`
if val, ok := obj["createSampleIntegrations"]; ok {
delete(obj, "createSampleIntegrations")
obj["createSampleWorkflows"] = val
}
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "POST",
Expand Down Expand Up @@ -426,6 +449,10 @@ func expandIntegrationsClientCreateSampleWorkflows(v interface{}, d tpgresource.
return v, nil
}

func expandIntegrationsClientCreateSampleIntegrations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandIntegrationsClientProvisionGmek(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAccIntegrationsClient_integrationsClientBasicExample(t *testing.T) {
ResourceName: "google_integrations_client.example",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_workflows", "provision_gmek", "run_as_service_account", "location"},
ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_workflows", "create_sample_integrations", "provision_gmek", "run_as_service_account", "location"},
},
},
})
Expand All @@ -59,12 +59,11 @@ func testAccIntegrationsClient_integrationsClientBasicExample(context map[string
return acctest.Nprintf(`
resource "google_integrations_client" "example" {
location = "us-central1"
provision_gmek = true
}
`, context)
}

func TestAccIntegrationsClient_integrationsClientAdvanceExample(t *testing.T) {
func TestAccIntegrationsClient_integrationsClientFullExample(t *testing.T) {
acctest.SkipIfVcr(t)
t.Parallel()

Expand All @@ -78,19 +77,19 @@ func TestAccIntegrationsClient_integrationsClientAdvanceExample(t *testing.T) {
CheckDestroy: testAccCheckIntegrationsClientDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccIntegrationsClient_integrationsClientAdvanceExample(context),
Config: testAccIntegrationsClient_integrationsClientFullExample(context),
},
{
ResourceName: "google_integrations_client.example",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_workflows", "provision_gmek", "run_as_service_account", "location"},
ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_workflows", "create_sample_integrations", "provision_gmek", "run_as_service_account", "location"},
},
},
})
}

func testAccIntegrationsClient_integrationsClientAdvanceExample(context map[string]interface{}) string {
func testAccIntegrationsClient_integrationsClientFullExample(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_project" "test_project" {
}
Expand All @@ -104,12 +103,10 @@ resource "google_kms_crypto_key" "cryptokey" {
name = "crypto-key-example"
key_ring = google_kms_key_ring.keyring.id
rotation_period = "7776000s"
depends_on = [google_kms_key_ring.keyring]
}
resource "google_kms_crypto_key_version" "test_key" {
crypto_key = google_kms_crypto_key.cryptokey.id
depends_on = [google_kms_crypto_key.cryptokey]
}
resource "google_service_account" "service_account" {
Expand All @@ -119,7 +116,7 @@ resource "google_service_account" "service_account" {
resource "google_integrations_client" "example" {
location = "us-east1"
create_sample_workflows = true
create_sample_integrations = true
run_as_service_account = google_service_account.service_account.email
cloud_kms_config {
kms_location = "us-east1"
Expand All @@ -128,7 +125,41 @@ resource "google_integrations_client" "example" {
key_version = google_kms_crypto_key_version.test_key.id
kms_project_id = data.google_project.test_project.project_id
}
depends_on = [google_kms_crypto_key_version.test_key, google_service_account.service_account]
}
`, context)
}

func TestAccIntegrationsClient_integrationsClientDeprecatedFieldsExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckIntegrationsClientDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccIntegrationsClient_integrationsClientDeprecatedFieldsExample(context),
},
{
ResourceName: "google_integrations_client.example",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"cloud_kms_config", "create_sample_workflows", "create_sample_integrations", "provision_gmek", "run_as_service_account", "location"},
},
},
})
}

func testAccIntegrationsClient_integrationsClientDeprecatedFieldsExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_integrations_client" "example" {
location = "asia-south1"
provision_gmek = true
create_sample_workflows = true
}
`, context)
}
Expand Down
1 change: 0 additions & 1 deletion website/docs/r/integrations_auth_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ To get more information about AuthConfig, see:
```hcl
resource "google_integrations_client" "client" {
location = "us-west1"
provision_gmek = true
}
resource "google_integrations_auth_config" "basic_example" {
Expand Down
22 changes: 13 additions & 9 deletions website/docs/r/integrations_client.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ To get more information about Client, see:
```hcl
resource "google_integrations_client" "example" {
location = "us-central1"
provision_gmek = true
}
```
<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_working_dir=integrations_client_advance&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<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_working_dir=integrations_client_full&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" 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 - Integrations Client Advance
## Example Usage - Integrations Client Full


```hcl
Expand All @@ -64,12 +63,10 @@ resource "google_kms_crypto_key" "cryptokey" {
name = "crypto-key-example"
key_ring = google_kms_key_ring.keyring.id
rotation_period = "7776000s"
depends_on = [google_kms_key_ring.keyring]
}
resource "google_kms_crypto_key_version" "test_key" {
crypto_key = google_kms_crypto_key.cryptokey.id
depends_on = [google_kms_crypto_key.cryptokey]
}
resource "google_service_account" "service_account" {
Expand All @@ -79,7 +76,7 @@ resource "google_service_account" "service_account" {
resource "google_integrations_client" "example" {
location = "us-east1"
create_sample_workflows = true
create_sample_integrations = true
run_as_service_account = google_service_account.service_account.email
cloud_kms_config {
kms_location = "us-east1"
Expand All @@ -88,7 +85,6 @@ resource "google_integrations_client" "example" {
key_version = google_kms_crypto_key_version.test_key.id
kms_project_id = data.google_project.test_project.project_id
}
depends_on = [google_kms_crypto_key_version.test_key, google_service_account.service_account]
}
```

Expand All @@ -111,13 +107,21 @@ The following arguments are supported:
Structure is [documented below](#nested_cloud_kms_config).

* `create_sample_workflows` -
(Optional)
(Optional, Deprecated)
Indicates if sample workflow should be created along with provisioning.

* `provision_gmek` -
~> **Warning:** `create_sample_workflows` is deprecated and will be removed in a future major release. Use `create_sample_integrations` instead.

* `create_sample_integrations` -
(Optional)
Indicates if sample integrations should be created along with provisioning.

* `provision_gmek` -
(Optional, Deprecated)
Indicates provision with GMEK or CMEK.

~> **Warning:** `provision_gmek` is deprecated and will be removed in a future major release. Client would be provisioned as gmek if `cloud_kms_config` is not given.

* `run_as_service_account` -
(Optional)
User input run-as service account, if empty, will bring up a new default service account.
Expand Down

0 comments on commit 82eda93

Please sign in to comment.