arabold / serverless-export-env

Serverless plugin to export environment variables into a .env file
MIT License
102 stars 34 forks source link

Help with migration from 1.x to 2.x #50

Closed DavidNeiOs closed 2 years ago

DavidNeiOs commented 2 years ago

Working with version 1 I was using the outputs to add some variables manually to the .env file like this:

Outputs:
    AwsRegion:
      Value: ${self:custom.region}

    CognitoUserPoolId:
      Value: !Ref CognitoUserPool

this will output in V1.x

AWS_REGION=us-east-1
COGNITO_USER_POOL_ID=somevalue

I've tried manually adding them to provider.environment but running !Ref on provider (or custom) throws a circular dependency error also adding AWS_REGION to the provider throws an error as it is a reserved keyword.

I'm using these variables for testing

DavidNeiOs commented 2 years ago

I realised this has nothing to do with the plugin but there is in fact a circular dependency since one of the lambdas is postConfirmation for cognitoUserPool so having the name as an environment variable will start the "circle". I believe it will still be interesting to have the option to have the outputs on the .env file