TLP
TLP

Reputation: 1288

Dynamic domain name prefix for Cognito User Pool domain

I'm using Serverless Framework to create a Cognito user pool and based on the stage I'm deploying, I would like domain name prefixes like myapp-dev, myapp-staging, etc. The code I'm using in serverless.yml is like this:

  CognitoUserPoolDomain:
    Type: AWS::Cognito::UserPoolDomain
    Properties:
      Domain: myapp-${self:custom_stage}
      UserPoolId:
        Ref: CognitoUserPool

and

custom:
  stage: ${opt:stage, self:provider.stage}

The ${self:custom_stage} variable works for all other resources but not for the domain name as it's complaining about illegal characters. Is there another way to do this?

Upvotes: 1

Views: 1467

Answers (2)

TLP
TLP

Reputation: 1288

It turns out that the real name I was using instead of myapp was not accepted because it contained number characters. I've removed them and it works now.

It don't know why it wouldn't accept number characters, though, as the documentation says they can be used.

Upvotes: 0

pkarfs
pkarfs

Reputation: 1039

Looking at the AWS Documentation, I would say your issue isn't with using the variable '${self:custom_stage}' but in that you are providing a string for the name without the top-level-domain accompaniment. Try adding the suffix to the name (e.g: .com).

Upvotes: 1

Related Questions