For secrets such as Stripe API keys, they should never be visible to a user.
With Amplify CLI you can add a secret to each lambda function which will allow you to access a secret for each environment. View here
You can run amplify function update
for existing functions or when you create a amplify function add
there will be a prompt to add a secret.
Here is sample node lambda code to access the secret:
const { SSM } = require('aws-sdk');
...
const { Parameters: [ stripeSecretData ] } = await ( new SSM() )
.getParameters({
Names: [ 'STRIPE_SECRET_KEY' ].map(secretName => process.env[ secretName ]),
WithDecryption: true
})
.promise();
STRIPE_SECRET_KEY = stripeSecretData.Value;
When you checkout into another environment and push you will be prompted to add a secret for that new environment if one doesn't exist.
Note there is costs for using AWS secrets manager https://aws.amazon.com/secrets-manager/pricing/ and you must create 1 secret per lambda function.