Cognito Managed Login

I recently set up a Cognito user pool and associated app client via the AWS console. Throughout this process, I elected to use the new “Managed Login,” in place of the “Hosted UI.”

It worked okay, so now I decided to put this into code. This is where things fell apart. I cannot figure out how to create a style, or just use the default one programmatically. Not in CloudFormation, Terraform or Pulumi. Did AWS really release this and not provide an API for it or am I missing something. At this point I can have it use the new managed login via IaC but I have to manually go in and create the style via the AWS Console.

Any help would be appreciated here. If the answer is simply, there is no way to do this programmatically, then that is fine, I’ll revert to the Hosted UI.


Related discussions:

Cloudformation do work before EC2 stack destroy
Cognito Federated Identities - where/how to store user profile data?
CloudFormation: Creating Quick-Create Links for Stacks
Bug with Cloudformation JSON strings
Deploying to ECS
Has anyone worked on large apis built on API Gateway?
Cloudformation: What's the difference between the Ref function and the GetAtt function?
Stream logs to CloudWatch during Windows EC2 bootstrap
Cloudformation and User data not working
Managing 3x AWS accounts
Easy-going CloudFormation: cfn-modules
Why is there nearly nothing on the internet about AWS Cognito Sync?
Best way to get started with Cloudformation?
AWS Documentation (2021)
Pedant alert - Cloudformation yaml convention to not indent children
“Why should I learn CloudFormation when we have Terraform?”
Cognito sessions questions
Console Recorder for AWS - Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation template.
CloudFormation String Help
CloudFormation feature support lag is way out of hand
Cloudformation YAML Snippets for VS Code
Former2 - Generate CloudFormation / Terraform / Troposphere templates from your existing AWS resources
Where to store Cognito Logged In User JWT?
How to put my cognito hosted UI in front of my S3 site without allowing people to get around it?
Transforming CloudFormation Documentation
Running CloudFormation Drift Detection on All Your Stacks
Are you using AWS CDK in production?
Cloudformation : What visual JSON editor(s) do you use?
CloudFormation - Custom Resource vs Registry
Should I always verify JSON Web Tokens that get returned from Cognito?
Testing Tutorial?
Introducing AWS CloudFormation Guard (Preview) – a new open-source CLI for infrastructure compliance
Using AWS cognito from a react app
Security issue in CloudFormation was leaking role session credentials for customer accounts
Cross region Cloudformation. Now you can do it with a single file!
JavaScript + Cognito without the Frameworks?
Our AWS Wish List for AWS-mas aka re:invent 2020 - "day one Cloudformation support for every product released"
Amplify Pro/Cons
Single Page App + User Pool(s) + Customer Separation
How to authenticate API requests from Cognito Identity Pool
Can a cloudformation template roll back once complete?
Auto-generate CloudFormation Templates - no code required
How to modify Cognito JWT Tokens, we are using NodeJS
Looking for a tutorial on how to use Cognito with iOS and a web backend
How to properly format list of objects in CloudFormation?
Introducing 37 new resource types in the CloudFormation Registry
AWS Announces the General Availability of AWS CloudFormation Hooks
Does anybody else host almost everything on AWS... EXCEPT use Firebase for auth instead of Cognito?
Is Cognito Identity Pool really free?
AWS Issues (2016)
Amazon Cognito enables native support for AWS WAF
aws-sso-util — what a fantastic project
What to look into next, given cloudformation is telling me my aws::ecs::service timed out while trying to complete.
Is there a way to backup multiple Lambdas?
Some CloudFormation limitations are absurd and ridiculous
How do I get a Cognito user from Lambda authorisation event header using the @aws-sdk npm packages?
Using AWS Cognito & Amplify To Handle All The Login, Register, Email Verification Etc. For You - JS Example (No React, Vue, Angular Etc)
AWS CDK: API: s3 PutBucketPolicy Access Denied and need help
Why does AWS not recommend API keys in API gateway to authenticate clients? What other options are there for exposing an API and providing keys for it. This is an internal service accessing the API and not users through cognito for example
At what point should we use CloudFormation / CDK / TF
Problems with complex deployments and how CDK/CF is designed
Building API Keys with AWS Cognito
Is AWS SAM viable in the long run?
Amazon Cognito introduces tiered pricing for machine-to-machine (M2M) usage
Any word on this seemingly foundational amplify/cognito feature. that's been an issue for 5 years now?
CI/CD with S3, Lambda, and Github
Peek inside your AWS CloudFormation Deployments with timeline view (2024-11-14)
CloudFormation Hooks: New feature to enforce security, cost, and operational compliance before resource provisioning. Think Guard Rails for your IaC.
AWS Cognito Down In Us-East?
Terraform vs CloudFormation (2024-12-14)
Reshape your AWS CloudFormation stacks seamlessly with stack refactoring - AWS
How do I make my serverless stack more secure?
Entire backend is in AWS. What's the best auth provider to use?
Thoughts in 2025 on LZA vs Terraform for compliant architectures?
Best way to implement CI/CD on AWS using CloudFormation with Azure DevOps?
AWS CloudFormation increases the default stacks per account quota to 300,000
CloudFormation locally
Is there a way to programatically (cli) estimate the cost of a cloudformation stack before you launch it?
CloudFormation - Auto scaling groups
Cloudformation passing "CustomJSON" to a layer..
Troubleshooting CloudFormation templates
Automating AWS Config using CloudFormation - or not.
API Gateway Authentication
ECS + CloudFormation without clobbering desired counts?

I think userpools are considered data more that a resource like a table. You can probably configure it with an AWS ask like boto3.

I can’t find the exact AWS documentation that I used as reference, but the way it works is you create the managed login resource through IaC, setting use_cognito_provided_values to true, then query the resource for the JSON template to customise on top of. You can then pass them in as assets and settings, and set use_cognito_provided_values back to false.

https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_cognito/CfnManagedLoginBranding.html

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cognito-idp/describe-managed-login-branding-by-client.html

How are you doing this with the old hosted UI and IaC? I’m using the CLI/API to customize the CSS and logo because I couldn’t find a CFN-base way to do it. Plumi/TF/etc are using the APIs, so should be able to automate it (ie. it’s just a coverage issue).

Here’s my make target for the old hosted UI:

```
.PHONY: ui

ui:

aws cognito-idp set-ui-customization \

--user-pool-id $(call get_ssm_parameter,${PARAMETER_PREFIX}/auth/userpool/id) \

--client-id $(call get_ssm_parameter,${PARAMETER_PREFIX}/auth/userpool/client/id) \

--css “$(shell cat $(CSS_FILE))” \

--image-file fileb://$(IMAGE_FILE)

```

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-managedloginbranding.html

  • For the old UI, I have this:
aws.cognito.UserPoolUICustomization(
    "user-pool-ui-customization",
    user_pool_id=user_pool.id,
    client_id=user_pool_client.id,
    css="",
)
  • This is Pulumi, but it should be conceptually identical in TF/CF. In this case css is mandatory but by setting it to a blank string I avoid it and it gives the not-so-pretty default.

Thanks! This may do it. I use Pulumi and they don’t have this in their AWS provider quite yet. But AWS has it in their Cloud Control API, so I can reference it like aws-native.cognito.ManagedLoginBranding.

I’ll report back if it works.

Thank you. This may be what I was looking for; much appreciated.