aws-sam-cli: Error: AllowOrigin must be a quoted string when using !Sub/!ImportValue
Description
Template uses !Sub to determine the CORS string to use. When using sam local start-pi the following error is thrown: b’Error: AllowOrigin must be a quoted string (i.e. “'value'” is correct, but “value” is not).\n’
Steps to reproduce
In template.yml specify AllowOrigin field to use !Sub, for example:
AllowOrigin: !Sub
- "'https://${FrontEndDomainName}.${dnszone}'"
- {dnszone: !ImportValue mydomain-com-ZoneName}
Then sam build --use-container && sam local start-api
Observed result
Found ‘15’ API Events in Serverless function with name ‘myprojectApiLambda’ Sending Telemetry: {‘metrics’: [{‘commandRun’: {‘awsProfileProvided’: False, ‘debugFlagProvided’: True, ‘region’: ‘’, ‘commandName’: ‘sam local start-api’, ‘duration’: 135, ‘exitReason’: ‘UserException’, ‘exitCode’: 1, ‘requestId’: ‘226f246e-d2cb-4cd9-a496-a706b32e3284’, ‘installationId’: ‘450286d8-42a1-4f22-9c69-81080b051b56’, ‘sessionId’: ‘0d0e0c51-2097-4d57-9fb5-8569204975c9’, ‘executionEnvironment’: ‘CLI’, ‘pyversion’: ‘3.7.2’, ‘samcliVersion’: ‘0.22.0’}}]} HTTPSConnectionPool(host=‘aws-serverless-tools-telemetry.us-west-2.amazonaws.com’, port=443): Read timed out. (read timeout=0.1) Error: AllowOrigin must be a quoted string (i.e. “‘value’” is correct, but “value” is
Expected result
Should work…!
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: OSX Mojave
sam --version
: 0.22
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 24 (10 by maintainers)
@jfuss - tried the latest version and it looks like this problem has now been fixed. (I noticed the warning too).
Thank you!!! I can finally get upgraded to the latest version.
I think in an ideal world it’d be nice if I could avoid the need for the proxy to get cors to work locally, but I have a quite usable solution now so I’m happy.
@awood45 - noticed this has “more info needed” tag - are you needing anything further from me?
I also don’t think this should be classified as a feature request as it worked in previous versions. (I’m personally still stuck on 0.16 until both this and the MFA bugs are fixed)