aws-sagemaker-endpoint_configuration_variant_name doesn't allow to be omitted although it is optional #20966
Labels
bug
Addresses a defect in current functionality.
service/sagemaker
Issues and PRs that pertain to the sagemaker service.
Milestone
Community Note
Terraform CLI and Terraform AWS Provider Version
terraform version
Terraform v1.0.7
Affected Resource(s)
aws-sagemaker-endpoint_configuration_production_variants_variant_name
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
getting error:
│ Error: error creating SageMaker Endpoint Configuration: ValidationException: 1 validation error detected: Value '' at 'pr
oductionVariants.1.member.variantName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^a-zA
-Z0-9?
Panic Output
Expected Behavior
Terraform should create a random variant name since the variant name is not provided
Actual Behavior
Terraform through an error because it received a null value for the variant name
Steps to Reproduce
create a sagemaker endpoint configuration without a variant_name variable inside the production_variants block. Terraform will give you error instead of create a random variant name
terraform apply
Important Factoids
References
**_I reviewed the terraform code here:
https://github.com/hashicorp/terraform-provider-aws/blob/9b0205dd0e9992294ce7ae098e8293d9c7e1774e/aws/resource_aws_sagemaker_endpoint_configuration.go
this block of code below is not correct as the condition is forcing the if statement to apply in all cases
if v, ok := data["variant_name"]; ok {
l.VariantName = aws.String(v.(string))
} else {
l.VariantName = aws.String(resource.UniqueId())
}
the if statement should be changed to:
if v, ok := data["variant_name"]; ok && v.(string) != "" {
or
if v, ok := d.GetOk(data["variant_name"]); ok {_**
The text was updated successfully, but these errors were encountered: