Why SAML Authentication Failures Are So Disruptive {#introduction}
AWS IAM SAML authentication errors – Contact centers don’t get to pause. When SAML authentication breaks in Amazon Connect, agents can’t log in, supervisors lose visibility, and every queue metric starts trending the wrong direction. That’s the reality of building critical business operations on federated identity — when it works, users don’t even notice it. When it breaks, everything stops.
SAML-based SSO with AWS IAM is the standard enterprise approach for authenticating users into Amazon Connect without managing passwords inside AWS. It lets your existing identity provider — whether that’s Okta, Azure AD, ADFS, or something else — remain the single source of truth. But the authentication chain is long: your IdP generates an assertion, signs it with a certificate, Base64-encodes it, posts it to the AWS sign-in endpoint, which then validates every attribute before issuing a federated session. Any mismatch at any step produces an error that can be cryptic and hard to trace.
The errors themselves aren’t always obvious. A RoleSessionName that’s one character off from a Connect username. An ACS URL pointing to the global endpoint instead of your regional one. A signing certificate that was rotated in your IdP but never updated in IAM. A trust policy missing sts:AssumeRoleWithSAML. These are real issues that AWS architects and IAM administrators hit regularly, and they rarely produce error messages clear enough to diagnose at a glance.
This guide covers every SAML error you’re likely to encounter in an AWS IAM + Amazon Connect setup — from the exact error text, to the root cause, to the fix, to the CLI commands you need. It covers Okta, Azure AD, ADFS, Ping, and OneLogin configurations. It walks through CloudTrail debugging, SAML assertion decoding, IAM Identity Center issues, and advanced multi-account scenarios. If your federated login to Amazon Connect is broken, this is the one resource you need.
How AWS IAM SAML Federation Actually Works {#how-it-works}
Before you can fix a SAML problem, you need a clear mental model of what’s supposed to happen. SAML 2.0 federation with AWS uses a specific chain of trust that involves your identity provider, AWS STS, and the service you’re trying to access (in this case, Amazon Connect).
The core actors:
- Identity Provider (IdP): Your directory system — Okta, Azure AD, ADFS, etc. This is the authority on who a user is.
- Service Provider (SP): In the AWS SAML federation model, AWS acts as the service provider. The AWS sign-in SAML endpoint is
https://signin.aws.amazon.com/saml. - IAM SAML Identity Provider: A resource in your AWS account that stores your IdP’s metadata (issuer URL, public signing certificate, etc.) and establishes trust.
- IAM Role: The role the federated user assumes. It must have a trust policy that allows
sts:AssumeRoleWithSAMLfrom your IdP’s ARN. - AWS STS: The service that validates the SAML assertion and issues temporary credentials.
The federation flow at a technical level:
- A user navigates to your IdP portal and authenticates.
- The IdP generates a SAML assertion — a signed XML document containing the user’s identity, the IAM role they should assume, the SAML provider ARN, and a
RoleSessionName. - The IdP posts this assertion (Base64-encoded) to the AWS SAML endpoint.
- AWS STS receives the assertion and calls
AssumeRoleWithSAMLinternally, validating the signature against the public certificate in your IAM identity provider, checking the audience, validating the role ARN, and verifying the assertion hasn’t expired. - If everything checks out, STS returns temporary credentials, and the user is redirected to the target service — in this case, Amazon Connect via a relay state URL.
The IAM trust policy that enables this:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789012:saml-provider/YourIdPName"
},
"Action": "sts:AssumeRoleWithSAML",
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
}
}
]
}
If you’re using regional SAML endpoints (strongly recommended for Connect), you’ll need to allow both the global and regional audience URLs in this condition:
json
"Condition": {
"StringEquals": {
"SAML:aud": [
"https://signin.aws.amazon.com/saml",
"https://us-east-1.signin.aws.amazon.com/saml"
]
}
}
Required SAML attributes in the assertion:
| Attribute Name | Description | Required? |
|---|---|---|
https://aws.amazon.com/SAML/Attributes/Role | Comma-separated IAM Role ARN and SAML Provider ARN | Yes |
https://aws.amazon.com/SAML/Attributes/RoleSessionName | Identifier for the session (must match Connect username) | Yes |
https://aws.amazon.com/SAML/Attributes/SessionDuration | Session length in seconds (max 43200) | No |
https://aws.amazon.com/SAML/Attributes/PrincipalTag:* | Session tags for ABAC | No |
Amazon Connect SAML SSO with MS Azure AD | AWS Workshop | SAML 2.0 Authentication in Amazon Connect by Saroj Kumar Jena
The Amazon Connect SAML Authentication Flow {#connect-flow}
Amazon Connect SAML is IdP-initiated only. This is a critical distinction that trips up many engineers: users cannot navigate directly to your Connect instance URL and log in. Authentication must originate from the identity provider. If a user tries to access the Connect URL directly, they’ll see a “Session Expired” message.
The Connect-specific SAML flow works like this:
- A user accesses an internal portal (usually a tile in Okta, Azure AD MyApps, or similar) that links to your Connect instance.
- The IdP authenticates the user and generates a SAML assertion.
- The assertion is posted to the AWS SAML sign-in endpoint (regional recommended:
https://[region].signin.aws.amazon.com/saml). - AWS validates the assertion and grants a federated session.
- AWS redirects the browser to the relay state URL, which for Connect takes the format:
https://[region].console.aws.amazon.com/connect/federate/[instance-id] - Connect’s federation endpoint calls
connect:GetFederationTokenon behalf of the user. - Connect matches the
RoleSessionNamefrom the SAML response to a username in your Connect instance. If found, the user is logged in. If not, you get “Access Denied — your account has been authenticated but has not been onboarded to this application.”
Critical Connect-specific requirements:
- Connect usernames are case-sensitive, even under SAML.
- The
RoleSessionNamein the SAML assertion must exactly match the username in Connect — character for character. - You need exactly one IAM role for federation (only one role is used and needed).
- Sessions last a maximum of 12 hours. After that, even active agents are logged out.
- The IAM role must have permission to call
connect:GetFederationTokenon the specific Connect instance resource.
Complete Error Reference: Every SAML Error Explained {#error-reference}
Error 1: “Your request included an invalid SAML response. To logout, click here.”
This is the most common and frustratingly vague SAML error. It’s the generic failure state from the AWS SAML endpoint and can be triggered by several different underlying issues.
Root Causes:
Missing Role attribute: The SAML assertion doesn’t include the https://aws.amazon.com/SAML/Attributes/Role attribute, or the attribute exists but has no AttributeValue elements.
Invalid Role ARN format: The Role attribute value must be a comma-separated pair — arn:aws:iam::123456789012:role/YourRole,arn:aws:iam::123456789012:saml-provider/YourIdP. The order matters in some implementations.
Leading/trailing whitespace: This is surprisingly common. A space at the beginning or end of any SAML attribute value will cause this error. Check your IdP’s attribute mapping for trailing spaces.
Incorrect audience value: The <Audience> element in the SAML assertion must be https://signin.aws.amazon.com/saml (or the regional variant if you’ve configured that).
Fix — Check and update the Role attribute in your IdP (Okta example): In your Okta SAML app, go to the attribute statements section and verify:
- Name:
https://aws.amazon.com/SAML/Attributes/Role - Value:
appuser.role(or however you’re mapping roles from the directory) - Verify the value resolves to the correct ARN pair, with no extra spaces.
Fix — Update metadata via CLI:
bash
aws iam update-saml-provider \
--saml-metadata-document file://updated-metadata.xml \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/YourIdP
Error 2: “RoleSessionName is required in AuthnResponse”
Error code: InvalidIdentityToken | HTTP: 400
The SAML assertion doesn’t include the https://aws.amazon.com/SAML/Attributes/RoleSessionName attribute, or the attribute is present but empty.
Fix: In your IdP, add an attribute statement mapping:
- Attribute name:
https://aws.amazon.com/SAML/Attributes/RoleSessionName - Value: The user’s email address or SAMAccountName (e.g.,
user.emailin Okta,user.userprincipalnamein Azure AD)
For Connect specifically: The value of RoleSessionName must exactly match the Connect username. If your Connect usernames are jdoe but your RoleSessionName sends jdoe@company.com, the SAML assertion will be accepted by AWS but the Connect federation will fail with “Access Denied.”
Error 3: “RoleSessionName in AuthnResponse must match [a-zA-Z_0-9+=,.@-]{2,64}”
Error code: InvalidIdentityToken | HTTP: 400
The RoleSessionName value either contains invalid characters or exceeds 64 characters.
Common causes:
- Email addresses with unusual characters
- Session names derived from display names that include spaces or special characters
- Values generated from user attributes that concatenate too many fields
Fix: Ensure the RoleSessionName is 2–64 characters and matches only [a-zA-Z_0-9+=,.@-]. For most implementations, using just the username portion of an email (before the @) is safest. If you must use an email, verify it doesn’t contain characters outside the allowed set.
Error 4: “Not authorized to perform sts:AssumeRoleWithSAML” (AccessDenied, HTTP 403)
The IAM role referenced in the SAML assertion doesn’t have a trust policy that allows the sts:AssumeRoleWithSAML action, or the conditions in the trust policy don’t match what’s in the assertion.
Root causes:
- The role’s trust policy references the wrong SAML provider ARN
- The
SAML:audcondition doesn’t match the ACS URL in the assertion - The role name in the assertion is misspelled (role names are case-sensitive)
- The federated user doesn’t satisfy the conditions in the trust policy
Fix — Verify the trust policy:
bash
aws iam get-role --role-name YourFederationRole --query 'Role.AssumeRolePolicyDocument'
The output should include sts:AssumeRoleWithSAML and reference your SAML provider ARN as the Principal. If you use session tags (PrincipalTag attributes), the trust policy must also include sts:TagSession.
Fix — If using session tags, update the trust policy:
json
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789012:saml-provider/YourIdP"
},
"Action": [
"sts:AssumeRoleWithSAML",
"sts:TagSession"
],
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
}
}
Error 5: “Response signature invalid” (InvalidIdentityToken)
The signature on the SAML response doesn’t validate against the public certificate stored in your IAM SAML identity provider. This happens when your IdP’s signing certificate has been rotated but the new certificate hasn’t been uploaded to IAM.
Fix:
- Download the updated SAML metadata XML from your IdP.
- Update the IAM provider:
bash
aws iam update-saml-provider \
--saml-metadata-document file://new-metadata.xml \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/YourIdP
- Verify the update:
bash
aws iam get-saml-provider \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/YourIdP \
--query 'SAMLMetadataDocument'
Pro tip: IAM doesn’t auto-alert on certificate expiration. Set up a CloudWatch Events rule or a Lambda-based rotation check to monitor certificate expiry dates from your IdP metadata before they expire in production.
Error 6: “Failed to assume role: Issuer not present in specified provider”
Error code: AuthSamlInvalidSamlResponseException
The <Issuer> element in the SAML response doesn’t match the issuer declared in the metadata file you uploaded to IAM when creating the SAML provider.
Fix: Download fresh metadata from your IdP and compare the entityID attribute of the <EntityDescriptor> element to what’s stored in your IAM SAML provider. They must match exactly — including protocol prefix (http vs https) and trailing slashes.
Error 7: “Could not parse metadata.”
The SAML metadata XML you uploaded to IAM is malformed. Common causes:
- The metadata file includes a BOM (Byte Order Mark) — IAM requires UTF-8 without BOM
- The X.509 certificate in the metadata is smaller than 1024 bits
- Repeated extensions exist in the X.509 certificate
- The XML itself is malformed
Fix: Open the metadata file in Notepad++ (Windows) or use file command on Linux to detect encoding. Save as UTF-8 without BOM. Validate the XML structure. Verify the X.509 certificate meets size requirements:
bash
openssl x509 -in cert.pem -text -noout | grep "Public-Key"
Error 8: “Response does not contain the required audience.”
The <Audience> value in the SAML assertion’s <AudienceRestriction> element doesn’t match what AWS expects.
Required audience value: https://signin.aws.amazon.com/saml
If you’re using regional endpoints (recommended for Connect), you’ll also need the regional audience value (e.g., https://us-east-1.signin.aws.amazon.com/saml) reflected in your trust policy condition.
Fix in Okta: In the SAML app settings, set the Audience URI (SP Entity ID) to https://signin.aws.amazon.com/saml.
Fix in Azure AD: In the Enterprise Application SAML setup, set “Identifier (Entity ID)” to https://signin.aws.amazon.com/saml.
Error 9: “Requested DurationSeconds exceeds MaxSessionDuration set for this role.”
The SessionDuration attribute in the SAML assertion requests a session longer than the role’s MaxSessionDuration setting (default: 1 hour, maximum: 12 hours).
Fix: Either reduce the SessionDuration attribute value in your IdP’s assertion, or increase the role’s MaxSessionDuration:
bash
aws iam update-role \
--role-name YourFederationRole \
--max-session-duration 43200
Note: For Amazon Connect specifically, sessions expire after 12 hours regardless. Agents should log out and back in via the IdP to refresh.
Error 10: “Specified provider doesn’t exist.”
The SAML provider ARN in the Role attribute doesn’t match any IAM SAML provider in the account. This is usually a typo or the wrong account ID embedded in the ARN.
Fix: List your existing SAML providers and compare:
bash
aws iam list-saml-providers
Verify the ARN in the SAML assertion matches exactly, including the account ID and provider name.
Step-by-Step Troubleshooting Workflow {#troubleshooting-workflow}
When SAML breaks, you need a systematic approach. Here’s the workflow that works in real enterprise environments.
Step 1 — Identify the error message
Capture the exact error from the browser. Most AWS SAML errors appear at the AWS sign-in endpoint (signin.aws.amazon.com) before reaching Connect. Note whether the error is from AWS (authentication failed at the STS layer) or from Connect (authentication succeeded but authorization to Connect failed).
Step 2 — Capture and decode the SAML assertion
This is the single most useful diagnostic step. The SAML assertion is posted from your IdP to AWS as a Base64-encoded parameter.
In Chrome or Edge:
- Press
F12to open DevTools - Click the Network tab, then check Preserve log
- Reproduce the login failure
- Filter for POST requests, look for a request to
signin.aws.amazon.com/saml - Click that request, go to Payload, find the
SAMLResponseparameter - Copy the Base64 value
Decode it locally (never use an online decoder with production SAML data):
bash
# Linux/macOS
echo "BASE64_VALUE_HERE" | base64 --decode > decoded_assertion.xml
# PowerShell (Windows)
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("BASE64_VALUE_HERE")) | Out-File decoded_assertion.xml
For HAR-based capture (useful when you need to share with support):
bash
grep -o "SAMLResponse=.*&" login.har | sed -E 's/SAMLResponse=(.*)&/\1/' > samlresponse_encoded.txt
cat samlresponse_encoded.txt | python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));" | base64 --decode > samlresponse_decoded.xml
Step 3 — Validate the decoded assertion
Check these elements in the decoded XML:
xml
<!-- Check the Issuer -->
<saml:Issuer>https://your-idp-issuer-url</saml:Issuer>
<!-- Check the audience -->
<saml:AudienceRestriction>
<saml:Audience>https://signin.aws.amazon.com/saml</saml:Audience>
</saml:AudienceRestriction>
<!-- Check the Role attribute -->
<saml:Attribute Name="https://aws.amazon.com/SAML/Attributes/Role">
<saml:AttributeValue>
arn:aws:iam::123456789012:role/ConnectFederationRole,arn:aws:iam::123456789012:saml-provider/YourIdP
</saml:AttributeValue>
</saml:Attribute>
<!-- Check the RoleSessionName -->
<saml:Attribute Name="https://aws.amazon.com/SAML/Attributes/RoleSessionName">
<saml:AttributeValue>jdoe</saml:AttributeValue>
</saml:Attribute>
<!-- Check expiry (NotOnOrAfter) -->
<saml:SubjectConfirmationData NotOnOrAfter="2026-05-26T12:00:00Z" ... />
Step 4 — Verify Connect user existence
Once you’ve confirmed the RoleSessionName, verify the user exists in Connect:
bash
aws connect list-users --instance-id YOUR_INSTANCE_ID \
| python3 -c "import sys,json; users=json.load(sys.stdin)['UserSummaryList']; [print(u['Username']) for u in users if 'jdoe' in u['Username'].lower()]"
Step 5 — Check CloudTrail for the failed event
bash
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=AssumeRoleWithSAML \
--start-time "2026-05-26T00:00:00Z" \
--end-time "2026-05-26T23:59:59Z" \
| jq '.Events[] | {time: .EventTime, user: .Username, errorCode: .CloudTrailEvent | fromjson | .errorCode, errorMessage: .CloudTrailEvent | fromjson | .errorMessage}'
For Connect-specific federation events, also look for ExternalIdPDirectoryLogin in IAM Identity Center CloudTrail logs.
Decoding and Debugging SAML Assertions {#debugging-assertions}
IAM Identity Center built-in debugger:
If you’re using IAM Identity Center, there’s a built-in SAML assertion viewer. Hold Shift and click an application tile in the AWS access portal. A debug page appears showing the full SAML assertion XML, attribute values, and the ability to copy the XML before continuing to the application. This is invaluable for diagnosing attribute mapping issues without needing browser DevTools.
Validating assertion timing:
Clock skew is a real issue. SAML assertions contain NotBefore and NotOnOrAfter timestamps. If your IdP server’s clock is more than 5 minutes out of sync with AWS, assertions will be rejected as expired or not-yet-valid. Most IdPs and AWS infrastructure use NTP, but a misconfigured server can drift.
Check the assertion’s timing:
bash
grep -E "NotBefore|NotOnOrAfter" decoded_assertion.xml
Compare to current time:
bash
date -u
If the times don’t align, sync your IdP server’s clock to a reliable NTP source.
Validating the signing certificate:
Extract the certificate from the decoded assertion and compare it to what’s in IAM:
bash
# Get the certificate from the assertion
grep -A 5 "X509Certificate" decoded_assertion.xml
# Get the certificate from the IAM provider metadata
aws iam get-saml-provider \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/YourIdP \
--query 'SAMLMetadataDocument' --output text | grep -A 5 "X509Certificate"
They should match. If they don’t, your IdP rotated its certificate without updating IAM.
Amazon Connect-Specific SAML Issues {#connect-specific}
“Access Denied. Your account has been authenticated, but has not been onboarded to this application.”
This is the most common Connect SAML error after successful AWS authentication. The SAML assertion was valid — AWS accepted it — but Connect couldn’t find a matching user.
Diagnosis:
bash
# Extract the RoleSessionName from the decoded assertion
export USERNAME=$(grep -Eo 'RoleSessionName.*?</AttributeValue>' decoded_assertion.xml | sed -E 's/.*<AttributeValue>(.*)<\/AttributeValue>/\1/')
# Check if that user exists in Connect
aws connect list-users --instance-id YOUR_INSTANCE_ID | grep -i "$USERNAME"
Common causes and fixes:
- Case mismatch: Connect usernames are case-sensitive.
JDoeandjdoeare different users. Standardize on one convention everywhere. - User not created in Connect: SAML in Connect doesn’t support just-in-time provisioning. Users must be pre-created in Connect’s user management before they can log in via SSO.
- Username format mismatch: Your IdP sends
jdoe@company.comas theRoleSessionName, but the Connect user was created asjdoe. Either update the user in Connect or change theRoleSessionNamemapping in your IdP. - Duplicate profiles: The user has two separate SSO profiles assigned. Check the Connect user management page for duplicate entries.
“Access denied, Please contact your AWS account administrator for assistance.”
This error appears after SAML authentication succeeds at the AWS level but the assumed IAM role lacks permission to call connect:GetFederationToken.
Fix — Attach the required policy to the federation role:
json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ConnectFederationAccess",
"Effect": "Allow",
"Action": "connect:GetFederationToken",
"Resource": [
"arn:aws:connect:us-east-1:123456789012:instance/YOUR-INSTANCE-ID/user/${aws:userid}"
]
}
]
}
Or using a condition-based approach (allows federation to a specific instance without user-specific resource ARNs):
json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "connect:GetFederationToken",
"Resource": "*",
"Condition": {
"StringEquals": {
"connect:InstanceId": "YOUR-INSTANCE-ID"
}
}
}
]
}
Attach via CLI:
bash
aws iam attach-role-policy \
--role-name YourFederationRole \
--policy-arn arn:aws:iam::123456789012:policy/ConnectFederationPolicy
ACS URL and Regional Endpoint Issues
By default, most IdPs use the global ACS URL (https://signin.aws.amazon.com/saml). For Connect, AWS recommends using regional ACS endpoints for better availability. When these are mismatched, you may see silent redirect failures or incorrect region routing.
Fix — Update ACS URL in your IdP to the regional endpoint:
https://us-east-1.signin.aws.amazon.com/saml
Fix — Update the trust policy condition to accept both URLs:
json
"Condition": {
"StringEquals": {
"SAML:aud": [
"https://signin.aws.amazon.com/saml",
"https://us-east-1.signin.aws.amazon.com/saml"
]
}
}
Fix — Configure relay state for direct Connect access:
https://us-east-1.console.aws.amazon.com/connect/federate/YOUR-INSTANCE-ID
For agent CCP deep-linking:
https://us-east-1.console.aws.amazon.com/connect/federate/YOUR-INSTANCE-ID?destination=%2Fccp-v2
Identity Provider Troubleshooting {#idp-troubleshooting}
Okta
Common issues:
- The AWS app in Okta needs the correct attribute statements. Go to your AWS application in Okta → Sign On → Edit → Attribute Statements. Verify both Role and RoleSessionName are mapped.
- Okta’s pre-built AWS integration auto-populates some SAML values. If you’re using a custom SAML app instead, you’ll need to set all attributes manually.
- The ACS URL in Okta’s settings should be updated from the default global endpoint to your regional endpoint.
- Ensure the “Application Username” in Okta assignments matches the Connect username format exactly.
Okta SAML debugger: In Okta, you can use the SAML assertion debugger to see exactly what the assertion will contain before a user actually logs in. This is under Applications → Your App → More → View SAML setup instructions.
Azure AD / Microsoft Entra ID
Common issues:
- The claim mapping in Azure AD uses different terminology. “User Identifier” maps to
RoleSessionName. Verify the format matches Connect username conventions. - Azure AD’s user principal name (
user.userprincipalname) is often the email address. If Connect usernames are just the username portion, you’ll need a transformation in the claim mapping. - The Entity ID in Azure must be set to
https://signin.aws.amazon.com/saml. - Certificate rotation in Azure AD: Azure generates new certificates on a rolling basis. Enable “SAML signing certificate” notifications, and automate metadata refresh to IAM.
Extracting RoleSessionName from Azure AD assertion:
bash
# After decoding the assertion
grep -A2 "RoleSessionName" decoded_assertion.xml
ADFS (Active Directory Federation Services)
Common issues:
- ADFS claim rules need to be configured manually. Missing claim rules for Role or RoleSessionName are common.
- The ADFS relying party trust needs the AWS SAML metadata imported correctly.
- Clock synchronization between the ADFS server and AWS can cause timing validation failures.
- The NameID format must be
urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddressfor most configurations.
Verify ADFS claim rules (PowerShell on ADFS server):
powershell
Get-AdfsRelyingPartyTrust -Name "Amazon Web Services" | Select-Object -ExpandProperty IssuanceTransformRules
Ping Identity
Common issues center around attribute mapping and signature algorithm compatibility. Ensure your PingFederate or PingOne application is configured to send SAML 2.0 assertions (not SAML 1.1) and that the signing algorithm is SHA-256 (SHA-1 is deprecated and may be rejected).
OneLogin
OneLogin’s AWS integration uses a custom connector. Verify that the “SAML signature element” is set to “Both” or “Response” in the OneLogin AWS connector settings. Assertions-only signing can cause AWS to reject the response.
Using CloudTrail to Debug SAML Failures {#cloudtrail}
CloudTrail records SAML-related events under AWS STS, and they’re invaluable for diagnosing authentication failures without having to reproduce the issue in a browser.
Key events to look for:
| Event | Service | What it means |
|---|---|---|
AssumeRoleWithSAML | STS | Every SAML federation attempt, success or failure |
ExternalIdPDirectoryLogin | SSO | IAM Identity Center external IdP login |
ConsoleLogin | signin.amazonaws.com | Console login via federation |
GetFederationToken | Connect | Connect-specific federation token request |
Query SAML failures in CloudTrail:
bash
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=AssumeRoleWithSAML \
--start-time $(date -d "1 hour ago" -u +%Y-%m-%dT%H:%M:%SZ) \
| jq '.Events[] | select(.CloudTrailEvent | fromjson | .errorCode != null) | {
time: .EventTime,
errorCode: (.CloudTrailEvent | fromjson | .errorCode),
errorMessage: (.CloudTrailEvent | fromjson | .errorMessage),
sourceIP: (.CloudTrailEvent | fromjson | .sourceIPAddress)
}'
Find Connect federation failures:
bash
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=GetFederationToken \
--start-time $(date -d "1 hour ago" -u +%Y-%m-%dT%H:%M:%SZ) \
| jq '.Events[] | select(.CloudTrailEvent | fromjson | .errorCode != null)'
CloudTrail Lake query for SAML errors (more powerful):
If you’ve set up CloudTrail Lake, you can run SQL queries:
sql
SELECT
eventTime,
errorCode,
errorMessage,
userAgent,
sourceIPAddress,
json_extract_scalar(requestParameters, '$.roleArn') as roleArn,
json_extract_scalar(requestParameters, '$.principalArn') as providerArn
FROM your_event_data_store
WHERE eventName = 'AssumeRoleWithSAML'
AND errorCode IS NOT NULL
AND eventTime > CURRENT_TIMESTAMP - INTERVAL '24' HOUR
ORDER BY eventTime DESC
Using IAM Access Analyzer:
IAM Access Analyzer can identify whether external SAML providers have overly permissive access policies. Run an analysis and look for findings related to your SAML provider ARN.
IAM Identity Center Issues {#identity-center}
AWS recommends IAM Identity Center for new SAML federation setups. It simplifies the federation model but introduces its own class of issues.
“An unexpected error has occurred” during sign-in
This typically means a mismatch in the SAML exchange between your external IdP and IAM Identity Center. Key requirements for external IdP sign-in to IAM Identity Center:
- The
nameIDformat must beurn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress - The
nameIDvalue must match an existing IAM Identity Center username (it’s a username match, not email match) - Only one assertion per SAML response is supported
- Encrypted SAML assertions are not supported by IAM Identity Center
- If Attributes for Access Control (ABAC) is enabled: maximum 50 attributes, no multi-valued attributes, no structured XML values
Check CloudTrail for the specific failure:
bash
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=ExternalIdPDirectoryLogin
SCIM Provisioning Failures
If users can’t sign in to IAM Identity Center from an external IdP, check whether they’ve been provisioned via SCIM first. IAM Identity Center doesn’t support just-in-time user creation for SAML — users must exist before they can authenticate.
Common SCIM error scenarios:
Users fail to sync because of missing required fields:
"2 validation errors detected: Value at 'name.givenName' failed to satisfy constraint:
Member must have length greater than or equal to 1"
Fix: Ensure all users in your IdP have first name, last name, and display name populated.
Multi-value attribute collision:
"List attribute emails exceeds allowed limit of 1"
Fix: Configure SCIM mappings to send only one value per attribute. Remove secondary email addresses from SCIM attribute mappings.
AWSReservedSSO_ Roles
If you see roles prefixed with AWSReservedSSO_ in IAM and you can’t modify them, that’s expected behavior. These roles are managed by IAM Identity Center and can only be modified through the Identity Center console in the management account. Attempting to edit them in IAM results in:
Cannot perform the operation on the protected role 'AWSReservedSSO_RoleName_Here' -
this role is only modifiable by AWS
Clock Skew in TOTP/MFA
If users get MFA errors during SAML sign-in, ensure the device running the authenticator app is synchronized to an NTP time source. TOTP codes are time-based and will fail if the client clock is more than 30 seconds off.
Advanced Scenarios {#advanced}
Multi-Account Federation
In multi-account AWS Organizations setups, you typically have one central IAM SAML provider in your identity/management account, with role assumptions in member accounts. Common issues:
- The SAML provider ARN is only trusted in the account where it’s created. You can’t use
arn:aws:iam::111111111111:saml-provider/IdPas a principal in a trust policy in account222222222222. Each account needs its own SAML provider, or you use IAM Identity Center’s permission set model. - Service Control Policies (SCPs) can block
sts:AssumeRoleWithSAMLin member accounts. If federation works in the management account but fails in member accounts, check SCPs:
bash
aws organizations list-policies-for-target \
--target-id YOUR_ACCOUNT_ID \
--filter SERVICE_CONTROL_POLICY
Cross-Region Authentication
AWS STS is a global service, but for Amazon Connect specifically, regional STS endpoints matter. If STS is disabled in your Connect instance’s region, federation will fail.
Check if STS is enabled in a region:
bash
aws sts get-caller-identity --region ap-southeast-2
Ensure no SCP prevents STS in your Connect region.
SAML Encryption
IAM supports encrypted SAML assertions (using a private key you upload). If you’re enabling SAML encryption (required for some FedRAMP or compliance scenarios):
- Generate a key pair and upload the private key to IAM
- Upload the public certificate to your IdP
- IAM supports up to two private keys simultaneously (for rotation)
- IAM Identity Center does not support encrypted SAML assertions — use direct IAM federation if you need encryption
Rotate the SAML encryption key:
bash
# Add new key
aws iam update-saml-provider \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/YourIdP \
--add-private-key file://new-private-key.pem
# Remove old key after transition
aws iam update-saml-provider \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/YourIdP \
--remove-private-key KEY_ID_OF_OLD_KEY
Security Best Practices {#security}
Certificate rotation: Monitor your IdP’s signing certificate expiration date. When it rotates, you have a narrow window to update the metadata in IAM before all SAML federation breaks. Consider automating this with a Lambda function that downloads the IdP metadata on a schedule and compares it to what’s in IAM.
Least privilege on the federation role: The federation IAM role should grant only the permissions needed for Connect federation — specifically connect:GetFederationToken. Avoid attaching broad policies like ReadOnlyAccess to the federation role.
Session duration: Default sessions are 1 hour. Connect supports up to 12 hours via SessionDuration attribute. Set this to the minimum your contact center operations require. After 12 hours, agents must re-authenticate via the IdP.
Enforce MFA at the IdP layer: MFA for federated users should be enforced at the IdP (Okta, Azure AD, etc.) rather than in AWS IAM. The IAM role’s trust policy can include a condition to require MFA, but enforcing it at the IdP ensures no SAML assertion is issued without MFA completion.
Trust policy conditions: Use specific conditions in your trust policy to restrict which users can assume the role:
json
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml",
"SAML:iss": "https://your-idp.okta.com"
}
}
Audit SAML providers regularly:
bash
aws iam list-saml-providers
aws iam get-saml-provider --saml-provider-arn ARN
Remove any stale providers from decommissioned IdP integrations.
Real-World Case Studies {#case-studies}
Case Study 1: The Post-Certificate-Rotation Outage
Scenario: An enterprise contact center running 500 agents in Amazon Connect experienced a complete login failure on a Monday morning. All agents received “Your request included an invalid SAML response.”
Diagnosis: CloudTrail showed AssumeRoleWithSAML events failing with InvalidIdentityToken — the error code for signature validation failure. The team decoded a SAML assertion and compared the embedded certificate to what was in IAM. They didn’t match.
Root cause: The Okta team had rotated the SAML signing certificate on Friday. The IAM SAML provider metadata hadn’t been updated.
Fix: Download new metadata from Okta, update IAM provider, all agents back online within 10 minutes:
bash
# Download from Okta metadata URL
curl -s "https://your-org.okta.com/app/YOUR-APP-ID/sso/saml/metadata" > metadata.xml
aws iam update-saml-provider \
--saml-metadata-document file://metadata.xml \
--saml-provider-arn arn:aws:iam::123456789012:saml-provider/OktaIdP
Prevention: Set up a CloudWatch alarm triggered by a Lambda function that checks IdP metadata weekly and sends SNS alerts when the certificate is within 30 days of expiration.
Case Study 2: The RoleSessionName Case Sensitivity Problem
Scenario: After a Connect username migration (standardizing all usernames to lowercase), 15% of agents could no longer log in after authenticating via Azure AD successfully.
Diagnosis: The team ran aws connect list-users and grep’d for the affected usernames. The users existed. SAML authentication succeeded. Connect returned “Access Denied — not onboarded.”
Root cause: Azure AD’s user attribute user.userprincipalname preserved mixed case for some users. Their Connect usernames had been migrated to lowercase, but the SAML RoleSessionName was still being sent in the original mixed-case format. JDoe in the assertion ≠ jdoe in Connect.
Fix: Modified the Azure AD claim mapping to apply a ToLower() transformation on the RoleSessionName claim. Re-tested with affected users — all resolved.
Case Study 3: The SCP Blocking STS in a New Region
Scenario: A team expanded their Connect deployment to the ap-southeast-2 (Sydney) region. Agents in the new region couldn’t log in via SAML, but agents in us-east-1 could.
Diagnosis: CloudTrail in the ap-southeast-2 account showed no AssumeRoleWithSAML events at all. The SAML assertion was being sent to the regional endpoint but no STS calls were recorded.
Root cause: An organization-wide SCP was blocking all STS actions in regions outside us-east-1 and eu-west-1. The new Sydney region wasn’t on the allowlist.
Fix: Updated the SCP to include ap-southeast-2 in the allowed regions for STS actions. Also updated the Connect relay state URL to point to the Sydney endpoint and ensured the IAM role trust policy accepted the Sydney ACS URL.
FAQs {#faqs}
Q1: What is the required audience value for AWS SAML federation? The audience URI (also called SP Entity ID) must be https://signin.aws.amazon.com/saml. For regional endpoints, the audience is https://[region].signin.aws.amazon.com/saml, and your IAM role trust policy must be updated to accept it.
Q2: Why can’t I log directly into Amazon Connect when using SAML? Amazon Connect with SAML uses IdP-initiated SSO only. Connect doesn’t support SP-initiated (service provider-initiated) SSO. Users must always start authentication from their identity provider portal. Direct access to a Connect URL will result in a “Session Expired” error.
Q3: How do I decode a SAML response without using an online tool? On Linux/macOS: echo "BASE64_VALUE" | base64 --decode > assertion.xml. On Windows PowerShell: [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("BASE64_VALUE")). Never paste production SAML data into online decoders — it contains sensitive security context.
Q4: What is the maximum SAML session duration for Amazon Connect? Connect sessions expire after 12 hours maximum, regardless of the SessionDuration SAML attribute. After 12 hours, agents must log out and re-authenticate via their IdP.
Q5: Why does SAML work for some users but not others? The most common cause is a username mismatch between the RoleSessionName in the SAML assertion and the username in Connect. Also check: the affected users’ group membership in the IdP, whether they have the IAM role mapped correctly, and whether their Connect user accounts exist with the correct username (case-sensitive).
Q6: How do I fix “Not authorized to perform sts:AssumeRoleWithSAML”? Verify that the IAM role’s trust policy includes sts:AssumeRoleWithSAML as an allowed action, that the Principal references the correct SAML provider ARN, and that the SAML:aud condition matches the ACS URL in the assertion. If using session tags, also add sts:TagSession to the allowed actions.
Q7: Do I need to update anything in IAM when my IdP rotates its signing certificate? Yes — immediately. You need to download the new SAML metadata from your IdP and update it in your IAM SAML provider using aws iam update-saml-provider. Until you do, all SAML federation to that provider will fail with a signature validation error.
Q8: Can I use IAM Identity Center instead of direct IAM SAML federation for Connect? Yes. IAM Identity Center simplifies the federation model and provides a centralized access portal. However, it doesn’t support encrypted SAML assertions, and just-in-time user creation is not supported — users must be pre-provisioned via SCIM or manually.
Q9: Why do agents get logged out after 12 hours even during an active call? This is expected AWS Connect behavior with SAML authentication. The federated session token issued by STS expires, and Connect can’t automatically renew it. Agents need to plan refreshes proactively by re-authenticating via the IdP before the 12-hour mark.
Q10: What CloudTrail event shows a SAML authentication failure? Look for AssumeRoleWithSAML events in STS with a non-null errorCode. For Connect-specific failures, also check GetFederationToken events. For IAM Identity Center, filter on ExternalIdPDirectoryLogin.
Q11: My SAML metadata file won’t upload to IAM — “Unable to parse metadata” error. What’s wrong? Check: (1) The file is UTF-8 encoded without a BOM, (2) the X.509 certificate uses at least 1024-bit keys, (3) the certificate doesn’t have repeated extensions, (4) the XML is well-formed. Open the file in a text editor that shows encoding, and validate the XML with an XML validator.
Q12: Can multiple IAM roles be mapped to a single SAML assertion? A single SAML assertion can include multiple Role attribute values, allowing a user to choose which role to assume. However, for Amazon Connect, only one role is used for federation — the user won’t see a role selection prompt because Connect’s redirect handles role assumption internally.
Q13: Why does SAML federation work in us-east-1 but fail in ap-southeast-2? Likely causes: STS is disabled in that region (check with aws sts get-caller-identity --region ap-southeast-2), a Service Control Policy is blocking STS actions, the trust policy doesn’t include the regional ACS URL, or the relay state URL points to the wrong region.
Q14: How do I prevent the “Response signature invalid” error from recurring? Automate metadata refresh. Set up a Lambda function (or CI/CD pipeline step) that periodically downloads IdP metadata, compares it to what’s in IAM, and applies updates automatically. Also configure certificate expiration alerts in your IdP.
Q15: Is there a way to test SAML configuration without affecting production users? Yes. Create a test user in your Connect instance and your IdP, assign them the federation role, and test the full SSO flow in a browser session isolated from your production users. IAM Identity Center also has a SAML assertion debugger (Shift + click on an app tile in the access portal) that lets you inspect the assertion without completing the login.
Conclusion
SAML federation for Amazon Connect sits at the intersection of your identity provider, AWS IAM, AWS STS, and Connect’s user management — and failures at any layer produce errors that can seem disconnected from the actual root cause. The key to resolving these quickly is a disciplined diagnostic approach: decode the assertion first, validate every attribute, check CloudTrail for the actual error code, and work systematically through the federation chain.
The issues covered in this guide — from signature validation failures after certificate rotation, to case-sensitive username mismatches in Connect, to missing connect:GetFederationToken permissions — represent the most common real-world failure scenarios. Most can be resolved in under 30 minutes once you know what to look for.
For ongoing reliability, automate your IdP metadata refresh, monitor certificate expiration dates proactively, standardize username conventions across Connect and your directory, and use CloudTrail Lake to build visibility into federation events before they become user-impacting outages.
Also Check
- The Amazon Connect 503 Survival Guide
- Amazon Connect AI Agent Content Segmentation
- Amazon Connect CSP Bypass
- Fixing Amazon Connect “acceptContact API Request Failed: Network Failure”
- Amazon Connect API Throttling Troubleshooting