Developing (CLI & SDK) Flashcards

1
Q

How can you develop and perform AWS tasks against AWS?

A
  • Using the AWS CLI on our local computer
  • Using the AWS CLI on our EC2 machines
  • Using the AWS SDK on our local computer
  • Using the AWS SDK on our EC2 machines
  • Using the AWS Instance Metadata Service for EC2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is CLI?

A

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is your first step to use the CLI on your computer?

A

Download and install it. Run aws –version to see if it was installed successfully

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What you need to do if you want to upgrade your CLI on your computer?

A

Download it and install it once again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is your next step after you install CLI on your computer?

A

Download an access key from your IAM user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is your next step on CLI after you installed and downloaded your access key on your computer?

A

1- You need to run “aws configure” in your pc console.
2- type your access key (id and secret) downloaded
3- type the default region
4- type the default format or leave empty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you use CLI on your EC2 instances (the bad way)?

A

you could run “aws configure” just like you do on your personal computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you use CLI on your EC2 instances (the right way)?

A

you can attach an IAM Role to your EC2 instances. IAM Rol can come with a policy authorizing exactly what the EC2 instance should be able to do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In general terms what you need to do if you want your EC2 instance to perform something?

A

Use IAM Roles!! Never put your credentials there!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you test your IAM policies?

A

Using AWS Policy Simulator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is EC2 Instance Metadata?

A

Instance metadata is data about your instance that you can use to configure or manage the running instance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you retrieve your Instance metadata?

A

You must run from your terminal curl http://169.254.169.254/latest/meta-data/
Ending in / is a folder, otherwise a file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What can you not retrieve from the Instance metadata?

A

The IAM policies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Do you need an IAM role to access your instance metadata?

A

No needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is AWS SDK?

A

The software development kit (SDK) helps make AWS applications and services available to your applications across many devices and operating systems without using the CLI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How many SDKs are?

A

A lot, because there are un-official SDKs as well

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What region is used by default by SDK?

A

us-east-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What happens behind scenes when you configure the CLI in your computer?

A

A directory is created at ~/.aws/credentials where all the information is stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What you should do for intermittent errors received from API Rate Limits?

A

Exponential Backoff

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How works retry mechanism in Exponential Backoff?

A

You set a constant and use exponential values i.e.

  • for 2: 1, 2, 4, 8, 16, 32…
  • for 3: 1, 3, 9, 27, 81, 243…
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the 2 types of AWS Limits (Quotas)?

A
  • API Rate Limits

- Service Quota Limits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Explain technology stack for CICD on AWS

A

use CodePipeline to orchestrate = CodeCommit + CodeBuild + CodeDeploy

23
Q

If after installing the AWS CLI, regardless the OS you are using, you use it and you get the error “aws: command not found”, what does that mean?

A

Means the aws executable is not in the PATH environment variable

24
Q

What you get if you type aws configure again in your terminal?

A
You get the current configuration:
1- access key id
2- secret access key
3- default region
4- default format
25
Q

What is created behind scenes when you run aws configure on your terminal?

A

a new directory is created in ~/.aws with two files:

  • config: region
  • credentials: access keys
26
Q

What is the cardinality between IAM Roles and EC2 instances?

A

1 IAM Role can be used by many instances but an instance can only have 1 IAM Role

27
Q

What is –dry-run?

A

It is an option to make sure we have the permissions… but not actually run the commands!
Some AWS CLI commands (such as EC2) can become expensive if they succeed, say if we wanted to try to create an EC2 Instance.

28
Q

Can you use –dry-run on any CLI API call?

A

not all commands support it

29
Q

What message do you get when you use –dry-run option in your command?

A

An error occurred (DryRunOperation) when calling the COMMAND operation: Request would have succeeded, but DryRun flag is set.

30
Q

What can you use to decode a long error message from executing an API call?

A

The STS command line “sts decode-authorization-message –encoded-message MESSAGE_TOKEN”

31
Q

What you must do on your EC2 instance to execute “sts decode-authorization-message –encoded-message MESSAGE_TOKEN” command from the instance CLI?

A

You need first to update the role policy to grant permission to execute sts:DecodeAuthorizationMessage

32
Q

What if you want to use more than one account from your terminal CLI?

A

You can use profiles

33
Q

How can I use a different account from my terminal CLI?

A

By running aws configure –profile MY_OTHER_ACCOUNT.
This will allow you to configure a new bracket in your ~/.aws directory, something like:
[default]
aws_access_key_id = dk43jkkj43j4334k
aws_secret_access_key = dasdfew32332fek43jkkj43j43ASA34kdsrere
[MY_OTHER_ACCOUNT]
aws_access_key_id = dk43jkkj43j4334k
aws_secret_access_key = dasdfew32332fek43jkkj43j43ASA34kdsrere

34
Q

What happens if I execute a command from my terminal CLI and I have more than one profile set?

A

the default profile is use. If you want to use another profile you must specify –profile MY_OTHER_ACCOUNT at the end of the command

35
Q

What is the command to create MFA temporary session from CLI?

A

You must run STS GetSessionToken API call using the command:
aws sts get-session-token –serial-number ARN_OF_THE_MFA_DEVICE –token-code MFA_CODE –duration-seconds #MS

36
Q

What you must do to use temporary credentials returned by GetSessionToken CLI’s API call?

A

You need to use it with profiles using aws configure –profile mfa and specifying the access key id and the secret access key returned.

37
Q

Once you have created a MFA profile in your CLI what is your last step to make it work?

A

You need to modify the file ~/.aws/credentials and add the session token to the file

38
Q

What is API Rate Limit for DescribeInstances API call on EC2?

A

100 calls per second

39
Q

What is API Rate Limit for GetObject API call on S3?

A

5500 GET per second per prefix

40
Q

What you should do for consistent errors received from API Rate Limits?

A

request an API throttling limit increase

41
Q

What is the Service Limit for running on-demand instances?

A

1152 vCPU

42
Q

What can you do if you need a service limit increase?

A

open a ticket

43
Q

What can you do if you need a service quota increase?

A

you can use the Service Quotas API

44
Q

What can you do if you get ThrottlingExceptions?

A

Exponential Backoff

45
Q

What has the highest priority in terms of Credentails Providers when using CLI?

A

the command line options:

  • -region
  • -output
  • -profile
46
Q

What has the highest priority in terms of Credentails Providers when using SDK or CLI without command line options?

A
Environment variables:
CLI:
a. AWS_ACCESS_KEY_ID
b. AWS_SECRET_ACCESS_KEY
c. AWS_SESSION_TOKEN
SDK:
a. AWS_ACCESS_KEY_ID
b. AWS_SECRET_ACCESS_KEY
47
Q

What has the second highest priority in terms of Credentails Providers when using SDK or CLI without command line options?

A

~/.aws/credentials file and ~/.aws/config file (just CLI)

48
Q

What has the lower priority in terms of Credentails Providers when using SDK or CLI without command line options?

A

Container credentials (ECS) and last Instance Profile Credentials (EC2 Instances Profiles)

49
Q

What is best practice for Credentials when working within AWS?

A

IAM Roles:
=> EC2 Instances Roles for EC2 Instances
=> ECS Roles for ECS tasks
=> Lambda Roles for Lambda functions

50
Q

What is best practice for Credentials when working outside AWS?

A
  • Environment variables

- Named profiles

51
Q

What is used for SigV4?

A

to add authentication information to AWS requests sent by HTTP

52
Q

What options can you use when using SigV4?

A
  • HTTP Header

- Query String (S3 pre-signed URLs)

53
Q

How do you sign the HTTP requests when using the CLI or SDK?

A

requests are signed for you in this case, otherwise you must use SigV4