0
0
AWScloud~20 mins

CLI scripting basics in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CLI Scripting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What is the output of this AWS CLI command?
You run the following AWS CLI command to list all S3 buckets in your account:

aws s3api list-buckets --query 'Buckets[].Name' --output text

What will be the output format?
AA newline-separated list of bucket names in plain text.
BA JSON array of bucket names.
CA table with bucket names and creation dates.
DAn error because --output text is invalid here.
Attempts:
2 left
💡 Hint
Think about what the --output text option does in AWS CLI.
Configuration
intermediate
2:00remaining
Which AWS CLI command sets the default region for future commands?
You want to configure your AWS CLI so that all future commands use the region us-west-2 by default. Which command achieves this?
Aaws configure region us-west-2
Baws set region us-west-2
Caws configure set region us-west-2
Daws configure default-region us-west-2
Attempts:
2 left
💡 Hint
The AWS CLI uses the configure set command to change settings.
security
advanced
2:00remaining
What error occurs when running this AWS CLI command without permissions?
You run this command to list EC2 instances:

aws ec2 describe-instances

Your IAM user does not have permission to describe instances. What error message will you see?
AA ResourceNotFoundException error because no instances exist.
BNo error; the command returns an empty list.
CA SyntaxError due to incorrect command syntax.
DAn AccessDeniedException error indicating lack of permissions.
Attempts:
2 left
💡 Hint
Think about what happens when you lack permissions to perform an AWS action.
Architecture
advanced
3:00remaining
Which AWS CLI command sequence correctly creates and tags an EC2 instance?
You want to create an EC2 instance and then add a Name tag to it using AWS CLI. Which sequence of commands is correct?
A
1) aws ec2 run-instances --image-id ami-12345678 --count 1 --instance-type t2.micro
2) aws ec2 create-tags --resources <instance-id> --tags Key=Name,Value=MyInstance
B
1) aws ec2 create-tags --resources <instance-id> --tags Key=Name,Value=MyInstance
2) aws ec2 run-instances --image-id ami-12345678 --count 1 --instance-type t2.micro
C1) aws ec2 run-instances --image-id ami-12345678 --count 1 --instance-type t2.micro --tag Name=MyInstance
D1) aws ec2 run-instances --image-id ami-12345678 --count 1 --instance-type t2.micro --tags Key=Name,Value=MyInstance
Attempts:
2 left
💡 Hint
Creating tags requires the instance ID, which you get after launching the instance.
Best Practice
expert
3:00remaining
What is the best practice to securely run AWS CLI commands in automated scripts?
You want to run AWS CLI commands in an automated script on a server. Which approach is best to securely provide credentials?
AStore AWS access keys directly in the script as plain text variables.
BUse IAM roles attached to the server or instance to provide temporary credentials.
CManually enter AWS credentials each time the script runs.
DStore AWS credentials in a publicly accessible file on the server.
Attempts:
2 left
💡 Hint
Think about avoiding hardcoding secrets and using AWS features for security.