If you are getting AccessDeniedException
An error occurred (AccessDeniedException) when calling the CreateUserPoolDomain operation: User: arn:aws:iam::<aws_account_id>:user/amplify-dev is not authorized to perform: cognito-idp:CreateUserPoolDomain on resource: arn:aws:cognito-idp:us-west-2:<aws_account_id>:userpool/us-west-2_EHNXjvL37 because no identity-based policy allows the cognito-idp:CreateUserPoolDomain action
The error message you’re seeing indicates that the IAM user amplify-dev doesn’t have the necessary permissions to execute the CreateUserPoolDomain operation in AWS Cognito. To resolve this issue, you’ll need to modify the IAM policy associated with this user to include the necessary permissions.
Here are the steps to do this:
- Go to the IAM section of the AWS Management Console.
- In the left navigation pane, click on “Users”.
- Find and click on the
amplify-devuser. - Under the “Permissions” tab, look for the “Add inline policy” button on the right and click it.
- In the “Create policy” interface, switch to the “JSON” tab and enter the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CognitoPermissions",
"Effect": "Allow",
"Action": [
"cognito-idp:CreateUserPoolDomain",
"cognito-idp:DescribeUserPoolDomain",
"cognito-idp:DeleteUserPoolDomain"
],
"Resource": "*"
}
]
}
- Click on “Review policy”.
- Enter a name for the policy and click “Create policy”.
This policy grants the amplify-dev user the permissions to create, describe, and delete user pool domains in AWS Cognito.
Please note that the "Resource": "*" in the policy allows these actions on all resources. If you want to restrict this to specific user pools, replace "*" with the ARNs of the user pools.
After you’ve added the policy, try running your AWS CLI command again. If you’re still encountering issues, make sure your AWS CLI is configured with the correct credentials for the amplify-dev user.
Or do it via awscli:
To create and attach an IAM policy using the AWS CLI, you’ll need to follow these steps:
- Create the policy: Save the following policy document as a JSON file, such as
cognito_permissions.json:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CognitoPermissions",
"Effect": "Allow",
"Action": [
"cognito-idp:CreateUserPoolDomain",
"cognito-idp:DescribeUserPoolDomain",
"cognito-idp:DeleteUserPoolDomain"
],
"Resource": "*"
}
]
}
- Create the policy using AWS CLI: Use the
create-policycommand to create the policy:
aws iam create-policy --policy-name CognitoPermissionsPolicy --policy-document file://cognito_permissions.json
This command will return a policy ARN (Amazon Resource Name) in the output.
- Attach the policy to the user: To attach this policy to your user (
amplify-dev), use theattach-user-policycommand with the policy ARN from the previous step:
aws iam attach-user-policy --policy-arn "arn:aws:iam::aws:policy/CognitoPermissionsPolicy" --user-name amplify-dev
Now, your amplify-dev user should have the necessary permissions to manage Cognito user pool domains. Make sure to replace the policy ARN and user name with your actual values.
Also, please note that this policy allows these actions on all resources. If you want to restrict this to specific user pools, replace "*" with the ARNs of the user pools in the policy document.


