# 8. AWS Primer for Terraform
[toc]
**Topics**
:::success
- [x] Create an S3 bucket via AWS Console
- [x] Create AWS Access key id and Secret access key via AWS Console
- [x] Get AWS Access key id and Secret access key via Simplilearn LMS
- [x] Configure and work with AWS CLI
:::
---
### AWS Authentication mechanisms
---
:::warning
- AWS Console (GUI) --> User id + Password
- AWS CLI (Command line) --> Access key id + Secret access key
- AWS SDK (Programmatic access) --> Access key id + Secret access key
:::
---
### Create an S3 bucket via AWS Console
---
##### Login to AWS Console (console.aws.amazon.com) and click on *"View all services"*.

##### Scroll down to subcategory *"Storage"* and click *"S3"*

##### On S3 Dashboard click on *"Create Bucket"*

##### Provide a DNS compliant (Globally unique) name for your bucket.

##### Keep the rest of the setting to default, scroll down to the bottom of the page and click *"Create Bucket"*

##### Your bucket should be created and listed under your *"Buckets"*

:arrow_right: *If bucket creation fails, then add some additional characters to your proposed bucket name to make it globally unique.*
---
### Create AWS *access_key* and *secret_access_key* via AWS Console
---
##### Login into AWS Console
##### Navigate to IAM Dashboard --> Users --> select the user --> select "security credentials"

##### Scroll down to "Access Keys" and click on "Create access key"

##### Select the first option to create access key for CLI access, agree to terms and conditions and click *"Next"*

##### Provide an appropriate description tag for your credentials

##### Copy/download access key and secret access key

:arrow_right: *Make sure to copy/download the secret access key from the summary page. Once you exit the page this information cannot be retrieved again.*
---
### Get AWS Access key id and Secret access key via Simplilearn LMS
---
##### Login to your Simplilearn LMS and navigate to *Practice Labs*

##### Make sure to select *AWS* as your lab environment and click on *Launch Lab*

##### Click on *Launch Lab* again

##### Select the Tile which says *AWS Web Console* and click on *Auth url*

##### Select the Tile which says *AWS API Access*. This will show the following details on screen
- Access Key
- Secret Key
- Security Token

:arrow_right: *Make sure to copy all 3 in a text editor. We will need it when we write our terraform policy files.*
---
### Configure and work with AWS CLI
---
#### AWS CLI installation
- Login to your Simplilearn Lab Machine
- Check if aws cli is installed already via the following command:
````yaml=
Command:
aws --version
Expected Output:
aws-cli/2.11.8 Python/3.11.2 Darwin/22.5.0 exe/x86_64 prompt/off
````
:arrow_right: *refere to [awscli installation](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) page if AWSCLI is not installed already*
#### AWS CLI configuration
- Run the *aws configure* command to configure aws cli on the system. Please note that you would need *access_key* and *secret_access_key* gathered in the previous steps.
````yaml=
$ aws configure
AWS Access Key ID [None]: <<your access-key-id here>>
AWS Secret Access Key [None]: <<your secret-access-key here>>
Default region name [None]: us-east-1
Default output format [None]: json
````

#### Validate the configuration
- Run any aws command to see if you are able to access your AWS account via CLI
````yaml=
aws s3 ls
aws ec2 describe-regions --output table
````

:arrow_right: *To understand more about AWS CLI commands refer the following AWS documentation link --> https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-commandstructure.html*
### References
:::success
- https://aws.amazon.com/free/
- https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
- https://aws.amazon.com/developer/tools/
**AWS Control Tower Resources**
Workshops
- [AWS Control Tower workshop](https://catalog.workshops.aws/control-tower/en-US)
- [AWS Control Tower Immersion Day](https://controltower.aws-management.tools/immersionday/)
Whitepapers
- [Organizing Your AWS
Environment Using
Multiple Accounts [AWS Whitepaper]](https://docs.aws.amazon.com/pdfs/whitepapers/latest/organizing-your-aws-environment/organizing-your-aws-environment.pdf)
- [AWS Security Reference
Architecture [AWS Presctive Guidance]](https://d1.awsstatic.com/APG/aws-security-reference-architecture-v4.pdf)
Talks/Webinars
- [AWS re:Invent 2022 - Reimagining multi-account deployments for security and speed (NFX305)](https://www.youtube.com/watch?v=MKc9r6xOTpk)
- [AWS re:Invent 2022 - Multi-Region design patterns and best practices (ARC306)](https://www.youtube.com/watch?v=ilgpzlE7Hds)
:::