added infra setup with terraform
This commit is contained in:
parent
64ae58494b
commit
fcf203e1d8
8 changed files with 556 additions and 74 deletions
61
infra/README.md
Normal file
61
infra/README.md
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# Infrastructure Setup
|
||||
|
||||
## 1. Terraform
|
||||
|
||||
```bash
|
||||
cd infra
|
||||
cp terraform.tfvars.example terraform.tfvars # fill in your values
|
||||
terraform init
|
||||
terraform apply
|
||||
```
|
||||
|
||||
## 2. SSH Key
|
||||
|
||||
```bash
|
||||
terraform output -raw ssh_private_key > everytab-key && chmod 600 everytab-key
|
||||
terraform output ssh_command # prints the ssh command
|
||||
```
|
||||
|
||||
## 3. Bootstrap EC2
|
||||
|
||||
```bash
|
||||
scp -i everytab-key ec2-userdata.sh ec2-user@<IP>:~
|
||||
ssh -i everytab-key ec2-user@<IP> 'bash ~/ec2-userdata.sh'
|
||||
```
|
||||
|
||||
## 4. Clone Repo on EC2
|
||||
|
||||
```bash
|
||||
git clone <your-repo-url> ~/everytab
|
||||
cd ~/everytab
|
||||
```
|
||||
|
||||
## 5. Database Setup
|
||||
|
||||
On the EC2 instance:
|
||||
|
||||
```bash
|
||||
# Add to .bashrc (get the URL from: terraform output -raw database_url)
|
||||
echo "export DATABASE_URL='postgres://everytab:PASS@ENDPOINT:5432/everytab'" >> ~/.bashrc
|
||||
source ~/.bashrc
|
||||
|
||||
# Test connection
|
||||
psql $DATABASE_URL -c 'SELECT 1;'
|
||||
|
||||
# Create schema
|
||||
psql $DATABASE_URL -f ~/everytab/pipeline/01_cc_index/schema.sql
|
||||
```
|
||||
|
||||
## Teardown (after backup)
|
||||
|
||||
Switch to serving-only mode (destroys EC2, RDS, icons bucket):
|
||||
|
||||
```bash
|
||||
terraform apply -var="scanning=false"
|
||||
```
|
||||
|
||||
Full destroy (including the live site):
|
||||
|
||||
```bash
|
||||
terraform destroy
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue