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

imagebuilder fails to serialize types.LaunchTemplateConfiguration.SetDefaultVersion when set to false #736

Open
2 tasks done
DanielRieske opened this issue May 6, 2024 · 6 comments
Assignees
Labels
bug Something isn't working ec2 p2 service-api This issue pertains to the AWS API

Comments

@DanielRieske
Copy link

Acknowledgements

  • I have searched (https:/aws/aws-sdk/issues?q=is%3Aissue) for past instances of this issue
  • I have verified all of my SDK modules are up-to-date (you can perform a bulk update with go get -u github.com/aws/aws-sdk-go-v2/...)

Describe the bug

The types.LaunchTemplateConfiguration.SetDefaultVersion fails to serialize when set to false.

Logging:

  http.request.body=
  | {"clientToken":"terraform-20240505213014851300000002","distributions":[{"amiDistributionConfiguration":{"name":"{{ imagebuilder:buildDate }}"},"containerDistributionConfiguration":{"targetRepository":{"repositoryName":"repository-name","service":"ECR"}},"fastLaunchConfigurations":[{"accountId":"170689858638","enabled":true,"launchTemplate":{"launchTemplateId":"lt-07dac61f7e03c2b40","launchTemplateVersion":"1"},"maxParallelLaunches":6,"snapshotConfiguration":{"targetResourceCount":1}}],"launchTemplateConfigurations":[{"accountId":"170689858638","launchTemplateId":"lt-07dac61f7e03c2b40"}],"region":"us-west-2"}],"name":"tf-acc-test-6166724565934347995"}
  |   # aws_imagebuilder_distribution_configuration.test will be created
  |   + resource "aws_imagebuilder_distribution_configuration" "test" {
  |       + arn          = (known after apply)
  |       + date_created = (known after apply)
  |       + date_updated = (known after apply)
  |       + id           = (known after apply)
  |       + name         = "tf-acc-test-6166724565934347995"
  |       + tags_all     = (known after apply)
  | 
  |       + distribution {
  |           + license_configuration_arns = []
  |           + region                     = "us-west-2"
  | 
  |           + ami_distribution_configuration {
  |               + name               = "{{ imagebuilder:buildDate }}"
  |               + target_account_ids = []
  |             }
  | 
  |           + container_distribution_configuration {
  |               + container_tags = []
  | 
  |               + target_repository {
  |                   + repository_name = "repository-name"
  |                   + service         = "ECR"
  |                 }
  |             }
  | 
  |           + fast_launch_configuration {
  |               + account_id            = "170689858638"
  |               + enabled               = true
  |               + max_parallel_launches = 6
  | 
  |               + launch_template {
  |                   + launch_template_id      = (known after apply)
  |                   + launch_template_version = "1"
  |                 }
  | 
  |               + snapshot_configuration {
  |                   + target_resource_count = 1
  |                 }
  |             }
  | 
  |           + launch_template_configuration {
  |               + account_id         = "170689858638"
  |               + default            = false <--- This argument
  |               + launch_template_id = (known after apply)
  |             }
  |         }
  |     }

Expected Behavior

That the SetDefaultVersion was serialized in it's creation call.

Current Behavior

SetDefaultVersion isn't serialized.

Reproduction Steps

See above but running: https:/bschaatsbergen/terraform-provider-aws/blob/c8a4204284bc59aae965acddba1257239062009a/internal/service/imagebuilder/distribution_configuration_data_source_test.go#L16

Possible Solution

No response

Additional Information/Context

Relates: aws/aws-sdk-go-v2#2162

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2/service/imagebuilder v1.33.3

Compiler and Version used

go version go1.22.2 darwin/arm64

Operating System and version

macOS Sonoma 14.4.1

@RanVaknin
Copy link

Hi @DanielRieske ,

Thanks for reporting this issue. I'm able to reproduce this behavior. What we suspect the issue here is that the ImageBuilder service defines a default value of false to this member, but when the value is not explicitly sent, the service assigns a true default value for it.

We are working on upstreaming this issue to the service and will let you know once we have more details.

Thanks,
Ran~

@RanVaknin RanVaknin added response-requested This issue requires a response to continue service-api This issue pertains to the AWS API p2 and removed needs-triage response-requested This issue requires a response to continue labels May 7, 2024
@RanVaknin RanVaknin transferred this issue from aws/aws-sdk-go-v2 May 7, 2024
@DanielRieske
Copy link
Author

HI @RanVaknin

Thanks for taking a look at this!

From your explanation I understand that this would happen if we don't explicitly set the SetDefaultVersion bool to false and sent it to the service.
However during testing I set it explicitly to false but it wasn't able to serialize in the request body to the API.

And looking at the current implementation of how this argument serializes that makes sense.

Wouldn't this be an issue in the logic for serialization rather than an issue for the imagebuilder service team?

Again thanks for your help so far!

@RanVaknin
Copy link

Hi @DanielRieske ,

Thanks for your patience. The problem here is two fold:

  1. The Go SDK will not serialize the default value if it matches the zero value of that data type. In this case the zero value for a boolean is false, and that is also the default, therefore the serializer will omit the value in order to be more performant.
    This should be circumvented by a default value set on the service side, or with the service annotating their model with the required trait.

  2. The service side default is set to true instead of false. For example, if I send the request without that value you can see that the server side defaults to true, contrary to what the model specifies.

$ aws imagebuilder get-distribution-configuration --distribution-configuration-arn arn:aws:imagebuilder:us-east-1:REDACTED:distribution-configuration/example-distribution-config
{
    "requestId": "REDACTED",
    "distributionConfiguration": {
        "arn": "arn:aws:imagebuilder:us-east-1:REDACTED:distribution-configuration/example-distribution-config",
        "name": "example-distribution-config",
        "distributions": [
            {
                "region": "us-east-1",
                "amiDistributionConfiguration": {
                    "name": "MyAMI-{{ imagebuilder:buildDate }}"
                },
                "launchTemplateConfigurations": [
                    {
                        "launchTemplateId": "lt-REDACTED",
                        "accountId": "REDACTED",
                        "setDefaultVersion": true  <-------
                    }
                ]
            }
        ],
        "dateCreated": "2024-05-07T18:28:35.486Z",
        "tags": {}
    }
}

We are discussing what is the best way to fix this up and will update you as soon as we can.
Thanks,
Ran~

@bschaatsbergen
Copy link

Hey @RanVaknin, just checking in - is there an update on this already?

@ewbankkit
Copy link

N.B. For anyone finding this issue -- this is a problem with AWS SDK for Go v2. We have opened the same issue at aws/aws-sdk-go-v2#2734.

@RanVaknin
Copy link

Internal ticket #V1479153907

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ec2 p2 service-api This issue pertains to the AWS API
Projects
None yet
Development

No branches or pull requests

4 participants