[toc]
### AWS Concepts
#### AWS Services can have:
:::success
- Soft limits --> 5 VPC per account per region
- Hard limits --> 5TB Max file/object size (in S3)
:::
#### You can work with AWS via:
:::success
- AWS Console (GUI)(console.aws.amazon.com)
- AWS CLI (Command line) -
- SDK (Programmatic access)
:::
#### AWS Terminology
:::success
- EC2 --> Virtual Machines on AWS
- AMI --> Pre-configured OS template
- Keypair --> asymmetric key-pair for passwordless authentication
- VPC --> Logical network boundry where you have full control
- Subnets --> logical splitting of VPC into multipe smaller sub-networks
- Security Groups (SG) --> Firewalls in AWS
- Instance type --> to Define resources (vCPU / memory / network bandwidth)
- User data --> to pass initialization scripts
:::
#### EC2 nomenclature
:::success
**m5.xlarge**
m --> instance family
5 --> generation
xlarge --> size (vCPU/memory/network bandwidth)
:::
### Classroom activity 1 - Create an EC2 instance with default properties
#### Step 1: Create an instance with the following details:
:::warning
Software Image (AMI) --> Amazon Linux 2023 (ami-0f34c5ae932e6f0e4)
Instance type --> t2.micro
Keypair --> Create a new one by clicking "create a new keypair"
Security group --> select existing security group --> default
:::
:arrow_right: *Keep the rest of the values as default and create the instance*
#### Step 2: Connect to the instance
:::warning
- Go to EC2 dashboard
- List the EC2 instances
- Select the instance from the list
- Click on connect
- Click on connect
- Your terminal window should open in a new browser tab
:::
#### Step 3: Terminate the instance
:::warning
- Go to EC2 dashboard
- List the EC2 instances
- Select the instance
- Go to "instance state"
- Select "Terminate Instance"
:::
### Classroom Activity 2 - Create an EC2 instance with User data
#### Step 1: Create an EC2 instance via AWS Console with the following properties:
:::warning
Name = terraform-demo
AMI = Amazon Linux 2023 ## choose the right AMI as per your AWS region
Instance type = t2.micro
Security Group = create a new security group with the following incoming ports allowed:
80
443
22
User data = Put the following script
````yaml
#!/bin/bash
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo “Welcome to Simplilearn CMAT from $(hostname -f)” > /var/www/html/index.html
````
:mag: *Everything else should be left to their default values.*
:::
#### Step 2: Validation
:::warning
Access the webpage on a browser successfully
:::
#### Step 3: Connect to the instance
:::warning
- Go to EC2 dashboard
- List the EC2 instances
- Select the instance from the list
- Click on connect
- Click on connect
- Your terminal window should open in a new browser tab
:::
#### Step 4: Terminate the instance
:::warning
- Go to EC2 dashboard
- List the EC2 instances
- Select the instance
- Go to "instance state"
- Select "Terminate Instance"
:::
### How to get *access_key* and *secret_access_key* in your own AWS accounts
**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.*
### References
:::success
**Documentation**
- https://cdkworkshop.com/
- https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
- https://aws.amazon.com/developer/tools/
- https://aws.amazon.com/ec2/instance-types/
**Workshops**
- https://ec2spotworkshops.com/ (Fundamental)
- https://wellarchitectedlabs.com/ (Advanced)
-
:::