-
Notifications
You must be signed in to change notification settings - Fork 155
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
[python] Pulumi Import Codegen Fails #2517
Comments
Repro for issue:
|
I've been able to reproduce the issue locally, looking into it now |
Found out the main root cause of the issue. Pulumi import reads the state from the AWS provider, then it writes out a PCL block of text from that state. Finally it gives the PCL text to one of our code generators to emit the final piece of code from that resource. The problem here is that AWS provider is reading the state from the cloud incorrectly returning the following: Resource input state{
"urn": "urn:pulumi:stack::project::aws:lb/targetGroup:TargetGroup::test-target-group",
"custom": true,
"type": "aws:lb/targetGroup:TargetGroup",
"inputs": {
"__defaults": [
],
"deregistrationDelay": 300,
"healthCheck": {
"healthyThreshold": 5,
"matcher": "200",
"path": "/",
"timeout": 5,
"unhealthyThreshold": 2
},
"ipAddressType": "ipv4",
"loadBalancingAlgorithmType": "round_robin",
"loadBalancingCrossZoneEnabled": "use_load_balancer_configuration",
"name": "test-target-group",
"port": 80,
"protocol": "HTTP",
"protocolVersion": "HTTP1",
"stickiness": {
"enabled": false,
"type": "lb_cookie"
},
"targetFailovers": [
null
],
"vpcId": "<redacted>"
},
"parent": "urn:pulumi:dev::pythonimportissue::pulumi:pulumi:Stack::pythonimportissue-dev",
"protect": true,
"provider": "<redacted>"
} Notice here the input for property "targetFailovers": [
null
] has recorded a single element during array<{
onDeregistration: string,
onUnhealthy: string
}> The code generators expect such elements to be non-nullable which is why the PCL binder fails when type-checking the resulting PCL text Generated PCL text blockresource test-target-group "aws:lb/targetGroup:TargetGroup" {
deregistrationDelay = 300
healthCheck ={
healthyThreshold = 5,
matcher = "200",
path = "/",
timeout = 5,
unhealthyThreshold = 2
}
ipAddressType = "ipv4"
loadBalancingAlgorithmType = "round_robin"
loadBalancingCrossZoneEnabled = "use_load_balancer_configuration"
name = "test-target-group"
port = 80
protocol = "HTTP"
protocolVersion = "HTTP1"
stickiness ={
enabled = false,
type = "lb_cookie"
}
targetFailovers =[
null]
vpcId = "<redacted>"
options {
protect =true
}
} Will move the issue to |
Looking into the read implementation, the logic looks slightly questionable .. if there's no attributes at all then an empty array is returned. If neither |
Watching this, I'm available to investigate this as a potential bridge bug. |
Just some more info to help reproduce. This provisions a TargetGroup. import pulumi
import pulumi_aws as aws
main = aws.ec2.Vpc("main", cidr_block="10.0.0.0/16")
test = aws.lb.TargetGroup("test",
port=80,
protocol="HTTP",
vpc_id=main.id)
pulumi.export('arn', test.arn) Then I can reproduce with:
|
Found that this line upstream generates a list with an empty map element: There is an issue in the bridge that translates the empty map to null. Repro-as-unit-test is available: pulumi/pulumi-terraform-bridge#1105 We have a potential fix that changes that but there's a lot of testing diligence to roll that out. I recommend finding some workarounds in the meanwhile so we can reduce urgency from P1. Perhaps import code could tolerate it somehow? Could we patch upstream code to return an empty list? |
To resolve the P1, I'll do a patch on the upstream implementation to remove the map if it's got zero elements. |
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
- Add patch to elbv2 target_group to fix #2517
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Workaround for pulumi/pulumi-aws#2517 Don't return single empty map. Return empty list instead.
Fixes #3253 This PR upgrades the provider to match upstream provider version v5.32.0. List of unusual things that defeated upgrade-provider and required manual intervention: - The patch for elbv2 target workaround in #2517 does not apply cleanly to new upstream, had to be redone; I've tested manually that 2517 does not reproduce on top of the new provider, but need to backlog adding a test for it; the relevant ticket is in #2749 - Upstream is gradually removing AWS Go SDK v1. This affected legacy bucket resource that Pulumi retains in spite of upstream having it removed. This is now working again but required another invasive patch to undo upstream changes. - New "verified permissions" module needed to be registered in resources.go to support automatic module inference. - Several new Plugin Framework based resources required patching to support tags; this is slowing us down until we can implement #2962 - Run test of provider shim was breaking as it didn't get all the dependencies, now fixed - Patch from #3290 wouldn't apply because of wrong format (`make upstream.rebase` broken) - had to reformat it - doc_edits.go would keep appending edits to replacements.json; this is fixed
What happened?
When running a
pulumi import ...
command, the importing of the resource succeeds, however, the codegen part fails with an obscure error.Expected Behavior
Pulumi import succeeds and correctly generates the required code definition.
Steps to reproduce
Create pulumi python program on pulumi and generate the appropriate code definition.
pulumi import ....
See error shown above.
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: