AWS Credentials Setup - Quick Start Guideď
This guide shows you how to quickly configure AWS credentials for PutPlaceâs S3 storage backend.
Quick Start Optionsď
Option 1: AWS Credentials File (Recommended for Development)ď
Best for: Local development, testing, on-premises servers
Create AWS credentials file:
mkdir -p ~/.aws
cat > ~/.aws/credentials << 'EOF'
[putplace]
aws_access_key_id = YOUR_ACCESS_KEY_HERE
aws_secret_access_key = YOUR_SECRET_KEY_HERE
EOF
chmod 600 ~/.aws/credentials
Configure PutPlace (
.envfile):
STORAGE_BACKEND=s3
S3_BUCKET_NAME=your-bucket-name
S3_REGION_NAME=us-east-1
AWS_PROFILE=putplace
Start server:
uvicorn putplace.main:app
Thatâs it! The server will use the putplace profile from ~/.aws/credentials.
Option 2: IAM Role (Recommended for Production on AWS)ď
Best for: EC2, ECS, Lambda, EKS running on AWS
Create IAM policy with S3 permissions:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:HeadObject"],
"Resource": "arn:aws:s3:::your-bucket-name/files/*"
}]
}
Attach policy to EC2 instance role (via AWS Console or CLI)
Configure PutPlace (
.envfile):
STORAGE_BACKEND=s3
S3_BUCKET_NAME=your-bucket-name
S3_REGION_NAME=us-east-1
# No AWS credentials needed!
Start server:
uvicorn putplace.main:app
The server automatically uses the IAM role credentials. No keys needed!
Option 3: Environment Variables (Quick Testing)ď
Best for: Quick testing, CI/CD pipelines
Set environment variables:
export STORAGE_BACKEND=s3
export S3_BUCKET_NAME=your-bucket-name
export S3_REGION_NAME=us-east-1
export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_HERE
export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY_HERE
Start server:
uvicorn putplace.main:app
â ď¸ Warning: Credentials are visible in process list. Not recommended for production.
Verificationď
Quick Test: Standalone S3/SES Configuration Tests (v0.5.2+)ď
The fastest way to test your AWS credentials:
# Test S3 access
pp_configure S3
# Test SES access
pp_configure SES
# Test in specific region
pp_configure S3 --aws-region us-west-2
# Via invoke task
invoke configure --test-mode=S3
invoke configure --test-mode=SES
These commands will:
â Use your AWS credentials (IAM role, profile, or environment variables)
â Test connectivity to AWS services
â Show clear success/failure messages
â Exit with status code 0 (success) or 1 (failure)
Full Integration Testď
Test that your credentials work with the running server:
# Check if server can connect to S3
curl http://localhost:8000/health
# Upload a test file
curl -X POST http://localhost:8000/put_file \
-H "Content-Type: application/json" \
-d '{
"filepath": "/tmp/test.txt",
"hostname": "testhost",
"ip_address": "127.0.0.1",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"file_size": 0,
"file_mode": 33188,
"file_uid": 1000,
"file_gid": 1000,
"file_mtime": 1609459200.0,
"file_atime": 1609459200.0,
"file_ctime": 1609459200.0
}'
Check the server logs for:
â
"Initialized S3Storage with bucket: ..."â
"Using AWS profile: ..."(if using profile)â
"Using default AWS credential chain"(if using IAM role)
Troubleshootingď
âUnable to locate credentialsâď
Solution: Check in this order:
Is
AWS_PROFILEset correctly in.env?Does
~/.aws/credentialsfile exist and have correct permissions (600)?For EC2: Is IAM role attached to the instance?
# Check credentials file permissions
ls -la ~/.aws/credentials
# Should show: -rw------- (600)
# Check if AWS CLI can access credentials
aws sts get-caller-identity
âAccess Deniedâ errorsď
Solution: Check IAM permissions:
# Test S3 access with AWS CLI
aws s3 ls s3://your-bucket-name/files/
aws s3 cp /tmp/test.txt s3://your-bucket-name/files/test.txt
# If these work, PutPlace should work too
Make sure IAM policy includes: s3:PutObject, s3:GetObject, s3:HeadObject, s3:DeleteObject
âNoSuchBucketâ errorď
Solution: Create the S3 bucket:
# Create bucket
aws s3 mb s3://your-bucket-name --region us-east-1
# Enable versioning (optional but recommended)
aws s3api put-bucket-versioning \
--bucket your-bucket-name \
--versioning-configuration Status=Enabled
Complete Configuration Examplesď
Example 1: Development Setupď
# ~/.aws/credentials
[putplace-dev]
aws_access_key_id = AKIAI...
aws_secret_access_key = wJalr...
# .env
STORAGE_BACKEND=s3
S3_BUCKET_NAME=putplace-dev-bucket
S3_REGION_NAME=us-east-1
AWS_PROFILE=putplace-dev
MONGODB_DATABASE=putplace_dev
Example 2: Production on AWS EC2ď
# .env (no credentials needed!)
STORAGE_BACKEND=s3
S3_BUCKET_NAME=putplace-prod-bucket
S3_REGION_NAME=us-west-2
MONGODB_URL=mongodb://prod-db-server:27017
MONGODB_DATABASE=putplace_prod
EC2 instance must have IAM role with S3 permissions attached.
Example 3: Multiple Environments with Profilesď
# ~/.aws/credentials
[putplace-dev]
aws_access_key_id = AKIAI...dev...
aws_secret_access_key = secret...dev...
[putplace-staging]
aws_access_key_id = AKIAI...staging...
aws_secret_access_key = secret...staging...
[putplace-prod]
aws_access_key_id = AKIAI...prod...
aws_secret_access_key = secret...prod...
# .env.dev
AWS_PROFILE=putplace-dev
S3_BUCKET_NAME=putplace-dev-bucket
# .env.staging
AWS_PROFILE=putplace-staging
S3_BUCKET_NAME=putplace-staging-bucket
# .env.prod
AWS_PROFILE=putplace-prod
S3_BUCKET_NAME=putplace-prod-bucket
Security Best Practicesď
â DO:
Use IAM roles on AWS infrastructure (no keys needed)
Use AWS credentials file with profiles for on-premises
Set
chmod 600 ~/.aws/credentialsUse separate credentials for dev/staging/production
Rotate access keys every 90 days
Use least-privilege IAM policies
â DONâT:
Donât commit
.envfile to gitDonât use root AWS account credentials
Donât grant
s3:*permissionsDonât share credentials between applications
Donât log AWS credentials
Next Stepsď
đ Read the complete SECURITY.md for comprehensive security guidance
đ Learn about AWS Secrets Manager and HashiCorp Vault for advanced secret management
đ Review IAM policy examples for least-privilege access
đ Set up credential rotation for long-lived keys
Quick Referenceď
Method |
Security |
Setup |
Best For |
|---|---|---|---|
IAM Role |
âââââ |
Medium |
Production on AWS |
AWS Profile |
ââââ |
Easy |
Development, On-premises |
Env Variables |
âââ |
Easy |
Testing, CI/CD |
Hardcoded |
â |
Very Easy |
Never use! |
Default recommendation:
Production on AWS: Use IAM roles
Production on-premises: Use AWS credentials file with profiles
Development: Use AWS credentials file with profiles
CI/CD: Use environment variables from secret manager