YAML and JSON error aws static.config file

I'm trying to deploy a node.js application on elasticbeanstalk (I'm following directions here http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html), where the following needs to be done:

Step 6 [To update your application with a database] Point 5. On your local computer, update node-express/.ebextensions/static.config to add a production flag to the environment variables.

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs:staticfiles
    option_name: /public
    value: /public
  - option_name: NODE_ENV
    value: production

But when I deploy, I'm getting the error:

2014-08-29 10:15:11     ERROR   The configuration file .ebextensions/static.config in application version git-5376bdbd807e9f181e6a907f996068b4075dffe0-1409278503377 contains invalid YAML or JSON. YAML exception: while parsing a block mapping
 in "<reader>", line 1, column 1:
    option_settings:
    ^
expected <block end>, but found BlockEntry
 in "<reader>", line 5, column 1:
    - option_name: NODE_ENV
    ^
, JSON exception: Unexpected character (o) at position 0.. Update the configuration file.

I'm new to this and unable to figure out how to correct it. Please help.

Can you specify which text editor are you using for creating this YAML file? By any chance are you on a Windows machine? My first guess is that there could be some invalid character in your config file that is not visible in the text editor. If you have already not done so can you double check that there are no ctrl characters etc. in your file. I generally check for such invalid characters in vim.

Second thing to check: YAML is sensitive about whitespace and indentation, so can you double check your indentation are correct. I found this online website for validating your YAML format. You can give it a try.

You can alternatively try the following JSON in your config file. Just replace the contents of the YAML file with this JSON and it should work.

{
  "option_settings": [
    {
      "option_name": "/public", 
      "namespace": "aws:elasticbeanstalk:container:nodejs:staticfiles", 
      "value": "/public"
    }, 
    {
      "option_name": "NODE_ENV", 
      "value": "production"
    }
  ]
}

YAML as specified in the documentation should work just fine if there are no invalid characters and indentation is correct. For now you can try the above json.