Duplicated mapping key in env.yml

https://serverless-stack.com/chapters/load-secrets-from-env-yml.html

As per the documentation since we have stripe Test version we will have only stripe security key which we need to keep for both the Prod and Default value.

But when i ran the below command i am getting error like this :

C:\Program Files\Git\serverless-stack-2-api>serverless invoke local --function b
illing --path mocks/billing-event.json

  Y A M L Exception --------------------------------------

  duplicated mapping key in "C:\Program Files\Git\serverless-stack-2-api\env.yml
" at line 15, column -60:
    prod:
    ^

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment v
ariable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     win32
     Node Version:           8.11.3
     Serverless Version:     1.27.3

How can i resolve this ?

Thanks

I can able to resolve this by keeping by changing from

prod:
  stripeSecretKey: "STRIPE_PROD_SECRET_KEY"

default:
  stripeSecretKey: "STRIPE_TEST_SECRET_KEY"

TO

dev:
  APP_NAME: serverless-nodejs-starter
  stripeSecretKey: "xxx"

prod:
  APP_NAME: serverless-nodejs
  # Add the environment variables for the various stages

default:
  stripeSecretKey: "xxx"

Since the whole documentation is in dev we need to change it.

Hmmm I don’t think you need to change it. Your env.yml should look like this:

# Add the environment variables for the various stages

prod:
  stripeSecretKey: "sk_test_abcdefghi"

default:
  stripeSecretKey: "sk_test_abcdefghi"

THANKS @jayair for responding to my question.

Okay , i think i missed something here. Actually my env.yml looks like this

    dev:
      APP_NAME: serverless-nodejs-starter

    prod:
      APP_NAME: serverless-nodejs

As per the documentation i need to edit like this . So, below is my final env.yml

 dev:
  APP_NAME: serverless-nodejs-starter

prod:
  APP_NAME: serverless-nodejs

prod:
  stripeSecretKey: "sk_test_abcdefghi"

default:
  stripeSecretKey: "sk_test_abcdefghi"

As i mentioned above this env.yml gives me error like this

C:\Program Files\Git\serverless-stack-2-api>serverless invoke local --function b
illing --path mocks/billing-event.json

  Y A M L Exception --------------------------------------

  duplicated mapping key in "C:\Program Files\Git\serverless-stack-2-api\env.yml
" at line 15, column -60:

Do you want me to replace env.yml with the lines you had specified or you want to append the lines to the env.yml ?

Thanks

Ah I see. Yeah you need to replace the contents of the file with the new snippet.

I’ll tweak the wording in the tutorial to make it more clear.