Search code examples
node.jsamazon-web-servicesaws-lambdaaws-amplifyaws-sdk-js

Creating process.env variables using AWS Amplify?


With serverless we can add process.env variables by creating a configuration file entry like this:

environment:
    STRIPE_SECRET_KEY: ${self:custom.secrets.stripeSecretKey} # Stripe secret API key

And we can access it in our lambda function like this:

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

How do we do this with AWS Amplify?


Solution

  • You can add variables at your Amplify environment configuration. You can also add variable overrides and select a branch that's gonna use it.

    DOCS: https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html