name: aws-agentic-ai
aliases:
- bedrock-agentcore
description: AWS Bedrock AgentCore comprehensive expert for deploying and managing all AgentCore services. Use when working with Gateway, Runtime, Memory, Identity, or any AgentCore component. Covers MCP target deployment, credential management, schema optimization, runtime configuration, memory management, and identity services.
context: fork
model: sonnet
skills:
- aws-mcp-setup
allowed-tools:
- mcp__aws-mcp__*
- mcp__awsdocs__*
- Bash(aws bedrock-agentcore-control *)
- Bash(aws bedrock-agentcore-runtime *)
- Bash(aws bedrock *)
- Bash(aws s3 cp *)
- Bash(aws s3 ls *)
- Bash(aws secretsmanager *)
- Bash(aws sts get-caller-identity)
hooks:
PreToolUse:
- matcher: Bash(aws bedrock-agentcore-control create-*)
command: aws sts get-caller-identity —query Account —output text
once: true
AWS Bedrock AgentCore
AWS Bedrock AgentCore provides a complete platform for deploying and scaling AI agents with seven core services. This skill guides you through service selection, deployment patterns, and integration workflows using AWS CLI.
AWS Documentation Requirement
Always verify AWS facts using MCP tools (mcp__aws-mcp__* or mcp__*awsdocs*__*) before answering. The aws-mcp-setup dependency is auto-loaded — if MCP tools are unavailable, guide the user through that skill’s setup flow.
When to Use This Skill
Use this skill when you need to:
- Deploy REST APIs as MCP tools for AI agents (Gateway)
- Execute agents in serverless runtime (Runtime)
- Add conversation memory to agents (Memory)
- Manage API credentials and authentication (Identity)
- Enable agents to execute code securely (Code Interpreter)
- Allow agents to interact with websites (Browser)
- Monitor and trace agent performance (Observability)
Available Services
Common Workflows
Deploying a Gateway Target
MANDATORY - READ DETAILED DOCUMENTATION: See services/gateway/README.md for complete Gateway setup guide including deployment strategies, troubleshooting, and IAM configuration.
Quick Workflow:
- Upload OpenAPI schema to S3
- (API Key auth only) Create credential provider and store API key
- Create gateway target linking schema (and credentials if using API key)
- Verify target status and test connectivity
Note: Credential provider is only needed for API key authentication. Lambda targets use IAM roles, and MCP servers use OAuth.
Managing Credentials
MANDATORY - READ DETAILED DOCUMENTATION: See cross-service/credential-management.md for unified credential management patterns across all services.
Quick Workflow:
- Use Identity service credential providers for all API keys
- Link providers to gateway targets via ARN references
- Rotate credentials quarterly through credential provider updates
- Monitor usage with CloudWatch metrics
Monitoring Agents
MANDATORY - READ DETAILED DOCUMENTATION: See services/observability/README.md for comprehensive monitoring setup.
Quick Workflow:
- Enable observability for agents
- Configure CloudWatch dashboards for metrics
- Set up alarms for error rates and latency
- Use X-Ray for distributed tracing
Service-Specific Documentation
For detailed documentation on each AgentCore service, see the following resources:
Gateway Service
Runtime, Memory, Identity, Code Interpreter, Browser, Observability
Each service has comprehensive documentation in its respective directory:
Cross-Service Resources
For patterns and best practices that span multiple AgentCore services:
Additional Resources
Cross-Service Credential Management
Applies to: Gateway, Runtime, Memory, Identity
Overview
Credential management is a cross-cutting concern across all AgentCore services. This guide provides unified patterns for managing API keys, tokens, and authentication credentials across the AgentCore platform.
Authentication Overview
| Service |
Direction |
Supported Methods |
Use Case |
| Gateway |
Inbound |
IAM, JWT, No Auth |
Who can invoke MCP tools |
| Gateway |
Outbound |
IAM, OAuth (2LO/3LO), API Key |
Accessing external APIs |
| Runtime |
Inbound |
IAM (SigV4), JWT |
Who can invoke agents |
| Runtime |
Outbound |
OAuth, API Key |
Accessing third-party services |
| Memory |
- |
IAM Role |
Data access permissions |
| Identity |
- |
AWS KMS |
Secret encryption |
Inbound Authorization (Who Can Access Your Services)
Gateway Options (docs):
- IAM Identity: Uses AWS IAM credentials for authorization
- JWT: Tokens from identity providers (Cognito, Microsoft Entra ID, etc.)
- No Authorization: Open access - only for production with proper security controls
Runtime Options (docs):
- IAM (SigV4): Default authentication (works automatically)
- JWT Bearer Token: Token-based auth with discovery URL and audience validation
Note: A Runtime can only use one inbound auth type (IAM or JWT), not both simultaneously.
Outbound Authorization (Accessing External Services)
Gateway Options (docs):
| Target Type |
IAM (Service Role) |
OAuth 2LO |
OAuth 3LO |
API Key |
| Lambda function |
✅ |
❌ |
❌ |
❌ |
| API Gateway |
✅ |
❌ |
❌ |
✅ |
| OpenAPI schema |
❌ |
✅ |
✅ |
✅ |
| Smithy schema |
✅ |
✅ |
✅ |
❌ |
| MCP server |
❌ |
✅ |
❌ |
❌ |
- OAuth 2LO: Client credentials grant (machine-to-machine)
- OAuth 3LO: Authorization code grant (user-delegated access)
Runtime Options:
- OAuth: Tokens on behalf of users via Identity Service
- API Key: Key-based authentication via Identity Service
Best Practices
✅ DO's
Use Identity Service: Always manage credentials through the Identity service
# ✅ Correct - Use Identity API
aws bedrock-agentcore-control create-api-key-credential-provider \
--name MyCredentialProvider \
--api-key "YOUR_API_KEY_VALUE"
Separate by Environment: Use different providers for different environments
- dev-api-key-provider # Development
- staging-api-key-provider # Staging
- prod-api-key-provider # Production
Rotate Regularly: Implement quarterly credential rotation
aws bedrock-agentcore-control update-api-key-credential-provider \
--name MyCredentialProvider \
--api-key "NEW_API_KEY"
Least Privilege: Grant minimal required permissions to each credential
# API key should only have necessary API permissions
# IAM roles should have scoped-down policies
Monitor Usage: Track credential usage and set up alerts
{
"CloudWatch Alarms": {
"HighErrorRate": "Alert if > 10% failed requests",
"UnusualActivity": "Alert on usage spikes"
}
}
❌ DON'Ts
Never Hardcode: Don't embed credentials in code or configuration files
# ❌ Bad - Hardcoded API key
const apiKey = "sk-1234567890abcdef"
# ✅ Good - Reference credential provider
const credentialProvider = "MyCredentialProvider"
Don't Share Across Environments: Avoid using production keys in development
# ❌ Bad - Same key everywhere
dev: third-party-api-key: prod-key
prod: third-party-api-key: prod-key
# ✅ Good - Separate keys
dev: third-party-api-key: dev-key
prod: third-party-api-key: prod-key
Don't Commit to Git: Exclude credential files from version control
# .gitignore
*.env
*.secret
credential-*.json
Don't Use Long-Lived Tokens: Implement token refresh for OAuth
# OAuth tokens should auto-refresh
# Don't use tokens with > 30 day expiration
Multi-Service Credential Patterns
Pattern 1: Centralized Identity, Distributed Usage
┌─────────────────────────────────────┐
│ Identity Service │
│ - Stores ALL credentials │
│ - Manages rotation │
│ - Provides audit logs │
└──────────┬──────────────────────────┘
│
├────────────┬────────────┬────────────┐
▼ ▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Gateway │ │ Runtime │ │ Memory │ │ Other │
│ Uses │ │ Uses │ │ Uses │ │ Uses │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
Benefits:
- Single source of truth for all credentials
- Unified rotation and audit
- Consistent access patterns
Setup:
# 1. Create master credential in Identity
aws bedrock-agentcore-control create-api-key-credential-provider \
--name MasterAPICredentials \
--api-key "YOUR_MASTER_API_KEY"
# 2. Grant access to each service
# - Gateway: can read MasterAPICredentials
# - Runtime: can read MasterAPICredentials
# - Memory: can read MasterAPICredentials
Pattern 2: Service-Specific Credentials
┌─────────────────────────────────────┐
│ Identity Service │
│ - Stores credentials per service │
└──────────┬──────────────────────────┘
│
┌──────┴──────┬────────┬─────────┐
▼ ▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌──────┐ ┌─────┐
│ Gateway │ │ Runtime │ │Memory││Other│
│ Cred │ │ Cred │ │ Cred ││Cred │
└─────────┘ └─────────┘ └──────┘ └─────┘
Benefits:
- Isolation between services
- Independent rotation per service
- Service-specific permissions
Setup:
# Create separate providers
aws bedrock-agentcore-control create-api-key-credential-provider \
--name GatewayAPICredentials \
--api-key "YOUR_GATEWAY_API_KEY"
aws bedrock-agentcore-control create-api-key-credential-provider \
--name RuntimeCredentials \
--api-key "YOUR_RUNTIME_API_KEY"
Pattern 3: Tiered (Master + Service)
┌─────────────────────────────────────┐
│ Identity Service │
│ - Master credential │
│ - Per-service credentials │
└──────────┬──────────────────────────┘
│
┌──────┴──────┐
▼ ▼
┌─────────┐ ┌─────────────┐
│ Master │ │ Services │
│ Cred │ │ - Gateway │ │
└────┬────┘ │ - Runtime │
│ │ - Memory │
└──────┤ (each has │
│ own creds) │
└─────────────┘
Use Cases:
- Production: Master credential for critical APIs
- Development: Service-specific credentials for testing
- Emergency: Master credential as backup
Security Best Practices
Encryption
# Use KMS for secret encryption
aws secretsmanager create-secret \
--name MySecret \
--kms-key-id arn:aws:kms:us-west-2:123456789012:key/12345678-abcd-ef12-3456-7890abcdef12 \
--secret-string "my-secret-value"
Access Control
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock-agentcore:GetResourceApiKey"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:PrincipalTag/Service": "gateway"
}
}
}
]
}
Audit Logging
# Enable CloudTrail for Bedrock AgentCore
aws cloudtrail create-trail \
--name agentcore-audit \
--s3-bucket-name agentcore-audit-logs \
--include-global-service-events true
Rotation Strategy
Automated Rotation
# Enable automatic rotation (when supported)
aws secretsmanager rotate-secret \
--secret-id MySecret \
--lambda-arn arn:aws:lambda:us-west-2:123456789012:function:MyRotationFunction
# Rotation schedule (every 30 days)
aws secretsmanager rotate-secret \
--secret-id MySecret \
--rotation-rules AutomaticAfterDays=30
Manual Rotation Process
#!/bin/bash
# rotate-credentials.sh
echo "Step 1: Generate new credential"
NEW_KEY=$(generate-new-api-key)
echo "Step 2: Update in Identity service"
aws bedrock-agentcore-control update-api-key-credential-provider \
--name MyCredentialProvider \
--api-key "$NEW_KEY"
echo "Step 3: Verify all services work"
./test-all-services.sh
echo "Step 4: Delete old credential"
# Old credential is automatically deprecated
Common Patterns
Pattern: Credential Fallback
// Try primary credential, fallback to backup
async function callWithFallback(provider: string) {
try {
return await callAPI(provider);
} catch (error) {
if (error.code === 'InvalidAPICredentials') {
// Fallback to backup provider
return await callAPI(`${provider}-backup`);
}
throw error;
}
}
Pattern: Rate Limiting with Credential Pool
// Rotate through multiple credentials to avoid rate limits
const credentialPool = [
'cred-1',
'cred-2',
'cred-3'
];
let currentIndex = 0;
function getNextCredential(): string {
const credential = credentialPool[currentIndex];
currentIndex = (currentIndex + 1) % credentialPool.length;
return credential;
}
Troubleshooting Credential Issues
Issue: "Credential not found"
Diagnosis:
# Check if provider exists
aws bedrock-agentcore-control get-api-key-credential-provider \
--name MyCredentialProvider
# Check IAM permissions
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::123456789012:role/MyRole \
--action-names bedrock-agentcore:GetResourceApiKey \
--resource-arns arn:aws:bedrock-agentcore:us-west-2:123456789012:*
Solution: Create provider or grant IAM permissions
Issue: "Invalid credentials" after rotation
Diagnosis:
# Check secret value format
aws secretsmanager get-secret-value \
--secret-id arn:aws:secretsmanager:us-west-2:123456789012:secret:MySecret
# Should be: {"apiKey": "valid-key"}
Solution: Use correct update API
aws bedrock-agentcore-control update-api-key-credential-provider \
--name MyCredentialProvider \
--api-key "VALID_KEY"
Issue: Cross-service access denied
Diagnosis:
# Check which services can access the credential
aws bedrock-agentcore-control get-api-key-credential-provider \
--name MyCredentialProvider
# Review service IAM policies
Solution: Add cross-service access policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "bedrock-agentcore:GetResourceApiKey",
"Resource": "*",
"Condition": {
"ArnLike": {
"aws:PrincipalArn": [
"arn:aws:iam::*:role/*gateway*",
"arn:aws:iam::*:role/*runtime*"
]
}
}
}
]
}
Cost Considerations
Secrets Manager Costs
- Per secret: ~$0.40/month
- Per 10,000 API calls: ~$0.05
- Cross-region replication: Additional costs
Optimization:
- Share credentials across services when possible
- Use regional replication only when necessary
- Cache credential retrieval (respect security requirements)
Identity Service Costs
- Credential provider storage: Included in Secrets Manager
- API calls: Same as Secrets Manager pricing
- Cross-account access: No additional cost
References
Related Guides: