Infrastructure components: - VPC with single public subnet (10.0.0.0/16) - Security group (SSH/HTTP/HTTPS from anywhere) - EC2 instance (t3.medium, Ubuntu 24.04, 30GB encrypted gp3) - S3 bucket for backups (versioned, encrypted) - IAM role with S3FullAccess for EC2 - Route 53 DNS (gitea.poll-streams.com → EC2) - Ed25519 SSH key generation via Terraform
36 lines
770 B
HCL
36 lines
770 B
HCL
# IAM Role for EC2 to access S3
|
|
resource "aws_iam_role" "ec2_role" {
|
|
name = "${var.project_name}-ec2-role"
|
|
|
|
assume_role_policy = jsonencode({
|
|
Version = "2012-10-17"
|
|
Statement = [
|
|
{
|
|
Action = "sts:AssumeRole"
|
|
Effect = "Allow"
|
|
Principal = {
|
|
Service = "ec2.amazonaws.com"
|
|
}
|
|
}
|
|
]
|
|
})
|
|
|
|
tags = {
|
|
Name = "${var.project_name}-ec2-role"
|
|
}
|
|
}
|
|
|
|
resource "aws_iam_role_policy_attachment" "s3_full_access" {
|
|
role = aws_iam_role.ec2_role.name
|
|
policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess"
|
|
}
|
|
|
|
resource "aws_iam_instance_profile" "ec2_profile" {
|
|
name = "${var.project_name}-ec2-profile"
|
|
role = aws_iam_role.ec2_role.name
|
|
|
|
tags = {
|
|
Name = "${var.project_name}-ec2-profile"
|
|
}
|
|
}
|