Section 12: AWS CLI, SDK, IAM Roles & Policies Flashcards
You want to know if you can create ec2 instances using the AWS CLI without actually creating an issue. How can you do that?
Pass the –dry-run flag as the first argument after the command.
After running an AWS CLI command it returned an encrypted failure message. Which command can you use to decrypt the message?
STS. (Security Token Service)
Run aws sts decode-authorization-message –encoded-message <encrypted-failure-message></encrypted-failure-message>
What is IMDS?
Instance Meta-Data Service.
You can request meta-data about an instance using a URL
What is the difference between IMDS v1 and IMDS v2?
IMDS v1 is using a simple HTTP get request:
http://169.254.169.254/latest/meta-data
IMDS v2 takes 2 requests:
Step 1: Get a token
TOKEN=curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"
Step 2: Request meta data using the token
curl -H “X-aws-ec2-metadata-token: $TOKEN” -v http://169.254.169.254/latest/meta-data/
What can we use the use MFA for the AWS CLI
aws sts get-session-token
What will happen if we use the AWS SDK without specifying a default region?
It will use us-east-1
What is exponential backoff?
Retry requests with exponential delays when receiving a 5xx response (ThrottlingException, due to rate limits) when calling the AWS API.
First retry after 1 second
Second retry after 2 seconds
Third retry after 4 seconds
Fourth retry after 8 seconds
…
Do not retry when receiving 4xx responses.
In which order will the AWS CLI look for credentials? (Credentials Provider Chain)
- Command line options
- Environment variables
- CLI credentials file (~/.aws/credentials)
- CLI configuration file (~/.aws/config)
- Container credentials (for ECS tasks)
- Instance profile credentials (EC2 Instance Profile)
In which order will the AWS SDK look for credentials? (Java)
- Java system properties
- Environment variables
- The default credential profiles file (~/.aws/credentials)
- Container credentials (for ECS tasks)
- Instance profile credentials (EC2 Instance Profile)
Which 2 options do you have to send a SigV4 signed request?
- using HTTP Headers
- using Query parameters (ex: S3 pre-signed URLs)