-
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
AssertionError in lambda.EventSourceMapping
for version 6.13
#3092
Comments
Thank you for reporting @chrispyduck, looks like the issue in the native provider has a workaround - pulumi/pulumi-aws-native#1038 (comment) - did you try that? It might be the quickest way to unblocking your use case. |
Getting another report of this stack trace from a customer. Not yet certain which resource. |
Got a repro: import pulumi
import pulumi_aws as aws
import pulumi_archive as archive
assume_role = aws.iam.get_policy_document(
statements=[
aws.iam.GetPolicyDocumentStatementArgs(
effect="Allow",
principals=[
aws.iam.GetPolicyDocumentStatementPrincipalArgs(
type="Service",
identifiers=["lambda.amazonaws.com"],
)
],
actions=["sts:AssumeRole"],
)
]
)
iam_for_lambda = aws.iam.Role(
"iamForLambda",
assume_role_policy=assume_role.json,
managed_policy_arns=["arn:aws:iam::aws:policy/AmazonSQSFullAccess"],
)
lambda_ = archive.get_file(
type="zip", source_file="lambda.js", output_path="lambda_function_payload.zip"
)
test_lambda = aws.lambda_.Function(
"testLambda",
code=pulumi.FileArchive("lambda_function_payload.zip"),
role=iam_for_lambda.arn,
handler="index.test",
runtime="nodejs18.x",
)
queue = aws.sqs.Queue("queue")
esm = aws.lambda_.EventSourceMapping(
"example", event_source_arn=queue.arn, function_name=test_lambda.arn
) steps:
Same code works fine if |
Looks like the schema for the
And now it is:
I guess it was always meant to have only one parameter but the change of the type is a breaking change. Specifically in the repro above, when we call |
This is very interesting. The new provider looked at
After that the engine stopped interacting with the provider and emitted |
I'm wondering if the intent of this change pulumi/pulumi-terraform-bridge@f0a3ffc is making it worse here, in a sense that the bridge pretends that |
We are still working on a fix but the issue has a workaround - one can specify a value for esm = aws.lambda_.EventSourceMapping(
"example",
event_source_arn=queue.arn,
function_name=test_lambda.arn,
queues="queue",
opts=pulumi.ResourceOptions(delete_before_replace=True),
) This will force the resource to update and work around the issue. |
Should address pulumi/pulumi-aws#3092. Looks like we never actually could produced a diff for cases when TF detects no change in a property but our representation of it has changed. One specific case when this happens is when `MaxItemsOne` is added to a property. This causes us to represent the property with the flattened value instead of an array but we still present it to TF as an array. This PR adds logic for finding and forcing updates in such cases. Here is the changes in the GRPC calls, notice the `queues` property. GRPC before: ``` { "method": "/pulumirpc.ResourceProvider/Diff", "request": { "id": "a36b1ca7-080b-482a-a685-0b087016048d", "urn": "urn:pulumi:dev::aws_esm_py::aws:lambda/eventSourceMapping:EventSourceMapping::example", "olds": { "amazonManagedKafkaEventSourceConfig": null, "batchSize": 10, "bisectBatchOnFunctionError": false, "destinationConfig": null, "documentDbEventSourceConfig": null, "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-d91b62c", "filterCriteria": null, "functionArn": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3", "functionResponseTypes": [], "id": "a36b1ca7-080b-482a-a685-0b087016048d", "lastModified": "2023-12-07T15:11:47Z", "lastProcessingResult": "", "maximumBatchingWindowInSeconds": 0, "maximumRecordAgeInSeconds": 0, "maximumRetryAttempts": 0, "parallelizationFactor": 0, "queues": [], "scalingConfig": null, "selfManagedEventSource": null, "selfManagedKafkaEventSourceConfig": null, "sourceAccessConfigurations": [], "startingPosition": "", "startingPositionTimestamp": "", "state": "Enabled", "stateTransitionReason": "USER_INITIATED", "topics": [], "tumblingWindowInSeconds": 0, "uuid": "a36b1ca7-080b-482a-a685-0b087016048d" }, "news": { "__defaults": [ "enabled" ], "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-d91b62c", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3" }, "oldInputs": { "__defaults": [ "enabled" ], "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-d91b62c", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3" } }, "response": { "stables": [ "queues", "startingPosition", "selfManagedEventSource", "amazonManagedKafkaEventSourceConfig", "topics", "selfManagedKafkaEventSourceConfig", "eventSourceArn", "startingPositionTimestamp" ], "changes": "DIFF_NONE", "hasDetailedDiff": true }, "metadata": { "kind": "resource", "mode": "client", "name": "aws" } } { "method": "/pulumirpc.ResourceMonitor/RegisterResource", "request": { "type": "aws:lambda/eventSourceMapping:EventSourceMapping", "name": "example", "parent": "urn:pulumi:dev::aws_esm_py::pulumi:pulumi:Stack::aws_esm_py-dev", "custom": true, "object": { "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-d91b62c", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3" }, "dependencies": [ "urn:pulumi:dev::aws_esm_py::aws:sqs/queue:Queue::queue", "urn:pulumi:dev::aws_esm_py::aws:lambda/function:Function::testLambda" ], "propertyDependencies": { "eventSourceArn": { "urns": [ "urn:pulumi:dev::aws_esm_py::aws:sqs/queue:Queue::queue" ] }, "functionName": { "urns": [ "urn:pulumi:dev::aws_esm_py::aws:lambda/function:Function::testLambda" ] } }, "version": "6.13.1", "acceptSecrets": true, "supportsPartialValues": true, "acceptResources": true, "sourcePosition": { "uri": "file:///Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi_aws/lambda_/event_source_mapping.py", "line": 1170 } }, "response": { "urn": "urn:pulumi:dev::aws_esm_py::aws:lambda/eventSourceMapping:EventSourceMapping::example", "id": "a36b1ca7-080b-482a-a685-0b087016048d", "object": { "amazonManagedKafkaEventSourceConfig": null, "batchSize": 10, "bisectBatchOnFunctionError": false, "destinationConfig": null, "documentDbEventSourceConfig": null, "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-d91b62c", "filterCriteria": null, "functionArn": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-597cec3", "functionResponseTypes": [], "id": "a36b1ca7-080b-482a-a685-0b087016048d", "lastModified": "2023-12-07T15:11:47Z", "lastProcessingResult": "", "maximumBatchingWindowInSeconds": 0, "maximumRecordAgeInSeconds": 0, "maximumRetryAttempts": 0, "parallelizationFactor": 0, "queues": [], "scalingConfig": null, "selfManagedEventSource": null, "selfManagedKafkaEventSourceConfig": null, "sourceAccessConfigurations": [], "startingPosition": "", "startingPositionTimestamp": "", "state": "Enabled", "stateTransitionReason": "USER_INITIATED", "topics": [], "tumblingWindowInSeconds": 0, "uuid": "a36b1ca7-080b-482a-a685-0b087016048d" } }, "metadata": { "mode": "server" } } ``` Note how `queues` is represented as [] even though we should have flattened it. This causes an exception in the language runtime. GRPC now: ``` { "method": "/pulumirpc.ResourceProvider/Diff", "request": { "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "urn": "urn:pulumi:dev::aws_esm_py::aws:lambda/eventSourceMapping:EventSourceMapping::example", "olds": { "amazonManagedKafkaEventSourceConfig": null, "batchSize": 10, "bisectBatchOnFunctionError": false, "destinationConfig": null, "documentDbEventSourceConfig": null, "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "filterCriteria": null, "functionArn": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionResponseTypes": [], "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "lastModified": "2023-12-08T10:13:23Z", "lastProcessingResult": "", "maximumBatchingWindowInSeconds": 0, "maximumRecordAgeInSeconds": 0, "maximumRetryAttempts": 0, "parallelizationFactor": 0, "queues": [], "scalingConfig": null, "selfManagedEventSource": null, "selfManagedKafkaEventSourceConfig": null, "sourceAccessConfigurations": [], "startingPosition": "", "startingPositionTimestamp": "", "state": "Enabled", "stateTransitionReason": "USER_INITIATED", "topics": [], "tumblingWindowInSeconds": 0, "uuid": "fa076b9b-f38d-424c-999a-15cd0808f2fc" }, "news": { "__defaults": [ "enabled" ], "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649" }, "oldInputs": { "__defaults": [ "enabled" ], "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649" } }, "response": { "stables": [ "startingPosition", "topics", "selfManagedEventSource", "selfManagedKafkaEventSourceConfig", "eventSourceArn", "amazonManagedKafkaEventSourceConfig", "queues", "startingPositionTimestamp" ], "changes": "DIFF_SOME", "diffs": [ "queues" ], "detailedDiff": { "queues": { "kind": "UPDATE" } }, "hasDetailedDiff": true }, "metadata": { "kind": "resource", "mode": "client", "name": "aws" } } { "method": "/pulumirpc.ResourceProvider/Update", "request": { "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "urn": "urn:pulumi:dev::aws_esm_py::aws:lambda/eventSourceMapping:EventSourceMapping::example", "olds": { "amazonManagedKafkaEventSourceConfig": null, "batchSize": 10, "bisectBatchOnFunctionError": false, "destinationConfig": null, "documentDbEventSourceConfig": null, "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "filterCriteria": null, "functionArn": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionResponseTypes": [], "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "lastModified": "2023-12-08T10:13:23Z", "lastProcessingResult": "", "maximumBatchingWindowInSeconds": 0, "maximumRecordAgeInSeconds": 0, "maximumRetryAttempts": 0, "parallelizationFactor": 0, "queues": [], "scalingConfig": null, "selfManagedEventSource": null, "selfManagedKafkaEventSourceConfig": null, "sourceAccessConfigurations": [], "startingPosition": "", "startingPositionTimestamp": "", "state": "Enabled", "stateTransitionReason": "USER_INITIATED", "topics": [], "tumblingWindowInSeconds": 0, "uuid": "fa076b9b-f38d-424c-999a-15cd0808f2fc" }, "news": { "__defaults": [ "enabled" ], "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649" }, "oldInputs": { "__defaults": [ "enabled" ], "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649" } }, "response": { "properties": { "amazonManagedKafkaEventSourceConfig": null, "batchSize": 10, "bisectBatchOnFunctionError": false, "destinationConfig": null, "documentDbEventSourceConfig": null, "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "filterCriteria": null, "functionArn": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionResponseTypes": [], "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "lastModified": "2023-12-08T13:16:33Z", "lastProcessingResult": "", "maximumBatchingWindowInSeconds": 0, "maximumRecordAgeInSeconds": 0, "maximumRetryAttempts": 0, "parallelizationFactor": 0, "queues": null, "scalingConfig": null, "selfManagedEventSource": null, "selfManagedKafkaEventSourceConfig": null, "sourceAccessConfigurations": [], "startingPosition": "", "startingPositionTimestamp": "", "state": "Enabled", "stateTransitionReason": "USER_INITIATED", "topics": [], "tumblingWindowInSeconds": 0, "uuid": "fa076b9b-f38d-424c-999a-15cd0808f2fc" } }, "metadata": { "kind": "resource", "mode": "client", "name": "aws" } } { "method": "/pulumirpc.ResourceMonitor/RegisterResource", "request": { "type": "aws:lambda/eventSourceMapping:EventSourceMapping", "name": "example", "parent": "urn:pulumi:dev::aws_esm_py::pulumi:pulumi:Stack::aws_esm_py-dev", "custom": true, "object": { "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649" }, "dependencies": [ "urn:pulumi:dev::aws_esm_py::aws:sqs/queue:Queue::queue", "urn:pulumi:dev::aws_esm_py::aws:lambda/function:Function::testLambda" ], "propertyDependencies": { "eventSourceArn": { "urns": [ "urn:pulumi:dev::aws_esm_py::aws:sqs/queue:Queue::queue" ] }, "functionName": { "urns": [ "urn:pulumi:dev::aws_esm_py::aws:lambda/function:Function::testLambda" ] } }, "version": "6.13.1", "acceptSecrets": true, "supportsPartialValues": true, "acceptResources": true, "sourcePosition": { "uri": "file:///Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi_aws/lambda_/event_source_mapping.py", "line": 1170 } }, "response": { "urn": "urn:pulumi:dev::aws_esm_py::aws:lambda/eventSourceMapping:EventSourceMapping::example", "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "object": { "amazonManagedKafkaEventSourceConfig": null, "batchSize": 10, "bisectBatchOnFunctionError": false, "destinationConfig": null, "documentDbEventSourceConfig": null, "enabled": true, "eventSourceArn": "arn:aws:sqs:us-east-1:616138583583:queue-69b4360", "filterCriteria": null, "functionArn": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionName": "arn:aws:lambda:us-east-1:616138583583:function:testLambda-924a649", "functionResponseTypes": [], "id": "fa076b9b-f38d-424c-999a-15cd0808f2fc", "lastModified": "2023-12-08T13:16:33Z", "lastProcessingResult": "", "maximumBatchingWindowInSeconds": 0, "maximumRecordAgeInSeconds": 0, "maximumRetryAttempts": 0, "parallelizationFactor": 0, "queues": null, "scalingConfig": null, "selfManagedEventSource": null, "selfManagedKafkaEventSourceConfig": null, "sourceAccessConfigurations": [], "startingPosition": "", "startingPositionTimestamp": "", "state": "Enabled", "stateTransitionReason": "USER_INITIATED", "topics": [], "tumblingWindowInSeconds": 0, "uuid": "fa076b9b-f38d-424c-999a-15cd0808f2fc" } }, "metadata": { "mode": "server" } } ```
Fixes #3092 With these changes EventSourceMapping resources should successfully transition from v5 to v6 version of the provider via an Update plan. The root cause is fixed in pulumi/pulumi-terraform-bridge#1561 and applied here through the bridge dependency update. Specifically the EventSourceMapping example is a special case of a situation where upstream changes of MaxItems=1 list restrictions surface as breaking schema changes for Pulumi state. With the latest bridge versions bridged providers will detect these changes an force an Update plan to migrate the affected resources's state onto the new version. --------- Co-authored-by: Venelin <venelin@pulumi.com> Co-authored-by: pulumi-bot <bot@pulumi.com>
This was released in |
What happened?
I'm testing an upgrade of the python pulumi-aws from 5.10 to 6.13 and i'm seeing an
AssertionError: Unexpected type. Expected 'list' got '<class 'str'>'
that I believe I've narrowed down to uses ofaws.lambda_.EventSourceMapping
resources (by moving a return statement around to find the resource that causes it to fail), e.g.:I've verified that
queue.arn
andlambda_.arn
are strings and that the documentation and SDK code both list these parameters asstr
notlist
, and this code was working as-is before the upgrade, so I suspect this is a bug.Example
I'm trying to create a minimal project to reproduce this issue but I haven't been able to, yet. I'll update once I figure it out. For now all I can report is that every occurrence of
EventSourceMapping
has this problem in my (private) repo.Output of
pulumi about
Additional context
I was hoping to work around this using
aws-native
's version of this resource but I ran into this instead: pulumi/pulumi-aws-native#1038. This is preventing me from upgradingContributing
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: