Hi All,
I have a yml resources file which creates a cognito user pool. Then from another serverless.yml file need to store ther user pool id created into an environment variable called USER_POOL_ID.
My cognito-user-pool.yml is:
Resources:
CognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
# Generate a name based on the stage
UserPoolName: ${self:custom.root.serviceName}-${self:custom.root.stage}-${self:custom.root.cognito.USER_POOL_NAME}
# Set email as an alias
UsernameAttributes:
- email
AutoVerifiedAttributes:
- email
CognitoUserPoolClient:
Type: AWS::Cognito::UserPoolClient
Properties:
# Generate an app client name based on the stage
ClientName: ${self:custom.root.serviceName}-${self:custom.root.stage}-${self:custom.root.cognito.USER_POOL_CLIENT_NAME}
UserPoolId:
Ref: CognitoUserPool
ExplicitAuthFlows:
- ADMIN_NO_SRP_AUTH
GenerateSecret: false
Outputs:
UserPoolId:
Value:
Ref: CognitoUserPool
Export:
Name: ${self:custom.root.serviceName}-${self:custom.root.stage}-UserPoolId
UserPoolClientId:
Value:
Ref: CognitoUserPoolClient
Export:
Name: "UserPoolClient::Id"
And then I am referencing the exported output as follows in serverless.yml
USER_POOL_ID:
"Fn::ImportValue": "${self:custom.root.serviceName}-${self:custom.root.stage}-UserPoolId"
Any help is highly appreciated!
Thanks in advance guys