Amazon Web Services (AWS)¶
Cloud infrastructure and services configuration guide with security-first credential management.
Overview¶
AWS provides scalable cloud computing services. This section covers secure setup, CLI configuration, and best practices for managing AWS credentials with proper scope isolation.
Installing AWS CLI v2¶
AWS CLI v2 is the recommended command-line interface for AWS services.
Linux/WSL Installation¶
One-liner to download, extract, install, and verify:
1 | |
macOS Installation¶
Using Homebrew (Recommended):
1 | |
Or manually:
One-liner to download, extract, install, and verify:
1 | |
AWS Credential Setup¶
Understanding Credential Files¶
AWS uses two configuration files:
~/.aws/credentials- Contains access keys (API credentials)~/.aws/config- Contains region and profile configuration
Creating AWS Credentials via CLI¶
The easiest way to set up credentials is using the AWS CLI interactive configuration:
1 | |
This prompts for: 1. AWS Access Key ID 2. AWS Secret Access Key 3. Default region 4. Default output format
However, this creates a default profile with broad permissions. For better security, follow the profile-based approach below.
Security-First Credential Management¶
Critical Security Principle¶
Never use static credentials with broad AWS permissions as your default profile. Instead:
- Use temporary credentials or IAM roles when possible
- Keep static credentials in separate, narrowly-scoped profiles
- Grant only the minimum permissions needed for each profile
Setting Up Service-Specific Profiles¶
Create isolated credential profiles for each service. For example, to set up a Bedrock-only profile:
1 | |
Enter your credentials when prompted. This creates:
In ~/.aws/credentials:
1 2 3 | |
In ~/.aws/config:
1 2 3 | |
Complete Profile Configuration Example¶
For multiple services with proper isolation:
~/.aws/credentials
1 2 3 4 5 6 7 8 9 | |
~/.aws/config
1 2 3 4 5 6 7 8 9 | |
IAM Policy Examples¶
When creating AWS access keys for a profile, apply strict IAM policies:
Bedrock-Only Policy:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
S3-Only Policy:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Using Profiles with AWS CLI¶
Override Default Profile¶
Use any configured profile with the --profile flag:
1 2 3 4 5 | |
Set Default Profile for Session¶
1 2 | |
Using Profiles with AWS SDKs¶
Most AWS SDKs (Python boto3, Node.js, etc.) respect the AWS_PROFILE environment variable:
1 2 | |
Credentials File Security¶
Ensure proper permissions on credential files:
1 2 3 | |
Never commit credential files to version control:
1 2 3 | |
Best Practices¶
Profile Isolation¶
- ✅ DO: Create separate profiles for each service/application
- ❌ DON'T: Use default profile with full AWS permissions
Credential Rotation¶
- ✅ DO: Rotate access keys regularly (quarterly minimum)
- ❌ DON'T: Reuse the same credentials across multiple systems
Least Privilege¶
- ✅ DO: Grant only the permissions each service needs
- ❌ DON'T: Attach broad policies like
AdministratorAccess
Monitoring¶
- ✅ DO: Enable CloudTrail to audit credential usage
- ✅ DO: Check CloudWatch for unusual activity
- ❌ DON'T: Ignore access logs
Temporary Credentials¶
- ✅ PREFER: Temporary credentials via STS AssumeRole (when possible)
- ❌ AVOID: Long-lived static credentials for high-privilege access