AWS Credentials
Authentication Methods
The application usesboto3 (AWS SDK for Python) to interact with AWS services. Boto3 automatically looks for credentials in the following order:
-
Environment variables:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_SESSION_TOKEN(optional, for temporary credentials)
-
AWS credentials file (
~/.aws/credentials): -
AWS config file (
~/.aws/config): - IAM roles (when running on AWS EC2 or ECS)
For production deployments on AWS infrastructure, IAM roles are the recommended approach as they provide automatic credential rotation and don’t require managing static keys.
Local Development Setup
For local development, you’ll need AWS credentials with appropriate permissions:- Obtain AWS credentials from your team’s AWS administrator
-
Configure credentials using the AWS CLI:
Or manually create
~/.aws/credentials: -
Set the region in
~/.aws/config:
Required IAM Permissions
Your AWS credentials need the following S3 permissions:Resource field accordingly.
AWS Region
The application is configured to use theeu-west-1 (Europe - Ireland) region by default:
app/config.py:30 and cannot be overridden via environment variables in the current implementation.
All S3 buckets must be created in the
eu-west-1 region to match the application configuration.S3 Bucket Configuration
The application uses nine different S3 buckets for various purposes. Each bucket can be configured via environment variables.Bucket Overview
| Purpose | Environment Variable | Default (Local) | Development |
|---|---|---|---|
| CSV uploads | S3_BUCKET_CSV_UPLOAD | local-notifications-csv-upload | development-notifications-csv-upload |
| Contact lists | S3_BUCKET_CONTACT_LIST_UPLOAD | local-contact-list | development-contact-list |
| Logos (email/letter) | S3_BUCKET_LOGO_UPLOAD | public-logos-local | public-logos-tools |
| MOU documents | S3_BUCKET_MOU | local-mou | notify.tools-mou |
| Transient letters | S3_BUCKET_TRANSIENT_UPLOADED_LETTERS | local-transient-uploaded-letters | development-transient-uploaded-letters |
| Letter backups | S3_BUCKET_PRECOMPILED_ORIGINALS_BACKUP_LETTERS | local-precompiled-originals-backup-letters | development-letters-precompiled-originals-backup |
| Letter attachments | S3_BUCKET_LETTER_ATTACHMENTS | local-letter-attachments | development-letter-attachments |
| Report downloads | S3_BUCKET_REPORT_REQUESTS_DOWNLOAD | local-report-requests-download | development-report-requests-download |
| Email attachments | S3_BUCKET_TEMPLATE_EMAIL_FILES | local-template-email-files | development-template-email-files |
Bucket Purposes
CSV Upload Bucket
Environment Variable:S3_BUCKET_CSV_UPLOAD
Stores CSV files uploaded by users for batch sending notifications. Files are organized by service:
- Path structure:
service-{service_id}-notify/{upload_id}.csv - Security: Server-side encryption (AES256)
- Metadata: Custom metadata tracks processing status
- Used in:
app/s3_client/s3_csv_client.py:11
Contact List Bucket
Environment Variable:S3_BUCKET_CONTACT_LIST_UPLOAD
Stores reusable contact lists for services.
Logo Upload Bucket
Environment Variable:S3_BUCKET_LOGO_UPLOAD
Stores email and letter branding logos:
- Email logos: Stored at root level:
{filename} - Letter logos: Stored at:
letters/static/images/letter-template/{filename} - Temporary logos: Prefixed with
temp-and tagged for automatic deletion after 7 days - Permanent logos: Copied from temporary locations without delete tags
- Used in:
app/s3_client/logo_client.py:16
Logo files prefixed with
temp- are automatically cleaned up by S3 lifecycle policies after 7 days. Permanent logos must never be deleted as they may be referenced by historical email/letter templates.MOU Bucket
Environment Variable:S3_BUCKET_MOU
Stores Memorandum of Understanding documents signed by services.
Transient Uploaded Letters
Environment Variable:S3_BUCKET_TRANSIENT_UPLOADED_LETTERS
Temporary storage for uploaded letter PDFs during processing. Files are moved to permanent storage or deleted after processing.
Precompiled Letter Backups
Environment Variable:S3_BUCKET_PRECOMPILED_ORIGINALS_BACKUP_LETTERS
Backup storage for original precompiled letter files before processing.
Letter Attachments
Environment Variable:S3_BUCKET_LETTER_ATTACHMENTS
Stores PDF attachments that can be included with letters.
Report Requests Download
Environment Variable:S3_BUCKET_REPORT_REQUESTS_DOWNLOAD
Stores generated report files (CSV exports, usage reports) for user download.
Template Email Files
Environment Variable:S3_BUCKET_TEMPLATE_EMAIL_FILES
Stores file attachments for email templates.
Creating S3 Buckets
For local development, you can create buckets using the AWS CLI:Bucket Encryption
All buckets should have server-side encryption enabled:Bucket Lifecycle Policies
For buckets storing temporary files (logos, transient letters), configure lifecycle policies:CDN Configuration
Logo CDN
Environment Variable:LOGO_CDN_DOMAIN
The application serves logos via a CDN for performance:
- Default:
static-logos.notify.tools - Purpose: Serves logo images to email clients and letter PDFs
- Configuration: Must point to a CloudFront distribution or similar CDN backed by the logo S3 bucket
The logo CDN domain is used in Content Security Policy headers and must be accessible from user browsers and the template preview service.
Testing S3 Integration
The test suite usesmoto to mock AWS S3 interactions. See test examples:
tests/app/s3_client/test_s3_letter_upload_client.py:4tests/app/s3_client/test_logo_client.py:3
Troubleshooting
No AWS Credentials Found
Access Denied
- Verify your IAM user/role has the required S3 permissions
- Check that bucket names match environment variable configuration
- Ensure buckets exist in the
eu-west-1region
Bucket Not Found
- Create the missing bucket in
eu-west-1 - Verify environment variables are set correctly
- Check for typos in bucket names
Wrong Region
eu-west-1 to match the application configuration.
Production Considerations
Bucket Policies
Restrict bucket access to your application’s IAM role:Monitoring
Set up CloudWatch alarms for:- High error rates on S3 operations
- Unexpected bucket size growth
- Failed lifecycle policy deletions
Related Documentation
- Environment Variables - All application environment variables
- Session Management - Session configuration and security