Skip to content

Elasticache access failures when assuming rule fails in certain regions

0

We are experiencing issues when trying to use the elasticache API in specific regions when assuming roles

So when the credentials file looks like so

[access_user]
aws_access_key_id = ...
aws_secret_access_key = ...

[somerole]
role_arn= ...
external_id= ...
source_profile=access_user

The following commands are being ran successfully (as expected)

aws --profile somerole --region us-east-1 elasticache describe-cache-clusters

aws --profile somerole --region us-east-2 elasticache describe-cache-clusters

Bit the following commands fail (not as expected)

aws --profile somerole --region af-south-1 elasticache describe-cache-clusters

aws --profile somerole --region me-central-1 elasticache describe-cache-clusters

with the error An error occurred (InvalidClientTokenId) when calling the DescribeCacheClusters operation: The security token included in the request is invalid

Is there a special way to access the elasticache in those regions?

The issue also persists when using boto3 instead of the CLI

1 Answer
0

The error you're experiencing with ElastiCache API calls in specific regions (af-south-1 and me-central-1) while using assumed roles is likely related to region-specific issues with security tokens.

When you see the "InvalidClientTokenId" error stating that "The security token included in the request is invalid," this typically indicates one of several possible issues:

  1. Region activation: Ensure that both the source account (where access_user exists) and the target account (where the role exists) have the specific regions (af-south-1 and me-central-1) enabled. Some AWS regions require explicit opt-in.

  2. Role permissions: Verify that the IAM role you're assuming has the necessary permissions to perform ElastiCache operations in those specific regions. The role might have region-specific restrictions in its policies.

  3. Token validity: There might be issues with how the temporary security credentials are being used across regions. The default duration for assumed role sessions is 1 hour, so ensure your token hasn't expired.

  4. Region-specific restrictions: Check for any organizational policies or service control policies (SCPs) that might restrict ElastiCache actions in those specific regions.

  5. CLI configuration: Ensure your AWS CLI is up to date, as older versions might have issues with newer regions.

To troubleshoot this issue:

  • Run aws sts get-caller-identity --profile somerole --region af-south-1 to verify your identity is correctly assumed in the problematic regions
  • Check the IAM policies attached to the role for any region-specific conditions or restrictions
  • Verify that the role's trust relationship is properly configured
  • Consider adding the aws:ViaAWSService condition to any IP-restricted policies if applicable

If the issue persists, you might need to review the specific permissions required for ElastiCache operations in those regions and ensure your role has the appropriate access.
Sources
An error occurred (UnrecognizedClientException) when calling the ListClusters operation: The security token included in the request is invalid | AWS re:Post
Resolve access denied errors in S3 for IP-restricted IAM roles | AWS re:Post

answered a year ago

AWS
EXPERT

reviewed a year ago

  • aws sts get-caller-identity --profile somerole --region af-south-1 Fails with the same issue (An error occurred (InvalidClientTokenId) when calling the DescribeCacheClusters operation: The security token included in the request is invalid)

    while aws sts get-caller-identity --profile somerole --region us-central-1 succeeds, how come?

    Also there are no conditions attached to the role

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.