Closed Zaid-Ajaj closed 2 months ago
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.
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 https://github.com/hashicorp/terraform-provider-aws/issues/37211#issuecomment-2127911378.
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"
}
}
Opened upstream issue: https://github.com/hashicorp/terraform-provider-aws/issues/38861
Adding this to https://github.com/pulumi/pulumi-terraform-bridge/issues/2028 as well - I do think this could be mitigated by https://github.com/pulumi/pulumi-terraform-bridge/issues/2314 if it could be made to handle recursive values.
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.
This issue has been addressed in PR #4571 and shipped in release v6.54.0.
Similar to #4361 importing
aws:lb:Listener
works but emits warnings: