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

upgrade dcl to 1.77 #21077

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/12879.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
dataproc: added `encryption_config` to `google_dataproc_workflow_template`
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23

require (
cloud.google.com/go/bigtable v1.33.0
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.76.0
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.77.0
github.com/apparentlymart/go-cidr v1.1.0
github.com/davecgh/go-spew v1.1.1
github.com/dnaeon/go-vcr v1.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.76.0 h1:VH/j8GmTsvPds/NkGfo4OYr9C7R8ysikaqq4rcDUT0s=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.76.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.77.0 h1:fCJw7h8lc8oVQAhoMABdsWAGWF8E6+4A5HvDHe5OsVM=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.77.0/go.mod h1:pL2Qt5HT+x6xrTd806oMiM3awW6kNIXB/iiuClz6m6k=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func ResourceAssuredWorkloadsWorkload() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Required. Immutable. Compliance Regime associated with this workload. Possible values: COMPLIANCE_REGIME_UNSPECIFIED, IL4, CJIS, FEDRAMP_HIGH, FEDRAMP_MODERATE, US_REGIONAL_ACCESS, HIPAA, HITRUST, EU_REGIONS_AND_SUPPORT, CA_REGIONS_AND_SUPPORT, ITAR, AU_REGIONS_AND_US_SUPPORT, ASSURED_WORKLOADS_FOR_PARTNERS, ISR_REGIONS, ISR_REGIONS_AND_SUPPORT, CA_PROTECTED_B, IL5, IL2, JP_REGIONS_AND_SUPPORT, KSA_REGIONS_AND_SUPPORT_WITH_SOVEREIGNTY_CONTROLS, REGIONAL_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS_WITH_US_SUPPORT, IRS_1075",
Description: "Required. Immutable. Compliance Regime associated with this workload. Possible values: COMPLIANCE_REGIME_UNSPECIFIED, IL4, CJIS, FEDRAMP_HIGH, FEDRAMP_MODERATE, US_REGIONAL_ACCESS, HIPAA, HITRUST, EU_REGIONS_AND_SUPPORT, CA_REGIONS_AND_SUPPORT, ITAR, AU_REGIONS_AND_US_SUPPORT, ASSURED_WORKLOADS_FOR_PARTNERS, ISR_REGIONS, ISR_REGIONS_AND_SUPPORT, CA_PROTECTED_B, IL5, IL2, JP_REGIONS_AND_SUPPORT, KSA_REGIONS_AND_SUPPORT_WITH_SOVEREIGNTY_CONTROLS, REGIONAL_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS_US_SUPPORT, IRS_1075",
},

"display_name": {
Expand Down
109 changes: 82 additions & 27 deletions google/services/dataproc/resource_dataproc_workflow_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ func ResourceDataprocWorkflowTemplate() *schema.Resource {
Description: "All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.",
},

"encryption_config": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: "Optional. The encryption configuration for the workflow template.",
MaxItems: 1,
Elem: DataprocWorkflowTemplateEncryptionConfigSchema(),
},

"parameters": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -2015,6 +2024,20 @@ func DataprocWorkflowTemplatePlacementManagedClusterConfigWorkerConfigManagedGro
}
}

func DataprocWorkflowTemplateEncryptionConfigSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"kms_key": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
Description: "Optional. The Cloud KMS key name to use for encryption.",
},
},
}
}

func DataprocWorkflowTemplateParametersSchema() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -2112,15 +2135,16 @@ func resourceDataprocWorkflowTemplateCreate(d *schema.ResourceData, meta interfa
}

obj := &dataproc.WorkflowTemplate{
Jobs: expandDataprocWorkflowTemplateJobsArray(d.Get("jobs")),
Location: dcl.String(d.Get("location").(string)),
Name: dcl.String(d.Get("name").(string)),
Placement: expandDataprocWorkflowTemplatePlacement(d.Get("placement")),
DagTimeout: dcl.String(d.Get("dag_timeout").(string)),
Labels: tpgresource.CheckStringMap(d.Get("effective_labels")),
Parameters: expandDataprocWorkflowTemplateParametersArray(d.Get("parameters")),
Project: dcl.String(project),
Version: dcl.Int64OrNil(int64(d.Get("version").(int))),
Jobs: expandDataprocWorkflowTemplateJobsArray(d.Get("jobs")),
Location: dcl.String(d.Get("location").(string)),
Name: dcl.String(d.Get("name").(string)),
Placement: expandDataprocWorkflowTemplatePlacement(d.Get("placement")),
DagTimeout: dcl.String(d.Get("dag_timeout").(string)),
Labels: tpgresource.CheckStringMap(d.Get("effective_labels")),
EncryptionConfig: expandDataprocWorkflowTemplateEncryptionConfig(d.Get("encryption_config")),
Parameters: expandDataprocWorkflowTemplateParametersArray(d.Get("parameters")),
Project: dcl.String(project),
Version: dcl.Int64OrNil(int64(d.Get("version").(int))),
}

id, err := obj.ID()
Expand Down Expand Up @@ -2168,15 +2192,16 @@ func resourceDataprocWorkflowTemplateRead(d *schema.ResourceData, meta interface
}

obj := &dataproc.WorkflowTemplate{
Jobs: expandDataprocWorkflowTemplateJobsArray(d.Get("jobs")),
Location: dcl.String(d.Get("location").(string)),
Name: dcl.String(d.Get("name").(string)),
Placement: expandDataprocWorkflowTemplatePlacement(d.Get("placement")),
DagTimeout: dcl.String(d.Get("dag_timeout").(string)),
Labels: tpgresource.CheckStringMap(d.Get("effective_labels")),
Parameters: expandDataprocWorkflowTemplateParametersArray(d.Get("parameters")),
Project: dcl.String(project),
Version: dcl.Int64OrNil(int64(d.Get("version").(int))),
Jobs: expandDataprocWorkflowTemplateJobsArray(d.Get("jobs")),
Location: dcl.String(d.Get("location").(string)),
Name: dcl.String(d.Get("name").(string)),
Placement: expandDataprocWorkflowTemplatePlacement(d.Get("placement")),
DagTimeout: dcl.String(d.Get("dag_timeout").(string)),
Labels: tpgresource.CheckStringMap(d.Get("effective_labels")),
EncryptionConfig: expandDataprocWorkflowTemplateEncryptionConfig(d.Get("encryption_config")),
Parameters: expandDataprocWorkflowTemplateParametersArray(d.Get("parameters")),
Project: dcl.String(project),
Version: dcl.Int64OrNil(int64(d.Get("version").(int))),
}

userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
Expand Down Expand Up @@ -2219,6 +2244,9 @@ func resourceDataprocWorkflowTemplateRead(d *schema.ResourceData, meta interface
if err = d.Set("effective_labels", res.Labels); err != nil {
return fmt.Errorf("error setting effective_labels in state: %s", err)
}
if err = d.Set("encryption_config", flattenDataprocWorkflowTemplateEncryptionConfig(res.EncryptionConfig)); err != nil {
return fmt.Errorf("error setting encryption_config in state: %s", err)
}
if err = d.Set("parameters", flattenDataprocWorkflowTemplateParametersArray(res.Parameters)); err != nil {
return fmt.Errorf("error setting parameters in state: %s", err)
}
Expand Down Expand Up @@ -2257,15 +2285,16 @@ func resourceDataprocWorkflowTemplateDelete(d *schema.ResourceData, meta interfa
}

obj := &dataproc.WorkflowTemplate{
Jobs: expandDataprocWorkflowTemplateJobsArray(d.Get("jobs")),
Location: dcl.String(d.Get("location").(string)),
Name: dcl.String(d.Get("name").(string)),
Placement: expandDataprocWorkflowTemplatePlacement(d.Get("placement")),
DagTimeout: dcl.String(d.Get("dag_timeout").(string)),
Labels: tpgresource.CheckStringMap(d.Get("effective_labels")),
Parameters: expandDataprocWorkflowTemplateParametersArray(d.Get("parameters")),
Project: dcl.String(project),
Version: dcl.Int64OrNil(int64(d.Get("version").(int))),
Jobs: expandDataprocWorkflowTemplateJobsArray(d.Get("jobs")),
Location: dcl.String(d.Get("location").(string)),
Name: dcl.String(d.Get("name").(string)),
Placement: expandDataprocWorkflowTemplatePlacement(d.Get("placement")),
DagTimeout: dcl.String(d.Get("dag_timeout").(string)),
Labels: tpgresource.CheckStringMap(d.Get("effective_labels")),
EncryptionConfig: expandDataprocWorkflowTemplateEncryptionConfig(d.Get("encryption_config")),
Parameters: expandDataprocWorkflowTemplateParametersArray(d.Get("parameters")),
Project: dcl.String(project),
Version: dcl.Int64OrNil(int64(d.Get("version").(int))),
}

log.Printf("[DEBUG] Deleting WorkflowTemplate %q", d.Id())
Expand Down Expand Up @@ -3978,6 +4007,32 @@ func flattenDataprocWorkflowTemplatePlacementManagedClusterConfigWorkerConfigMan

return []interface{}{transformed}

}

func expandDataprocWorkflowTemplateEncryptionConfig(o interface{}) *dataproc.WorkflowTemplateEncryptionConfig {
if o == nil {
return dataproc.EmptyWorkflowTemplateEncryptionConfig
}
objArr := o.([]interface{})
if len(objArr) == 0 || objArr[0] == nil {
return dataproc.EmptyWorkflowTemplateEncryptionConfig
}
obj := objArr[0].(map[string]interface{})
return &dataproc.WorkflowTemplateEncryptionConfig{
KmsKey: dcl.String(obj["kms_key"].(string)),
}
}

func flattenDataprocWorkflowTemplateEncryptionConfig(obj *dataproc.WorkflowTemplateEncryptionConfig) interface{} {
if obj == nil || obj.Empty() {
return nil
}
transformed := map[string]interface{}{
"kms_key": obj.KmsKey,
}

return []interface{}{transformed}

}
func expandDataprocWorkflowTemplateParametersArray(o interface{}) []dataproc.WorkflowTemplateParameters {
if o == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,33 @@ func TestAccDataprocWorkflowTemplate_withShieldedVMs(t *testing.T) {
})
}

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

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"project": envvar.GetTestProjectFromEnv(),
"version": "2.0.35-debian10",
"kms_key_name": acctest.BootstrapKMSKeyWithPurposeInLocationAndName(t, "ENCRYPT_DECRYPT", "us-central1", "tf-bootstrap-dataproc-workflow").CryptoKey.Name,
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: funcAccTestDataprocWorkflowTemplateCheckDestroy(t),
Steps: []resource.TestStep{
{
Config: testAccDataprocWorkflowTemplate_encryptionConfig(context),
},
{
ImportState: true,
ImportStateVerify: true,
ResourceName: "google_dataproc_workflow_template.template",
},
},
})
}

func testAccDataprocWorkflowTemplate_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_dataproc_workflow_template" "template" {
Expand Down Expand Up @@ -199,6 +226,73 @@ resource "google_dataproc_workflow_template" "shielded_vms_template" {
`, context)
}

func testAccDataprocWorkflowTemplate_encryptionConfig(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_dataproc_workflow_template" "template" {
name = "template%{random_suffix}"
location = "us-central1"
encryption_config {
kms_key = "%{kms_key_name}"
}
placement {
managed_cluster {
cluster_name = "my-cluster"
config {
gce_cluster_config {
zone = "us-central1-a"
tags = ["foo", "bar"]
}
master_config {
num_instances = 1
machine_type = "n1-standard-1"
disk_config {
boot_disk_type = "pd-ssd"
boot_disk_size_gb = 15
}
}
worker_config {
num_instances = 3
machine_type = "n1-standard-2"
disk_config {
boot_disk_size_gb = 10
num_local_ssds = 2
}
}

secondary_worker_config {
num_instances = 2
}
software_config {
image_version = "%{version}"
}
}
}
}
jobs {
step_id = "someJob"
spark_job {
main_class = "SomeClass"
}
}
jobs {
step_id = "otherJob"
prerequisite_step_ids = ["someJob"]
presto_job {
query_file_uri = "someuri"
}
}
depends_on =[google_kms_crypto_key_iam_member.crypto_key]
}

data "google_project" "project" {}
resource "google_kms_crypto_key_iam_member" "crypto_key" {
crypto_key_id = "%{kms_key_name}"
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
member = "serviceAccount:service-${data.google_project.project.number}@dataproc-accounts.iam.gserviceaccount.com"
}
`, context)
}

func funcAccTestDataprocWorkflowTemplateCheckDestroy(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/assured_workloads_workload.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ The following arguments are supported:

* `compliance_regime` -
(Required)
Required. Immutable. Compliance Regime associated with this workload. Possible values: COMPLIANCE_REGIME_UNSPECIFIED, IL4, CJIS, FEDRAMP_HIGH, FEDRAMP_MODERATE, US_REGIONAL_ACCESS, HIPAA, HITRUST, EU_REGIONS_AND_SUPPORT, CA_REGIONS_AND_SUPPORT, ITAR, AU_REGIONS_AND_US_SUPPORT, ASSURED_WORKLOADS_FOR_PARTNERS, ISR_REGIONS, ISR_REGIONS_AND_SUPPORT, CA_PROTECTED_B, IL5, IL2, JP_REGIONS_AND_SUPPORT, KSA_REGIONS_AND_SUPPORT_WITH_SOVEREIGNTY_CONTROLS, REGIONAL_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS_WITH_US_SUPPORT, IRS_1075
Required. Immutable. Compliance Regime associated with this workload. Possible values: COMPLIANCE_REGIME_UNSPECIFIED, IL4, CJIS, FEDRAMP_HIGH, FEDRAMP_MODERATE, US_REGIONAL_ACCESS, HIPAA, HITRUST, EU_REGIONS_AND_SUPPORT, CA_REGIONS_AND_SUPPORT, ITAR, AU_REGIONS_AND_US_SUPPORT, ASSURED_WORKLOADS_FOR_PARTNERS, ISR_REGIONS, ISR_REGIONS_AND_SUPPORT, CA_PROTECTED_B, IL5, IL2, JP_REGIONS_AND_SUPPORT, KSA_REGIONS_AND_SUPPORT_WITH_SOVEREIGNTY_CONTROLS, REGIONAL_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS, HEALTHCARE_AND_LIFE_SCIENCES_CONTROLS_US_SUPPORT, IRS_1075

* `display_name` -
(Required)
Expand Down