hexr_tool() returns an authenticated client for any supported cloud service. Instead of managing API keys or IAM credentials, it uses your agent’s SPIFFE identity to exchange for short-lived cloud credentials through a 3-tier cache. The returned client is identical to what you’d get from the provider’s own SDK — you use it exactly the same way, just without any credential setup.
Signature
Parameters
The cloud service to authenticate. Uses the format
{provider}_{service}.Examples: "aws_s3", "gcp_bigquery", "azure_storage"Override the default region for this service.Examples:
"us-west-2", "europe-west1"Returns
An authenticated client from the cloud provider’s SDK, ready to use:| Service | Returns |
|---|---|
aws_s3 | boto3.client('s3') |
aws_ec2 | boto3.client('ec2') |
aws_dynamodb | boto3.resource('dynamodb') |
aws_sqs | boto3.client('sqs') |
aws_lambda | boto3.client('lambda') |
aws_bedrock | boto3.client('bedrock-runtime') |
gcp_bigquery | google.cloud.bigquery.Client() |
gcp_storage | google.cloud.storage.Client() |
gcp_vertexai | google.cloud.aiplatform client |
gcp_pubsub | google.cloud.pubsub_v1.PublisherClient() |
azure_storage | azure.storage.blob.BlobServiceClient() |
azure_cosmosdb | azure.cosmos.CosmosClient() |
azure_openai | openai.AzureOpenAI() |
Basic usage
How it works
Callinghexr_tool() triggers a credential resolution chain:
Your code calls hexr_tool()
s3 = hexr_tool("aws_s3") — the SDK starts the credential resolution chain.L1 cache check (in-memory)
The SDK checks the in-memory L1 cache for existing credentials. On a miss, it proceeds to L2.
L2 cache check (Valkey)
The SDK checks the cluster-wide Valkey L2 cache. On a miss, it proceeds to credential exchange.
Credential exchange
The SDK sends the JWT-SVID to the Credential Injector, which calls AWS
AssumeRoleWithWebIdentity. AWS STS returns {AccessKeyId, SecretKey, Token}.Multi-cloud example
Region override
OPA policy scoping
Theresources parameter on @hexr_agent tells OPA which services this agent is allowed to access. Attempting to call a service not in the list will result in a CredentialError:
Error handling
Observability
Everyhexr_tool() call emits OpenTelemetry data automatically:
Span: hexr.tool.invoke
hexr.tool.invocations— Counter by servicehexr.tool.duration— Histogram of call latencyhexr.cache.hits/hexr.cache.misses— Cache performance