Phantom CloudFront distribution blocks me from creating Cognito Custom domain - amazon-web-services

today i ran into the problem, that phantom CloudFront distribution blocks me from creating Cognito Custom domain.
I use 2 different aws accounts one for dev and one for prod. So i first created a cognito pool and tested the custom domain feature. Let us use "auth.blabla.com" so this domain as custom domain for that pool.
When i was finished testing i deleted the cognito pool and with it the custom domain, went to the prod account and tried to use the new same domain "auth.blabla.com" as custom domain. And got an error saying
One or more of the CNAMEs you provided are already associated with a different resource. (Service: AmazonCloudFront; Status Code: 409; Error Code: CNAMEAlreadyExists; Request ID: *******-****-****-****-************; Proxy: null)
But i can't access the distribution cognito created on my behalf for the pool (neither over the web-ui nor over the cli). I thought aws would delete it too when i delete the cognito pool. Seems like it doesn't...
Does aws delete it over some time (3-6hours) or am I on a dead end with that domain?

The CloudFront distribution that AWS creates for the custom Cognito domain will be removed in a few hours after you delete the user pool (or delete the custom domain via the Cognito console / API). This seems to be completely hidden from the user (you).

Related

How do I configure multiple AWS Connect instances from different accounts with AWS Single Sign On in a top level account?

I am setting up our telephony system in AWS and we're utilizing AWS Single Sign On for our primary SAML authentication. This has worked fine for normal cli and console access but has kind of been a struggle for implementing Amazon Connect through the SSO Cloud Applications configuration.
Background
I have done a proof of concept with a single Amazon Connect instance and was able to federate login with a number of different permissions sets to simulate admin, developer, and user access for the single instance. This worked fine until I started adding additional instances and each time any user permission set tries to login to Amazon Connect they get Session Expired on the Connect screen.
Our setup is as follows:
Root account contains AWS SSO Directory
Dev Account has 1 Connect instance in the east
QA Account has 2 Connect instances total in east and west
Prod account has 2 Connect instances total in east and west
A lot of the documentation I've been reading seems it assumes the Amazon Connect instances are in the same account as the Amazon SSO service. Additionally the documentation mentions creating additional IAM Identity Providers for each Amazon Connect instance's SAML Metadata file, and a role associated that allows the SSO user to access that instance. I see where this would work in a single account, but I don't understand how to adopt the access role and implement it as a permissions policy in AWS SSO for the user group thats logging into the instance.
I've configured everything as close as possible to the Amazon Connect SAML Setup Guide, and I'm working on troubleshooting the permissions policy stuff to configure access, I'm just at a loss.
If anyone has previous Amazon SSO experience, or has done something similar with Amazon Connect that would be greatly appreciated. I just want to be able to validate whether this is feasible in the current iteration of Amazon SSO (granted its a newer service), or we need to architect and integrate a 3rd party SSO for Amazon Connect.
Thanks!
We recently have this kind of setup and requirements and still in the testing phase but so far, it is working as expected.
In the Amazon Connect SAML Guide that you linked, there's a lacking piece of information in there with regards to the Attributes Mapping (Step 10)
Change From:
Field: https://aws.amazon.com/SAML/Attributes/Role
Value:
arn:aws:iam::<12-digit-account_id>:saml-provider/,arn:aws:iam::<12-digit-account_id>:role/
To This:
Field: https://aws.amazon.com/SAML/Attributes/Role
Value:
arn:aws:iam::ACCOUNT-ID:saml-provider/IDP_PROVIDER_NAME,arn:aws:iam::ACCOUNT-ID:role/ROLE_NAME
Sample Value:
arn:aws:iam::123456301789:saml-provider/AWSSSO_DevelopmentConnect,arn:aws:iam::123456301789:role/AmazonConnect_Development_Role
The Setup:
Root AWS
Configured with AWS SSO
In AWS SSO page, you can have 1 or more Amazon Connect Applications here
AmazonConnect-Development
AmazonConnect-QAEast
AmazonConnect-QAWest
Dev AWS:
You have setup Amazon Connect
AmazonConnect-Development as the Instance Name (Record the ARN)
Create a new Identity Provider (for ex: AWSSSO_DevelopmentConnect)
Create a Policy (to be attached in the Role)
Create a Role (for ex: AmazonConnect_Development_Role)
See more here for the content of Policy
In Root AWS, configure your AmazonConnect-Development application to have the Attribute Mapping pattern same with my above example value.
You also specify the Relay State URL for you want the users to be redirected to a specific Amazon Connecct application.
xxx AWS:
Same steps will be applied as the above
Key Points:
For each AWS Account:
You will need to Create Identity Provider, name it with a pattern
Create a Policy to be attached in the Role
Create a Role and Choose SAML 2.0 Federation
Checked: Allow programmatic and AWS Management Console access
Link the Identity Provider with the Role
For the Applications that you configure in the AWS SSO page, make sure the additional Attribute Mappings have the correct value

How to use AWS user pool access tokens to access AWS resources?

I have been using AWS cognito to create users and issue access tokens. I did this by setting up a custom domain (to sign in) and allowing implicit code grant etc...
Next I set up a identity pool which gives access to s3 objects through cloudfront. Then I added the user pool as a provider using the id and client ID.
I got to my oauth domain, logged in, then got my access token in the url. All well and good.
I finally sent a request to my original cloudfront domain to try and access my private s3 object. However the request was not allowed.
This lead me to have a few questions:
How do I associate the access token to IAM role? Does AWS not pick up the access token and add the IAM roles to the request automatically? Do I have to make another request to the identity pool to get another token with IAM role information?
Do I have to put custom authorizers infront of cloudfront like Authorization#Edge?
I also have an ALB and lambda functions. Do I need to add custom authorizers for each of these to tranform the access token to IAM roles for each request. Is there a common way for all?
Thanks in advance.

AWS Cognito Custom domain: The limit for custom domains is: 4. LimitExceededException;

We use AWS Cognito, with 2 user pools. Each user pool has one prefix domain, which work as expected.
Now I am trying to set up a custom domain for one user pool as per the instructions here:
https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html
But the following error occurs:
The limit for custom domains is: 4. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: LimitExceededException;Request ID: xxx-xxx-xxx)
I use the Management console, as root account owner, who has the permission to create custom domains and cloudfront distributions, i assume. I also use Route53 as the DNS provider and have a wildcard SSL certificate in AWS Certificate manager, for the domain name used.
I don't have even one custom domain. Why is it throwing a LimitExceededException?
Just encounter the same problem here. looks like it's a known issue.
Please check :
https://docs.aws.amazon.com/cognito/latest/developerguide/limits.html
Maximum number of custom domains per account is 4

Create AWS IAM users based on e-mail domain

I am setting up an AWS Account, the account will be used by an organization of employees for EC2 use/experimentation. Obviously, I do not want to distribute the root login info or set up one single IAM user for everyone to use. Unfortunately, I do not have the time to manage creating individual IAM users for everyone on a regular basis.
So, is there a way to auto-create IAM users based on a given email's domain on their first login attempt? The users should have read-only roles to begin, then an Administrator could give more roles as needed to each user. I am open to suggestions, perhaps lambda functions or linking to an identity provider?
Keep in mind that these new IAM users need to have access to the AWS Management Console, this is not necessarily intended for login to applications hosted on AWS.
Update:
Moving forward using this AWS Management Console Federation Proxy Sample found in Amazon's code reference, using with Microsoft Exchange hosted email.
If your existing identity provider supports SAML2 Federation, you can set it up to login to the AWS Management Console.
For more details refer Enabling SAML 2.0 Federated Users to Access the AWS Management Console.
Else you can implement a custom Federation Broker to return an URL to the user, after they authenticate with their corporate credentials.
For more details refer Creating a URL that Enables Federated Users to Access the AWS Management Console (Custom Federation Broker).

AWS Multi-Region webapp with centralised login services

We currently have a webapp running in AWS Region Ireland (service for the UK) and are planing to expand the service into the US.
In order to be sure that the US users get a low latency experience we are considering mirroring the AWS resources used Ireland in the US.
The data for the US users should be stored in the US region, the UK data in Ireland. (There is no need to report across both regions).
We are thinking of building a centralised login services that runs in the Ireland region. After successful login the user will be redirected to the region where his data is stored. (The login service has to know in which region the data is stored)
Has anyone built something similar? Any recommendation how to approach this?
Would Amazon Cognito support such a setup (if we build the login service based on cognito)?
Currently Amazon Cognito does not support this out of the box.
But if you use Cognito User Pools with Federated identities the credentials you get can be used in any AWS region. Along with that you can store a custom attribute for the user defining the region to which that user belongs and then redirect them accordingly.