Open kunal-stagepilot opened 2 years ago
Workaround Hard code the ARN with the desired region in the template file locally.
Hi @kunal-stagepilot are you working with the AWS Toolkit for Visual Studio or the AWS Toolkit for Visual Studio Code?
It looks like you are referring to the VS Code toolkit, I will move the issue to that repo.
Thanks Christopher!
Hey @kunal-stagepilot ,
Looks like this may be two separate bugs. I'll see what I can replicate on my end and report back.
I can copy/paste and run the command above in terminal and it builds without any issues. It builds successfully.
Now that is interesting. I'm wondering if the toolkit is doing something that causes --region
to become an invalid option.
Can confirm that AWS::Region
is resolved to 'us-east-1' when local debugging despite setting a region and profile in the aws
section. A minimal test case is to ref the region apart of an environment variable:
Environment:
Variables:
MY-REGION: !Ref AWS::Region
Also, buildArguments
/localArguments
should be passed in without delimiters:
"buildArguments": [
"--region", "eu-west-1"
],
"localArguments": [
"--region", "eu-west-1"
]
That's why there was an error. We're passing in the arguments as-is with no shell. Using the above correctly set my environment variable to 'eu-west-1'. I didn't notice this the first read-through since the Toolkit's output makes it look like the command is correct when it actually isn't.
Of course, the fact that the aws
parameters don't do anything is also confusing. It looks like we only use those fields inside the lambda as opposed to invoking SAM CLI. We may need to rethink how this is done since this behavior is clearly counterintuitive.
Describe the bug ${AWS::Region} always resolved to us-east-1 when debugging SAM application locally via VS Code AWS Toolkit.
My lambda function has a layer
While this works when I deploy my application stack to my AWS instance, it incorrectly resolves the region to us-east-1 when I debug locally. My default profile region is set to eu-west-1.
I added this to my debug configuration file, but ${AWS::Region} still resolved to us-east-1
Next, I tried adding
buildArguments
andlocalArguments
to the debug config file:When debugging, I get this error
Error: no such option: --region eu-west-1
It fails on this command: Note: I've truncated paths for brevityI can copy/paste and run the command above in terminal and it builds without any issues. It builds successfully.
To Reproduce
Expected behavior
aws
/region
key in the SAM debug config file.Computer (please complete the following information):