getlift / lift

Expanding Serverless Framework beyond functions using the AWS CDK
MIT License
920 stars 112 forks source link

'${construct:myQueueConstruct.dlqArn}' can't be resolved in functions.events.sqs #404

Open lynxSven opened 3 months ago

lynxSven commented 3 months ago

Description

I want to use the dlqArn of a construct to send the errors to another lambda function. When i try to use it in functions.events.sqs I get this error message when I try to deploy Configuration error at 'functions.handleError.events.0.sqs': must match pattern "^arn:"

When I try to use this placeholder in a ENVIRONMENT of the lambda function, like in the queue.md example, it works fine.

Maybe the preprocessor can't handle this placeholder?

How to Reproduce

...
    handler: 'pathToHandler.handler'
    events:
       - sqs: '${construct:myContructQueue.dlqArn}'
 ...

Additional Information

No response

lynxSven commented 3 months ago

It seems like the dlqArn doesn't return the ARN like I would expect. The things that gets resolved is --> myContructQueueDlqAAAAAAAAA,Arn

FYI: AAAAAAAAA, is fake data the value is something else, but i cant find it in this queue. the ARN is a completely different id.

I would expect something like in the reference here. arn:partition:service:region:account-id:resource-id docs and not resourcename+ID,Arn

I am confused where is this from?

lynxSven commented 3 months ago

The myContructQueueDlqAAAAAAAAA,Arn seems to come right out of the deployed Cloudformation.json

And resolves to

"Fn::GetAtt": [
            "myContructQueueDlqAAAAAAAA",
            "Arn"
          ]

Serverless does't seem to understand, that the placeholder gets resolved into an ARN.

mnapoli commented 2 months ago

Hi, unfortunately that seems to be a limitation with Serverless Framework.

Can you try this:

...
    handler: 'pathToHandler.handler'
    events:
       - sqs:
           arn: '${construct:myContructQueue.dlqArn}'
 ...
andrewleek-droplab commented 2 months ago

I am also seeing this issue, but when following your example: ... handler: 'pathToHandler.handler' events:

I get the following message: [!] Invalid configuration encountered at 'functions.handleFailureFunction.events.0.sqs.arn': unsupported string format

mnapoli commented 1 month ago

Mmh can you try this:

...
    handler: 'pathToHandler.handler'
    events:
       - sqs:
           arn: ${construct:myContructQueue.dlqArn}
 ...

sorry for the back and forth