From b67be75486b89626fe4f5573d8ca6517781791e3 Mon Sep 17 00:00:00 2001 From: vzilinas Date: Tue, 7 Nov 2023 18:21:55 +0100 Subject: [PATCH 1/4] Set basic_auth to optional in self_managed_kafka_parameters Basic auth is not required. One of credentials needs to be set. --- internal/service/pipes/source_parameters.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/pipes/source_parameters.go b/internal/service/pipes/source_parameters.go index b20c0ec540c..879155cda0f 100644 --- a/internal/service/pipes/source_parameters.go +++ b/internal/service/pipes/source_parameters.go @@ -444,7 +444,7 @@ func sourceParametersSchema() *schema.Schema { Schema: map[string]*schema.Schema{ "basic_auth": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: verifySecretsManagerARN, }, "client_certificate_tls_auth": { From c2ad22a92fbc63f754013211fda287f838e57e4f Mon Sep 17 00:00:00 2001 From: vzilinas Date: Tue, 7 Nov 2023 18:33:52 +0100 Subject: [PATCH 2/4] Add changelog --- .changelog/34293.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/34293.txt diff --git a/.changelog/34293.txt b/.changelog/34293.txt new file mode 100644 index 00000000000..f5fa907fa4e --- /dev/null +++ b/.changelog/34293.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_pipes_pipe: Make self_managed_kafka_parameters.credentials.basic_auth Optional +``` From 6bdd25391e02044b3bab7e120fca65e09ece6f2c Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 6 Jun 2024 07:46:29 -0400 Subject: [PATCH 3/4] Tweak CHANGELOG entry. --- .changelog/34293.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/34293.txt b/.changelog/34293.txt index f5fa907fa4e..d18f5d7d431 100644 --- a/.changelog/34293.txt +++ b/.changelog/34293.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_pipes_pipe: Make self_managed_kafka_parameters.credentials.basic_auth Optional +resource/aws_pipes_pipe: Mark `source_parameters.self_managed_kafka_parameters.credentials.basic_auth` as Optional ``` From 73c6e50243d5bd67c681fab77709e2113ccaf970 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 6 Jun 2024 07:48:58 -0400 Subject: [PATCH 4/4] r/aws_pipes_pipe: Use 'SchemaFunc'. --- internal/service/pipes/exports_test.go | 4 +- internal/service/pipes/pipe.go | 138 +++++++++++++------------ 2 files changed, 72 insertions(+), 70 deletions(-) diff --git a/internal/service/pipes/exports_test.go b/internal/service/pipes/exports_test.go index b27f1e9c5b3..d986d659db9 100644 --- a/internal/service/pipes/exports_test.go +++ b/internal/service/pipes/exports_test.go @@ -5,7 +5,7 @@ package pipes // Exports for use in tests only. var ( - FindPipeByName = findPipeByName - ResourcePipe = resourcePipe + + FindPipeByName = findPipeByName ) diff --git a/internal/service/pipes/pipe.go b/internal/service/pipes/pipe.go index bab8ae24074..ccc87e4ad1b 100644 --- a/internal/service/pipes/pipe.go +++ b/internal/service/pipes/pipe.go @@ -50,74 +50,76 @@ func resourcePipe() *schema.Resource { CustomizeDiff: verify.SetTagsDiff, - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrDescription: { - Type: schema.TypeString, - Optional: true, - Default: "Managed by Terraform", - }, - "desired_state": { - Type: schema.TypeString, - Optional: true, - Default: string(awstypes.RequestedPipeStateRunning), - ValidateDiagFunc: enum.Validate[awstypes.RequestedPipeState](), - }, - "enrichment": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidARN, - }, - "enrichment_parameters": enrichmentParametersSchema(), - "log_configuration": logConfigurationSchema(), - names.AttrName: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ConflictsWith: []string{names.AttrNamePrefix}, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 64), - validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), - ), - }, - names.AttrNamePrefix: { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ConflictsWith: []string{names.AttrName}, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 64-id.UniqueIDSuffixLength), - validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), - ), - }, - names.AttrRoleARN: { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, - names.AttrSource: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.Any( - verify.ValidARN, - validation.StringMatch(regexache.MustCompile(`^smk://(([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z])\.)*([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]):[0-9]{1,5}|arn:(aws[0-9A-Za-z-]*):([0-9A-Za-z-]+):([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.+)$`), ""), - ), - }, - "source_parameters": sourceParametersSchema(), - names.AttrTarget: { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "target_parameters": targetParametersSchema(), - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrDescription: { + Type: schema.TypeString, + Optional: true, + Default: "Managed by Terraform", + }, + "desired_state": { + Type: schema.TypeString, + Optional: true, + Default: string(awstypes.RequestedPipeStateRunning), + ValidateDiagFunc: enum.Validate[awstypes.RequestedPipeState](), + }, + "enrichment": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: verify.ValidARN, + }, + "enrichment_parameters": enrichmentParametersSchema(), + "log_configuration": logConfigurationSchema(), + names.AttrName: { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ConflictsWith: []string{names.AttrNamePrefix}, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 64), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), + ), + }, + names.AttrNamePrefix: { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ConflictsWith: []string{names.AttrName}, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 64-id.UniqueIDSuffixLength), + validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+`), ""), + ), + }, + names.AttrRoleARN: { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, + names.AttrSource: { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.Any( + verify.ValidARN, + validation.StringMatch(regexache.MustCompile(`^smk://(([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z])\.)*([0-9A-Za-z]|[0-9A-Za-z][0-9A-Za-z-]*[0-9A-Za-z]):[0-9]{1,5}|arn:(aws[0-9A-Za-z-]*):([0-9A-Za-z-]+):([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.+)$`), ""), + ), + }, + "source_parameters": sourceParametersSchema(), + names.AttrTarget: { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "target_parameters": targetParametersSchema(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, } }