Add complete SACC v4 infrastructure project
- Terraform modules: VPC, EC2, RDS, S3, CloudFront, Route53, Lambda, IAM, Security Groups - Ansible playbooks for server configuration - Scripts: create-test-environment.sh, destroy-test-environment.sh, validate-environment.sh - Documentation: README, QUICKSTART, AGENTS - Jenkins pipeline for automated deployment - Jenkins pipeline for environment destruction
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
variable "vpc_id" {}
|
||||
variable "environment" {}
|
||||
variable "my_ip" {}
|
||||
|
||||
resource "aws_security_group" "ec2" {
|
||||
name = "sacc4-ec2-sg-${var.environment}"
|
||||
description = "Security group para instancia EC2 SACC4"
|
||||
vpc_id = var.vpc_id
|
||||
|
||||
ingress {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
protocol = "tcp"
|
||||
cidr_blocks = [var.my_ip]
|
||||
description = "SSH desde IP autorizada"
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 80
|
||||
to_port = 80
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
description = "HTTP"
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 443
|
||||
to_port = 443
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
description = "HTTPS"
|
||||
}
|
||||
|
||||
ingress {
|
||||
from_port = 8080
|
||||
to_port = 8085
|
||||
protocol = "tcp"
|
||||
cidr_blocks = [aws_vpc.main.cidr_block]
|
||||
description = "APIs internas"
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
tags = { Name = "sacc4-ec2-sg-${var.environment}" }
|
||||
}
|
||||
|
||||
resource "aws_security_group" "rds" {
|
||||
name = "sacc4-rds-sg-${var.environment}"
|
||||
description = "Security group para RDS MariaDB"
|
||||
vpc_id = var.vpc_id
|
||||
|
||||
ingress {
|
||||
from_port = 3306
|
||||
to_port = 3306
|
||||
protocol = "tcp"
|
||||
security_groups = [aws_security_group.ec2.id]
|
||||
description = "MariaDB desde EC2"
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
tags = { Name = "sacc4-rds-sg-${var.environment}" }
|
||||
}
|
||||
|
||||
resource "aws_vpc" "main" {
|
||||
cidr_block = "10.3.0.0/16"
|
||||
}
|
||||
|
||||
output "ec2_sg_id" { value = aws_security_group.ec2.id }
|
||||
output "rds_sg_id" { value = aws_security_group.rds.id }
|
||||
Reference in New Issue
Block a user