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

AssertionError in lambda.EventSourceMapping for version 6.13 #3092

Closed
chrispyduck opened this issue Dec 5, 2023 · 9 comments · Fixed by #3126
Closed

AssertionError in lambda.EventSourceMapping for version 6.13 #3092

chrispyduck opened this issue Dec 5, 2023 · 9 comments · Fixed by #3126
Assignees
Labels
customer/feedback Feedback from customers kind/bug Some behavior is incorrect or out of spec p1 A bug severe enough to be the next item assigned to an engineer resolution/fixed This issue was fixed

Comments

@chrispyduck
Copy link

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 of aws.lambda_.EventSourceMapping resources (by moving a return statement around to find the resource that causes it to fail), e.g.:

aws.lambda_.EventSourceMapping(
    "queue",
    event_source_arn=queue.arn,
    function_name=lambda_.arn,
    opts=opts,
)

I've verified that queue.arn and lambda_.arn are strings and that the documentation and SDK code both list these parameters as str not list, 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

CLI          
Version      3.94.0
Go Version   go1.21.3
Go Compiler  gc

Plugins
NAME        VERSION
aws         6.13.0
aws-native  0.90.0
datadog     4.23.0
python      unknown

Host     
OS       darwin
Version  14.1.1
Arch     arm64

This project is written in python: executable='./env/bin/python' version='3.9.16'

Backend        
Name           pulumi.com
URL            *removed*
User           *removed*
Organizations  *removed*
Token type     personal

Dependencies:
NAME                     VERSION
blinker                  1.7.0
boltons                  20.2.1
boto3                    1.28.17
datadog-api-client       2.19.0
dnspython                2.4.2
Flask                    2.2.3
hiredis                  2.2.3
inflection               0.5.1
launchdarkly-server-sdk  7.6.1
lxml                     4.9.3
orjson                   3.9.10
pip                      22.3.1
pulumi-aws               6.13.0
pulumi-aws-native        0.90.0
pulumi-datadog           4.23.0
pydantic                 2.5.2
redis                    4.6.0
regret                   0.45.2
retry                    0.9.2
rich                     13.7.0
sentry-sdk               1.38.0
setuptools               69.0.2
tomli                    2.0.1
tomlkit                  0.12.3

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 upgrading

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).

@chrispyduck chrispyduck added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 5, 2023
@chrispyduck
Copy link
Author

Per @t0yv0 this may be related to #3075

@VenelinMartinov
Copy link
Contributor

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.

@iwahbe iwahbe removed the needs-triage Needs attention from the triage team label Dec 6, 2023
@t0yv0 t0yv0 added the customer/feedback Feedback from customers label Dec 6, 2023
@t0yv0
Copy link
Member

t0yv0 commented Dec 6, 2023

Getting another report of this stack trace from a customer. Not yet certain which resource.

@lukehoban lukehoban added the p1 A bug severe enough to be the next item assigned to an engineer label Dec 7, 2023
@VenelinMartinov
Copy link
Contributor

VenelinMartinov commented Dec 7, 2023

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:

  1. pulumi up with pulumi-aws version 5.42.0.
  2. pulumi up with pulumi-aws version 6.13.1.
  3. Observe failure:
  pulumi:pulumi:Stack (aws_esm_py-dev):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/opt/homebrew/bin/pulumi-language-python-exec", line 197, in <module>
        loop.run_until_complete(coro)
      File "/Users/vvm/.pyenv/versions/3.11.6/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
        return future.result()
               ^^^^^^^^^^^^^^^
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/stack.py", line 137, in run_in_stack
        await run_pulumi_func(lambda: Stack(func))
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
        await wait_for_rpcs()
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/stack.py", line 83, in wait_for_rpcs
        raise exn from cause
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/rpc_manager.py", line 71, in rpc_wrapper
        result = await rpc
                 ^^^^^^^^^
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/resource.py", line 1029, in do_register
        rpc.resolve_outputs(
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/rpc.py", line 1122, in resolve_outputs
        translated_value = translate_output_properties(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/rpc.py", line 1001, in translate_output_properties
        element_type = _get_list_element_type(typ)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/vvm/code/programs/aws_esm_py/venv/lib/python3.11/site-packages/pulumi/runtime/rpc.py", line 166, in _get_list_element_type
        raise AssertionError(f"Unexpected type. Expected 'list' got '{typ}'")
    AssertionError: Unexpected type. Expected 'list' got '<class 'str'>'

Same code works fine if pulumi up-d with 6.13.1 from the start, so likely some migration thing.

@VenelinMartinov
Copy link
Contributor

Looks like the schema for the queue parameter for EventSourceMapping changed:
In 5.43.0 it was:

"queues": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": "The name of the Amazon MQ broker destination queue to consume. Only available for MQ sources. A single queue name must be specified.\n"
                },

And now it is:

"queues": {
                    "type": "string",
                    "description": "The name of the Amazon MQ broker destination queue to consume. Only available for MQ sources. The list must contain exactly one queue name.\n"
                },

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 "/pulumirpc.ResourceMonitor/RegisterResource" for EventSourceMapping, we used to pass "queues": [] but now we pass "queues":null. Passing [] triggers the exception.

@t0yv0
Copy link
Member

t0yv0 commented Dec 7, 2023

This is very interesting. The new provider looked at queues: [] state and responded with DIFF_NONE.

{
    "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"
    }
}

After that the engine stopped interacting with the provider and emitted queues: [] from RegisterResource back to the Python language SDK, violating the type contract, and causing the runtime failure in the Python SDK.

@t0yv0
Copy link
Member

t0yv0 commented Dec 7, 2023

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 []->null translation is done implicitly but does not inform the engine..

@VenelinMartinov
Copy link
Contributor

VenelinMartinov commented Dec 8, 2023

We are still working on a fix but the issue has a workaround - one can specify a value for queues. For example:

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.
Once updated, one can then remove the queues value and run pulumi up again, which should get to the desired end state.
NOTE: This will cause a REPLACEMENT of the resource, which could trigger replacements of any resources which depend on it.
Also note that delete_before_replace is needed here.

VenelinMartinov added a commit to pulumi/pulumi-terraform-bridge that referenced this issue Dec 11, 2023
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"
    }
}
```
t0yv0 added a commit that referenced this issue Dec 11, 2023
The test will still fail if a Replace plan is generated for any of the resources. However Update
plans are now tolerated. This helps pass on a new bridge update that creates an Update plan to
compensate for schema changes in EventSourceMapping. See #3122 and #3092.
t0yv0 added a commit that referenced this issue Dec 12, 2023
The test will still fail if a Replace plan is generated for any of the resources. However Update
plans are now tolerated. This helps pass on a new bridge update that creates an Update plan to
compensate for schema changes in EventSourceMapping. See #3122 and #3092.
t0yv0 added a commit that referenced this issue Dec 12, 2023
The test will still fail if a Replace plan is generated for any of the resources. However Update
plans are now tolerated. This helps pass on a new bridge update that creates an Update plan to
compensate for schema changes in EventSourceMapping. See #3122 and #3092.
@t0yv0 t0yv0 mentioned this issue Dec 12, 2023
VenelinMartinov pushed a commit that referenced this issue Dec 12, 2023
The test will still fail if a Replace plan is generated for any of the
resources. However Update plans are now tolerated. This helps pass on a
new bridge update that creates an Update plan to compensate for schema
changes in EventSourceMapping. See #3122 and #3092.
VenelinMartinov added a commit that referenced this issue Dec 12, 2023
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>
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Dec 12, 2023
@VenelinMartinov
Copy link
Contributor

This was released in v6.13.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer/feedback Feedback from customers kind/bug Some behavior is incorrect or out of spec p1 A bug severe enough to be the next item assigned to an engineer resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants