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.
Quick Start: Create a Bedrock User via CloudShell¶
If you have access to the AWS Console, the fastest way to create a Bedrock IAM user and generate credentials is to run aws-bedrock-user.sh directly in AWS CloudShell — no local AWS CLI setup required, since CloudShell is already authenticated as your console account.
Steps¶
- Open the AWS Console and sign in
- Click the CloudShell icon in the top navigation bar (or search for "CloudShell")
- Paste and run this one-liner:
1 | |
Or if you have cloned this repo, run it directly:
1 | |
- Enter your username when prompted — the script will prefix it with
bedrock- - Copy the credentials block from the output into
~/.aws/credentialson your local machine
What the script does¶
- Creates an IAM user named
bedrock-<yourname> - Attaches the
AmazonBedrockFullAccessmanaged policy - Generates a permanent access key pair
- Prints a ready-to-paste
[bedrock]credentials block
Output example¶
1 2 3 4 5 | |
Paste this block into ~/.aws/credentials, then follow the profile configuration steps below to add the matching region entry to ~/.aws/config.
Credential security
The secret access key is shown once — it cannot be retrieved again. Save it immediately. If you lose it, delete the key in IAM and generate a new one.
AmazonBedrockFullAccess scope
This managed policy grants access to all Bedrock models and features. For production environments, consider creating a custom policy restricted to the specific model ARNs and actions your application needs.
Installing AWS CLI v2¶
AWS CLI v2 is the recommended command-line interface for AWS services.
Linux/WSL Installation¶
One-liner to download, extract (using Python's built-in zipfile — no unzip required), install to user directory, and verify:
1 | |
This installs AWS CLI to ~/.local/aws-cli with the aws command in ~/.local/bin (no sudo required, no unzip dependency).
Requirements:
- Ensure ~/.local/bin is in your PATH (see Shell Setup)
macOS Installation¶
Using Homebrew (Recommended):
1 | |
Or manually (user directory installation):
One-liner to download, extract, install to user directory, and verify:
1 | |
This installs AWS CLI to ~/.local/aws-cli with the aws command in ~/.local/bin (no sudo required).
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