localstack / serverless-localstack

⚡ Serverless plugin for running against LocalStack
519 stars 83 forks source link

Cannot resolve variable `${cf:}` #218

Closed zoiman closed 9 months ago

zoiman commented 1 year ago

When I try to reference variables from the cloudformation stack like this:

   iam:
     role:
       statements:
         - Effect: 'Allow'
           Action:
             - 'dynamodb:*'
           Resource:
             - ${cf:${self:custom.infrastructureStack}.TableArn}`

I receive the following error when deploying to localstack: - Cannot resolve variable at "provider.iam.role.statements.0.Resource.0": Value not found at "cf" source,

The serverless containing this resource was successfully deployed before to localstack.

Deploying to AWS works.

zoiman commented 1 year ago

I could solve this issue by using the Fn::ImportValue instead of ${cf:}

I have no idea why but it works. It would be interesting to know though...

steffyP commented 1 year ago

Hi @zoiman, we recently discovered that the localstack-serverless plugin behaves different when using serverless v2 vs v3. Could you check if this could be the case for you?

We also recently released localstack-serverless 1.1.0 which should fix the environment variable resolving when using serverless v3.

zjawol commented 1 year ago

Hi @steffyP

I just encountered this issue on my project and found this chat.

My packages: "serverless-localstack": "^1.1.1", "serverless": "^3.34.0", "@aws-sdk/....": "^3.395.0",

It looks like there is an issue as I am getting the same error : Value not found at "cf" source

steffyP commented 1 year ago

Hi @zjawol,

Could you please provide some more details? Ideally a reproducible sample 🙏

Which resource are you using? It's possible that the cloudformation model in LocalStack does not yet support the output you are trying to access.

steffyP commented 9 months ago

This issue seems to be stale. As we didn't get any response in three months, we are closing this issue now. Please feel free to reopen if it still persists, and provide updates logs and details.