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

aws-sagemaker-endpoint_configuration_variant_name doesn't allow to be omitted although it is optional #20966

Closed
Abdullah-Altahhan opened this issue Sep 21, 2021 · 3 comments · Fixed by #29915
Labels
bug Addresses a defect in current functionality. service/sagemaker Issues and PRs that pertain to the sagemaker service.
Milestone

Comments

@Abdullah-Altahhan
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

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.

        **_resource "aws_sagemaker_endpoint_configuration" "ec" {

          production_variants {
            model_name             = "linear-learner"
            initial_instance_count = 1
            instance_type          = "ml.t2.medium"
            // variant_name   is not provided as it is optional and terraform is supposed to generate a random one
          }_**

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

  1. 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 {_**

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/sagemaker Issues and PRs that pertain to the sagemaker service. labels Sep 21, 2021
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 21, 2021
@DrFaust92 DrFaust92 removed the bug Addresses a defect in current functionality. label Dec 4, 2022
@DrFaust92
Copy link
Collaborator

DrFaust92 commented Dec 4, 2022

not a bug as API requires this
https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ProductionVariant.html#sagemaker-Type-ProductionVariant-VariantName

Provider usually does not stray from API unless there is a good reason so adding the auto generated id can be done with https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 4, 2023
@jar-b jar-b reopened this Mar 10, 2023
@jar-b
Copy link
Member

jar-b commented Mar 10, 2023

Re-opening. This does appear to be a legitimate bug with configurations that omit the production_variants.0.variant_name attribute. e.g.

resource "aws_sagemaker_endpoint_configuration" "test" {
  name = "jb-test-sagemaker-config"

  production_variants {
    model_name             = aws_sagemaker_model.test.name
    initial_instance_count = 2
    instance_type          = "ml.t2.medium"
    initial_variant_weight = 1
  }
}
│ Error: creating SageMaker Endpoint Configuration: ValidationException: 1 validation error detected: Value '' at 'productionVariants.1.member.variantName' failed to satisfy constraint: Member must satisfy r
egular expression pattern: ^[a-zA-Z0-9]([\-a-zA-Z0-9]*[a-zA-Z0-9])?
│       status code: 400, request id: 3ce60b91-4330-40e6-b50f-a8862c592549
│
│   with aws_sagemaker_endpoint_configuration.test,
│   on main.tf line 43, in resource "aws_sagemaker_endpoint_configuration" "test":
│   43: resource "aws_sagemaker_endpoint_configuration" "test" {

The unconfigured empty string is passed instead of a generated value.

@jar-b jar-b added the bug Addresses a defect in current functionality. label Mar 10, 2023
@github-actions github-actions bot added this to the v4.59.0 milestone Mar 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/sagemaker Issues and PRs that pertain to the sagemaker service.
Projects
None yet
4 participants