aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.7k stars 3.93k forks source link

cdk migrate: could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping #31987

Open mpMelnikov opened 3 weeks ago

mpMelnikov commented 3 weeks ago

Describe the bug

When I try to generate CDK code for my Lambda using cdk migrate --from-scan most-recent --region eu-south-2 --stack-name ai-news-stack --filter tag-key="project",tag-value="ai-news" --verbose I see the error:

Found 30 resources.
Generating CFN template from scanned resources.
Please wait, template creation in progress. This may take a couple minutes.
[CREATE_IN_PROGRESS] Template Creation in Progress
Template successfully generated!
 ❌  Migrate failed for `ai-news-stack`: AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping00a5458fae72e448b2a44c28858d91c3a0009qGls of type AWS::Lambda::EventSourceMapping
[01:12:11] Reading cached notices from /home/mikhail/.cdk/cache/notices.json
AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping00a5458fae72e448b2a44c28858d91c3a0009qGls of type AWS::Lambda::EventSourceMapping

Regression Issue

Last Known Working CDK Version

No response

Expected Behavior

cdk migrate --from-scan most-recent --region eu-south-2 --stack-name ai-news-stack --filter tag-key="project",tag-value="ai-news" --verbose is executed without errors and CDK code is generated.

Current Behavior

When I try to generate CDK code for my Lambda using cdk migrate --from-scan most-recent --region eu-south-2 --stack-name ai-news-stack --filter tag-key="project",tag-value="ai-news" --verbose I see the error:

Found 30 resources.
Generating CFN template from scanned resources.
Please wait, template creation in progress. This may take a couple minutes.
[CREATE_IN_PROGRESS] Template Creation in Progress
Template successfully generated!
 ❌  Migrate failed for `ai-news-stack`: AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping00a5458fae72e448b2a44c28858d91c3a0009qGls of type AWS::Lambda::EventSourceMapping
[01:12:11] Reading cached notices from /home/mikhail/.cdk/cache/notices.json
AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping00a5458fae72e448b2a44c28858d91c3a0009qGls of type AWS::Lambda::EventSourceMapping

Reproduction Steps

  1. Create Lambda with a tag.
  2. cdk init app --language csharp or cdk init app --language javascript
  3. cdk bootstrap aws://000000000000:eu-south-2
  4. cdk migrate --from-scan most-recent --region eu-south-2 --stack-name ai-news-stack --filter tag-key="project",tag-value="ai-news" --verbose

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.165.0 (build 00f70f1)

Framework Version

No response

Node.js Version

v18.18.2

OS

Ubuntu 22.04.5 LTS

Language

.NET

Language Version

6.0.135

Other information

No response

ashishdhingra commented 2 weeks ago

Followed below mentioned steps using CDK version 2.165.0 (build 00f70f1):

Result: cdk migrate failed with below error:

Using the latest successful scan which is 0 days, 0 hours, and 11 minutes old.
Applying filters to resource scan.
finding related resources.
Found 3 resources.
Generating CFN template from scanned resources.
Please wait, template creation in progress. This may take a couple minutes.
[CREATE_IN_PROGRESS] Template Creation in Progress
Template successfully generated!
 ❌  Migrate failed for `ai-news-stack`: AiNewsStackStack could not be generated because RecursiveLoop is not a valid property for resource LambdaFunction00TestJSFunction00nmcyI of type AWS::Lambda::Function
[11:27:51] Reading cached notices from /Users/ashdhin/.cdk/cache/notices.json
AiNewsStackStack could not be generated because RecursiveLoop is not a valid property for resource LambdaFunction00TestJSFunction00nmcyI of type AWS::Lambda::Function
[11:27:51] Error: AiNewsStackStack could not be generated because RecursiveLoop is not a valid property for resource LambdaFunction00TestJSFunction00nmcyI of type AWS::Lambda::Function
    at generateStack (/opt/homebrew/lib/node_modules/aws-cdk/lib/index.js:520:156222)
    at CdkToolkit.migrate (/opt/homebrew/lib/node_modules/aws-cdk/lib/index.js:523:5125)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async exec4 (/opt/homebrew/lib/node_modules/aws-cdk/lib/index.js:575:56240)

The error is different from the one reported by user though.

Related issue https://github.com/aws/aws-cdk/issues/31696.

@mpMelnikov Thanks for reporting the issue. I got a different error than the one you mentioned. There is an existing issue https://github.com/aws/aws-cdk/issues/31696 for RecursiveLoop is not a valid property error. Please review if you still get the original error and if we could close this issue as duplicate since we already have tracking issue.

Thanks, Ashish

mpMelnikov commented 2 weeks ago

Hi @ashishdhingra, thank you for your test! I'll check it again in clean environment by the end of this week.

github-actions[bot] commented 2 weeks ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

mpMelnikov commented 2 weeks ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

I am still here and need more time.

ashishdhingra commented 2 weeks ago

Sure. I will re-add response requested label.

github-actions[bot] commented 2 weeks ago

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

mpMelnikov commented 1 week ago

@mpMelnikov Thanks for reporting the issue. I got a different error than the one you mentioned. There is an existing issue #31696 for RecursiveLoop is not a valid property error. Please review if you still get the original error and if we could close this issue as duplicate since we already have tracking issue.

Thanks, Ashish

I confirm that the error I observe is different from the one seen by Ashish. What have I done to reproduce it again?

  1. Opened AWS Console in a region where I don't have any resources (us-east-2).
  2. Created Lambda with the tag 'test_tag' = '2024_11_10'.
  3. Created SQS queue with the same tag 'test_tag' = '2024_11_10'.
  4. Added SQS trigger to the Lambda. image
  5. cdk init app --language csharp
  6. cdk migrate --from-scan new --region us-east-2 --stack-name ai-news-stack --filter tag-key="test_tag",tag-value="2024_11_10" --verbose
  7. I see the error I have shared earlier:
    Applying filters to resource scan.
    finding related resources.
    Found 5 resources.
    Generating CFN template from scanned resources.
    Please wait, template creation in progress. This may take a couple minutes.
    [CREATE_IN_PROGRESS] Template Creation in Progress
    Template successfully generated!
    ❌  Migrate failed for `ai-news-stack`: AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping0000a5e5ee989d4414aaa15d88e3f9750900fBpmf of type AWS::Lambda::EventSourceMapping
    [21:33:22] Reading cached notices from /home/mikhail/.cdk/cache/notices.json
    AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping0000a5e5ee989d4414aaa15d88e3f9750900fBpmf of type AWS::Lambda::EventSourceMapping
    [21:33:22] Error: AiNewsStackStack could not be generated because Tags is not a valid property for resource LambdaEventSourceMapping0000a5e5ee989d4414aaa15d88e3f9750900fBpmf of type AWS::Lambda::EventSourceMapping
    at generateStack (/home/mikhail/.nvm/versions/node/v18.18.2/lib/node_modules/aws-cdk/lib/index.js:520:156222)
    at CdkToolkit.migrate (/home/mikhail/.nvm/versions/node/v18.18.2/lib/node_modules/aws-cdk/lib/index.js:523:5125)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async exec4 (/home/mikhail/.nvm/versions/node/v18.18.2/lib/node_modules/aws-cdk/lib/index.js:575:56240)

    image