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

Allow empty values in Service Catalog provisioning parameters #21669

Merged
merged 4 commits into from
Nov 9, 2021
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/21669.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_servicecatalog_provisioned_product: Allow empty values in provisioning parameters
```
4 changes: 2 additions & 2 deletions internal/service/servicecatalog/provisioned_product.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func expandServiceCatalogProvisioningParameter(tfMap map[string]interface{}) *se
apiObject.Key = aws.String(v)
}

if v, ok := tfMap["value"].(string); ok && v != "" {
if v, ok := tfMap["value"].(string); ok {
apiObject.Value = aws.String(v)
}

Expand Down Expand Up @@ -629,7 +629,7 @@ func expandServiceCatalogUpdateProvisioningParameter(tfMap map[string]interface{
apiObject.UsePreviousValue = aws.Bool(v)
}

if v, ok := tfMap["value"].(string); ok && v != "" {
if v, ok := tfMap["value"].(string); ok {
apiObject.Value = aws.String(v)
}

Expand Down
47 changes: 45 additions & 2 deletions internal/service/servicecatalog/provisioned_product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestAccServiceCatalogProvisionedProduct_basic(t *testing.T) {
"accept_language",
"ignore_errors",
"provisioning_artifact_name",
"provisioning_parameters",
"retain_physical_resources",
},
},
Expand Down Expand Up @@ -175,11 +176,33 @@ resource "aws_s3_bucket_object" "test" {
content = jsonencode({
AWSTemplateFormatVersion = "2010-09-09"

Parameters = {
VPCPrimaryCIDR = {
Type = "String"
}
LeaveMeEmpty = {
Type = "String"
Description = "Make sure that empty values come through. Issue #21349"
}
}

"Conditions" = {
"IsEmptyParameter" = {
"Fn::Equals" = [
{
"Ref" = "LeaveMeEmpty"
},
"",
]
}
}

Resources = {
MyVPC = {
Type = "AWS::EC2::VPC"
Type = "AWS::EC2::VPC"
Condition = "IsEmptyParameter"
Properties = {
CidrBlock = "10.1.0.0/16"
CidrBlock = { Ref = "VPCPrimaryCIDR" }
}
}
}
Expand Down Expand Up @@ -268,6 +291,16 @@ resource "aws_servicecatalog_provisioned_product" "test" {
product_id = aws_servicecatalog_product.test.id
provisioning_artifact_name = %[1]q
path_id = data.aws_servicecatalog_launch_paths.test.summaries[0].path_id

provisioning_parameters {
key = "VPCPrimaryCIDR"
value = "10.1.0.0/16"
}

provisioning_parameters {
key = "LeaveMeEmpty"
value = ""
}
}
`, rName))
}
Expand All @@ -281,6 +314,16 @@ resource "aws_servicecatalog_provisioned_product" "test" {
provisioning_artifact_name = %[1]q
path_id = data.aws_servicecatalog_launch_paths.test.summaries[0].path_id

provisioning_parameters {
key = "VPCPrimaryCIDR"
value = "10.2.0.0/16"
}

provisioning_parameters {
key = "LeaveMeEmpty"
value = ""
}

tags = {
%[2]q = %[3]q
}
Expand Down