serverless-localstack
serverless-localstack copied to clipboard
variables in profile name breaks sls logs
I'm getting some strange behavior when i have serverless variables in my profile name, like this:
custom:
defaultStage: local
stage: ${opt:stage, self:custom.defaultStage}
localstack:
stages:
- local
lambda:
mountCode: True
provider:
profile: ${self:custom.stage}Profile
....
Depending on the command and the parameters, I'll sometimes get Error: Profile ${self:custom.stage}Profile does not exist
-
sls deploy
works perfectly. -
sls deploy -s local
throws the error -
sls print
works perfectly. -
sls print -s local
throws the error
sls logs
works differently. if i call it without the stage variable, it tries to call the real aws endpoint
-
sls logs -f myFunc
throwsThe security token included in the request is invalid.
. -
sls print -s local
throws the profile error
Thanks for reporting @yonahforst . This should be fixed in a7189808717cff31aae3f8252167e1375d79d432 - can you please give it another try with the latest version 0.4.26
? Please report here if the problem persists. Thanks
@whummer i think this fix causes the aws endpoints to never be reconfigured.
I get errors saying that the stack/log-group doesn't exist. I assume that's because the endpoints weren't reconfigured and sls is still trying to talk to the real aws endpoint
Thanks for the update @yonahforst . Haven't been able to reproduce this (seems to be working for the examples we tested). Can you please share a small, complete example to reproduce this issue? Thanks!
sure thing @whummer :)
- add profile called
localProfile
to your ~/.aws/credentials - run sls to create a new service
- replace the yml file with this:
service: temp1
custom:
defaultStage: local
stage: ${opt:stage, self:custom.defaultStage}
localstack:
host: http://${env:LOCALSTACK_HOST, 'localhost'}
edgePort: ${env:LOCALSTACK_EDGE_PORT, '4566'}
stages:
- local
provider:
name: aws
runtime: nodejs12.x
region: eu-west-1
stage: ${self:custom.stage}
profile: ${self:custom.stage}Profile
functions:
hello:
handler: handler.hello
plugins:
- serverless-localstack
- run
sls deploy
- run
sls info
. You should getStack with id temp1-local does not exist
- run
sls logs -f hello
. you should getThe specified log group does not exist.
Thanks for the update @yonahforst . Looks like your Serverless stack is using eu-west-1
- just to confirm, are you seeing the same error if you configure DEFAULT_REGION=eu-west-1
in the environment of your LocalStack Docker container? Thanks
hi @whummer, yes I already have DEFAULT_REGION=eu-west-1
set 🙂
I think the problem is here: https://github.com/localstack/serverless-localstack/blob/a7189808717cff31aae3f8252167e1375d79d432/src/index.js#L104-L111
if this.reconfigureAWS()
fails as is said it might, then those endpoints never get reconfigured and stay set to the real aws endpoints
Hi @yonahforst,
do you still have issues with variable resolvment with the latest localstack-serverless plugin?
This issue seems to be stale. As we didn't get any response in two months, and the original report is from 2020, we are closing this issue now. Please feel free to reopen if it still persists, and provide updates logs and details.