I’m having trouble finding an example so forgive me if it’s my search skills that are lacking here, but has anybody sucessfully set up the Resources section in your serverless.yml file to construct User and Identity Pools automatically?
Really, I’m trying to automate what @fanjie and @jayair have done here:
In your serverless yaml file, you can use cloud formation template to create cognito pool as shown below and then you can use the output of the cognito pool how ever you want, in this example, I created an env variable that will be injected to lambda’s.
I’m also having trouble with this, I can create the user pool, but I can’t seem to reference the user pool as a cognito provider in the identity pool section, and it fails saying the provider name is wrong.
Fails, I’m guessing in part because of order of operations. What I’d like is for the Resources to generate and then fetch the arn to put as my authorizer.
You can still reference the environment variable within the authorizer or define the environment variable for that function. Haven’t tried it but try and see what happens.
If there is dependency issue, Cloud Front provides depends on clause you can use that so you can manage the order of resource creation
@altcatalin Thanks for the idea, but it still barfs on it on a new line.
@pgali The environment variable can be read in the function no problem, but I’m trying to get the framework to set up the authorizer for me automatically. That may be asking to much, I’m beginning to think 8).
Thanks @jonsmirl - your example has been extremely helpful to me. Any chance you could tell me what I’d need to change to configure the User Pool resource so that it is set up to use the user’s email address as their “username”. I can do this via the AWS console but I want to put this config in serverless.yml.
I think you remove the ‘name’ field. But does amplify support that yet? I don’t think they have gotten around to making the userpool stuff configurable yet.
I don’t really know much about amplify. I just want to add the config for my user pool to my serverless service and I was able to take what I needed from your example and use that to create a user pool successfully, just not with the exact config I need.
The ‘name’ field is different to ‘username’ so I don’t think removing that will achieve what I want. Are you able to point me in direction of any docs/tutorials that might help me out? Thanks again!
hi all
so i want use cognito pool id use in lambda function.
i try to import UserPool::Id to env varible and then use env varible inside lambda. but its not work
got a error :circuiler dependency error within serverless deploy