question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: AllowOrigin must be a quoted string when using !Sub/!ImportValue

See original GitHub issue

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)

  1. OS: OSX Mojave
  2. sam --version: 0.22

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
johnc44commented, Mar 24, 2020

@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.

1reaction
johnc44commented, Dec 11, 2019

@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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: AllowOrigin must be a quoted string when using !Sub ...
Description Template uses !Sub to determine the CORS string to use. When using sam local start-pi the following error is thrown: b'Error: ...
Read more >
CorsConfiguration - AWS Serverless Application Model
Manage cross-origin resource sharing (CORS) for your API Gateway APIs. Specify the domain to allow as a string or specify a dictionary with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found