# AWS – EC2, User Data, RDS/Aurora

## EC2 indítás

Beállítások:
- AMI: Amazon Linux 2023
- Instance type: t2.micro
- Key pair: create vagy existing
- Network: VizsgaVPC
- Subnet: PublicSubnet
- Auto-assign public IP: Enable
- Security Group: WebBiztGroup
- Storage: gp3

## User Data webserver script

```bash
#!/bin/bash
yum update -y
yum install httpd -y
systemctl start httpd
systemctl enable httpd
echo "<h1>Vizsga AWS Webserver</h1>" > /var/www/html/index.html
```

## Teszt

Böngésző:

```text
http://EC2_PUBLIC_IP
```

Ha nem megy:
- van public IP?
- SG inbound 80 open?
- subnet route table IGW-re mutat?
- user-data lefutott?
- httpd fut?

SSH:

```bash
ssh -i kulcs.pem ec2-user@PUBLIC_IP
```

HTTPD ellenőrzés EC2-n:

```bash
sudo systemctl status httpd
curl localhost
```

## RDS / Aurora

Beállítás:
- Engine: MySQL vagy Aurora MySQL
- DB instance class: t3.micro
- Storage: gp3
- Multi-AZ: ha kéri, enabled
- Public access: No
- Subnet group: private subnetek
- Security Group: RDSBiztGroup
- Port: 3306
- Master username/password
- Initial database

## DB subnet group

Legalább 2 Availability Zone private subnettel.

```text
PrivateSubnetA
PrivateSubnetB
```

## RDS Security Group

Inbound:
- MySQL/Aurora
- TCP 3306
- Source: WebBiztGroup

## Endpoint használata

RDS létrejötte után kapsz endpointot:

```text
database-1.xxxxx.eu-central-1.rds.amazonaws.com
```

Web szerverről ezzel lehet kapcsolódni.

## Vizsgán gyakori kikapcsolandók

Ha a feladat kéri:
- monitoring off
- backup off vagy minimális
- encryption off
- deletion protection off

## Hibakeresés

EC2 nem elérhető:
- public subnet?
- public IP?
- route table IGW?
- security group 22/80?
- NACL nem tilt?

RDS nem elérhető:
- private subnet jó?
- SG-to-SG source jó?
- port 3306?
- endpoint jó?
- public access szándék szerint off/on?
