Add VM_AWS_Prueba_1_20260612_185221.TF
This commit is contained in:
parent
7b04f46e54
commit
d3e007dcf9
117
VM_AWS_Prueba_1_20260612_185221.TF
Normal file
117
VM_AWS_Prueba_1_20260612_185221.TF
Normal file
@ -0,0 +1,117 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 5.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
region = "eu-west-1"
|
||||
|
||||
default_tags {
|
||||
tags = {
|
||||
Project = "espaciodatos-{UUID}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_vpc" "simpl_vpc" {
|
||||
cidr_block = "10.0.0.0/16"
|
||||
enable_dns_support = true
|
||||
enable_dns_hostnames = true
|
||||
|
||||
tags = {
|
||||
Name = "simpl-vpc-{UUID}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "simpl_subnet" {
|
||||
vpc_id = aws_vpc.simpl_vpc.id
|
||||
cidr_block = "10.0.1.0/24"
|
||||
map_public_ip_on_launch = true
|
||||
|
||||
tags = {
|
||||
Name = "simpl-subnet-{UUID}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_internet_gateway" "simpl_igw" {
|
||||
vpc_id = aws_vpc.simpl_vpc.id
|
||||
|
||||
tags = {
|
||||
Name = "simpl-igw-{UUID}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table" "simpl_rt" {
|
||||
vpc_id = aws_vpc.simpl_vpc.id
|
||||
|
||||
route {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.simpl_igw.id
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "simpl-rt-{UUID}"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "simpl_rta" {
|
||||
subnet_id = aws_subnet.simpl_subnet.id
|
||||
route_table_id = aws_route_table.simpl_rt.id
|
||||
}
|
||||
|
||||
resource "aws_security_group" "simpl_sg" {
|
||||
count = 1
|
||||
name = "simpl-sg-{UUID}"
|
||||
description = "SIMPL security group"
|
||||
vpc_id = aws_vpc.simpl_vpc.id
|
||||
|
||||
ingress {
|
||||
description = "SSH"
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
dynamic "ingress" {
|
||||
for_each = toset(["3342", "888"])
|
||||
content {
|
||||
from_port = tonumber(ingress.value)
|
||||
to_port = tonumber(ingress.value)
|
||||
protocol = "tcp"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
cidr_blocks = ["0.0.0.0/0"]
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_instance" "simpl_vm" {
|
||||
ami = "ami-589452222222"
|
||||
instance_type = "m5.large"
|
||||
subnet_id = aws_subnet.simpl_subnet.id
|
||||
vpc_security_group_ids = 1 > 0 ? [aws_security_group.simpl_sg[0].id] : []
|
||||
user_data_base64 = "var.simpl_cloud_init"
|
||||
|
||||
root_block_device {
|
||||
volume_size = 500
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "offering-enterprise-server-{UUID}-terraform"
|
||||
}
|
||||
}
|
||||
|
||||
output "vmIps" {
|
||||
depends_on = [aws_instance.simpl_vm]
|
||||
value = [aws_instance.simpl_vm.public_ip]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user