I am trying to deploy my serverless.yml
to localstack but I am facing some issues.
I have one serverless.yml
which contains my infrastructure resources such a dynamoDB which I can successfully deploy to localstack.
Another serverless.yml
references those resources in the serverless.yml
like this:
MY_DYNAMODB_TABLE:
!Select [1, !Split ['/', '${cf:${self:custom.infrastructureStack}.MyDynamoDBArn}']]
This works perfectly when I deploy everything to AWS, however when I try to deploy this to localstack I receive this error:
- Cannot resolve variable at "provider.environment.MY_DYNAMODB_TABLE.Fn::Select.1.Fn::Split.1": Value not found at "cf" source,
I am starting localstack via cli and deploying via sls deploy --stage local
When I look at the localstack cli output when deploying I can also not spot any error, the AWS cloudformation.ListStackResources
returns 200
:
2023-04-26T12:38:39.871 INFO --- [ asgi_gw_0] localstack.request.aws : AWS cloudformation.ListStackResources => 200
I am not sure why but I solved it by replacing
MY_DYNAMODB_TABLE:
!Select [1, !Split ['/', '${cf:${self:custom.infrastructureStack}.MyDynamoDBArn}']]
with
MY_DYNAMODB_TABLE:
Fn::ImportValue: MyDynamoDBArn
which worked.