ResourceNotFoundException
This error occurs when the requested resource (such as a DynamoDB table, Lambda function, or secret) does not exist in the specified AWS region or account.
Usually happens because:
- ☑ Target resource resides inside different physical region than client's active config
- ☑ The table, function, or secret name contains typing mistakes or missing prefix keys
- ☑ Resource has been deleted or is still undergoing creation sequences
🔍 Quick Checklist:
What is ResourceNotFoundException?
A 'ResourceNotFoundException' is raised when an API client attempts to read, update, or delete an AWS resource that the service cannot find. AWS resources are scoped strictly by AWS Account ID and AWS Region. Typical causes include typos in the resource name (e.g. table name or secret name), specifying the wrong region context (e.g., querying us-east-1 when the secret is created in us-west-2), or attempting to access a resource that has been deleted or is still provisioning.
Common Causes
- Typo in resource name: The database table, lambda function name, or secret path contains spelling mistakes or wrong suffixes.
- Active region mismatch: The calling client environment is configured to point to one region (e.g. us-east-1) while the target resource resides in another region (e.g. us-west-2).
- Resource deleted or not yet created: The resource has either been deleted by another user/process or is still undergoing creation/stack deployment.
| Cause | Frequency |
|---|---|
| AWS Region mismatch (resource is in us-west-2, client queries us-east-1) | ⭐⭐⭐⭐⭐ |
| Typo in resource name or suffix string | ⭐⭐⭐⭐ |
| Querying resource that has been deleted or not yet fully provisioned | ⭐⭐⭐ |
Common Mistakes
- Assuming resources are global (with the exception of IAM, Route 53, and CloudFront, most AWS resources are strictly regional).
- Spelling secret paths or lambda names with wrong environments prefixes or trailing spaces.
How to Fix
AWS Operations & Verification
Utilize AWS CLI waiter commands inside shell scripts to block execution until the target resource is fully active.
# 1. Create a DynamoDB table
$ aws dynamodb create-table --table-name ProductTable --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --billing-mode PAY_PER_REQUEST
# 2. Block script execution until table transitions to ACTIVE state
$ aws dynamodb wait table-exists --table-name ProductTablePlatform Specific Fixes
List existing resources inside specific regions using the AWS CLI.
# 1. List DynamoDB tables in oregon region
aws dynamodb list-tables --region us-west-2
# 2. List secrets in secrets manager
aws secretsmanager list-secrets --region us-west-2Best Practices
- Adopt infrastructure as code configurations (Terraform / CloudFormation) to automatically wire target resources variables.
- Adopt automated verification scripts to test resource states prior to application startups.
Frequently Asked Questions (FAQ)
Q: What is a ResourceNotFoundException?
This is a client-side (400 Bad Request) error. It means the AWS service verified your credentials and permissions, but could not physically find the specific table, function, secret, or stream you requested.
Q: Why do I get this error when my resource definitely exists?
Check the region. This is the most common cause. If your DynamoDB table was created in 'us-west-2' (Oregon), but your local environment variable 'AWS_DEFAULT_REGION' is set to 'us-east-1' (N. Virginia), any queries to the table will fail with ResourceNotFoundException.
Q: How do I solve this for Secrets Manager?
Confirm the Secret Name matches exactly, including slashes or environments prefixes (e.g. '/prod/database/password'). If you use a Secret ARN, make sure the suffix characters match. Run 'aws secretsmanager list-secrets' to verify.
Q: How do I wait for a resource to be created in scripts?
Use AWS CLI waiters. Waiters poll the resource status until it reaches a ready state. For example: 'aws dynamodb wait table-exists --table-name ProductTable'. This pauses your shell script execution until the table status transitions to 'ACTIVE'.