Get the Cognito User Pool ID for creating the UserPoolClient

In my serverless.yaml I am creating a cognito user pool. I want to also create a cognito user pool client, but that requires knowing the userpool’s ID. How can I get the userpool’s ID?

Relevant code:

resources:
  Resources:
    appClient:
      Type: AWS::Cognito::UserPoolClient
      Properties: 
        AllowedOAuthFlows: 
          - code
        AllowedOAuthFlowsUserPoolClient: false
        AllowedOAuthScopes: 
          - email
          - openid
        CallbackURLs: 
          - projectr://pr
        ClientName: AppClient
        GenerateSecret: false
        LogoutURLs: 
          - projectr://pr
        # ReadAttributes: 
        #   - String
        RefreshTokenValidity: 30
        SupportedIdentityProviders: 
          - COGNITO
          - Google
        ###Here is where the problem is. How do I get the UserPoolId?
        UserPoolId: String

    projectRUserPool:
      Type: AWS::Cognito::UserPool
      Properties: 
        AdminCreateUserConfig: 
          AllowAdminCreateUserOnly: false
        AliasAttributes: 
          - email
        AutoVerifiedAttributes: 
          - email
        EmailConfiguration: 
          EmailSendingAccount: DEVELOPER
          ReplyToEmailAddress: #company email#
          SourceArn: #sourceARN#
        MfaConfiguration: OFF
        Policies:
          PasswordPolicy: 
            MinimumLength: 8
            RequireLowercase: true
            RequireNumbers: true
            RequireSymbols: false
            RequireUppercase: true
            TemporaryPasswordValidityDays: 7
        UserPoolName: ProjectR
        UserPoolTags: 
          project: "Project-R"
          state: "Project-R-Dev"

Using Ref function you can get the UserPoolId

UserPoolId:
      Ref: projectRUserPool
1 Like