You have configured two AWS CLI profiles named dev and prod for different AWS accounts. Which command correctly lists the S3 buckets in the prod account?
Use the --profile option to specify which account profile to use.
The AWS CLI uses the --profile flag to select the credentials and settings from the named profile. Using --profile prod runs the command with the prod account credentials.
You want to add a new AWS CLI profile named test with access key AKIA123TEST and secret key secretTestKey. Which command correctly sets this profile?
Use aws configure set with the --profile option to set keys for a named profile.
The aws configure set command sets individual configuration values. Using --profile test applies the settings to the test profile. Options A, B, and C are invalid AWS CLI commands.
You manage multiple AWS accounts for development, testing, and production. Which approach best isolates credentials and reduces risk?
Consider isolation and security best practices when managing multiple accounts.
Using separate profiles with unique credentials isolates access and reduces risk if one set is compromised. Sharing credentials or using root keys increases security risks.
You run a Python script using boto3 without specifying a profile. Your AWS CLI has two profiles: default and staging. Which profile will boto3 use by default?
import boto3 s3 = boto3.client('s3') buckets = s3.list_buckets() print([b['Name'] for b in buckets['Buckets']])
Check how boto3 selects credentials when no profile is explicitly given.
boto3 uses the AWS SDK credential provider chain. It first checks the AWS_PROFILE environment variable. If not set, it uses the default profile. If no credentials are found, it raises an error.
You have multiple AWS CLI profiles stored in ~/.aws/credentials file in plain text. What is the main security risk of this setup?
Consider file permissions and who can read the credentials file.
The credentials file is stored in plain text. If file permissions are not restrictive, other users or malware on the system can read the keys and misuse them. AWS does not encrypt this file automatically.