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

Warnings emitted when importing aws:lb:Listener, One or more imported inputs failed to validate #4362

Closed
Zaid-Ajaj opened this issue Aug 13, 2024 · 6 comments · Fixed by #4571
Assignees
Labels
area/import An issue related to `pulumi import` or the import resource option. awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed

Comments

@Zaid-Ajaj
Copy link

Similar to #4361 importing aws:lb:Listener works but emits warnings:

  aws:lb:Listener (listener):
    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `aws` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: aws:lb/listener:Listener resource 'listener' has a problem: expected default_action.0.order to be in the range (1 - 50000), got 0. Examine values at 'listener.defaultActions[0].order'.

@Zaid-Ajaj Zaid-Ajaj added the area/import An issue related to `pulumi import` or the import resource option. label Aug 13, 2024
@t0yv0 t0yv0 added the needs-triage Needs attention from the triage team label Aug 13, 2024
@flostadler
Copy link
Contributor

Thanks for reporting this @Zaid-Ajaj! I have a hunch that this is nils/default values for primitives returned by the AWS SDK not being handled correctly.

I tried reproducing this, but couldn't trigger this exact error. But another one:

aws:lb/listener:Listener resource 'testitest' has a problem: expected default_action.0.forward.0.stickiness.0.duration to be in the range (1 - 604800), got 0. Examine values at 'testitest.defaultActions[0].forward.stickiness.enabled'.

This is the Listener I tried importing:

const listener = new aws.lb.Listener("my-listener", {
    loadBalancerArn: loadbalancer.arn,
    port: 80,
    defaultActions: [{
        type: "forward",
        targetGroupArn: targetGroup.arn,
    }],
});

I'm quite sure this line here is triggering the initial issue. It's converting the pointer to Order to an int32, which will yield 0 if Order is nil:
https://github.com/hashicorp/terraform-provider-aws/blob/3724def77810f619392ecb79fd3e40915c0b0214/internal/service/elbv2/listener.go#L977

Similarly this here will trigger the issue I was able to find because it coerces the pointers for stickiness duration & enabled config into primitives:
https://github.com/hashicorp/terraform-provider-aws/blob/3724def77810f619392ecb79fd3e40915c0b0214/internal/service/elbv2/listener.go#L1170-L1171

We'll need to fix the upstream handling of optional values in read for elbv2 Listener.

@flostadler flostadler added kind/bug Some behavior is incorrect or out of spec and removed needs-triage Needs attention from the triage team labels Aug 14, 2024
@flostadler
Copy link
Contributor

Correcting the code of the imported resource and running pulumi up correctly aligns the state.
This is in line with the behavior in upstream. e.g. see Step 4 - Import here hashicorp/terraform-provider-aws#37211 (comment).

Running this terraform program and then importing the resource (terraform import aws_lb_listener.testitest "arn:aws:elasticloadbalancing:eu-central-1:REDACTED:listener/app/my-lb-68bcf24/37b75057b7294e93/8480247a88078e97") shows the same behavior as with Pulumi.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
    }
  }
}

provider "aws" {
  region = "eu-central-1"
}

resource "aws_lb_listener" "testitest" {
    load_balancer_arn = "arn:aws:elasticloadbalancing:eu-central-1:REDACTED:loadbalancer/app/my-lb-68bcf24/37b75057b7294e93"
    port              = 80

    default_action {
        type             = "forward"
        target_group_arn = "arn:aws:elasticloadbalancing:eu-central-1:REDACTED:targetgroup/my-tg-355c5dc/12565d1a2120a867"
    }
}
tf apply output
aws_lb_listener.testitest: Refreshing state... [id=arn:aws:elasticloadbalancing:eu-central-1:REDACTED:listener/app/my-lb-68bcf24/37b75057b7294e93/8480247a88078e97]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_lb_listener.testitest will be updated in-place
  ~ resource "aws_lb_listener" "testitest" {
        id                = "arn:aws:elasticloadbalancing:eu-central-1:REDACTED:listener/app/my-lb-68bcf24/37b75057b7294e93/8480247a88078e97"
        tags              = {}
        # (5 unchanged attributes hidden)

      ~ default_action {
          + target_group_arn = "arn:aws:elasticloadbalancing:eu-central-1:REDACTED:targetgroup/my-tg-355c5dc/12565d1a2120a867"
            # (2 unchanged attributes hidden)

          - forward {
              - stickiness {
                  - duration = 0 -> null
                  - enabled  = false -> null
                }
              - target_group {
                  - arn    = "arn:aws:elasticloadbalancing:eu-central-1:REDACTED:targetgroup/my-tg-355c5dc/12565d1a2120a867" -> null
                  - weight = 1 -> null
                }
            }
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_lb_listener.testitest: Modifying... [id=arn:aws:elasticloadbalancing:eu-central-1:REDACTED:listener/app/my-lb-68bcf24/37b75057b7294e93/8480247a88078e97]
aws_lb_listener.testitest: Modifications complete after 1s [id=arn:aws:elasticloadbalancing:eu-central-1:REDACTED:listener/app/my-lb-68bcf24/37b75057b7294e93/8480247a88078e97]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

@flostadler
Copy link
Contributor

Opened upstream issue: hashicorp/terraform-provider-aws#38861

@flostadler flostadler added the awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). label Aug 14, 2024
@t0yv0
Copy link
Member

t0yv0 commented Aug 14, 2024

Adding this to pulumi/pulumi-terraform-bridge#2028 as well - I do think this could be mitigated by pulumi/pulumi-terraform-bridge#2314 if it could be made to handle recursive values.

@flostadler
Copy link
Contributor

The issue was fixed upstream and just released as part of v5.69.0. This should be fixed when we pull this release into pu-aws in the next days.

@pulumi-bot
Copy link
Contributor

This issue has been addressed in PR #4571 and shipped in release v6.54.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/import An issue related to `pulumi import` or the import resource option. awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants