Update terraform related files
This commit is contained in:
parent
5fdddba3f5
commit
4a1af51ee6
3 changed files with 79 additions and 4 deletions
9
datasource.tf
Normal file
9
datasource.tf
Normal file
|
@ -0,0 +1,9 @@
|
|||
data "aws_ami" "server_ami" {
|
||||
most_recent = true
|
||||
owners = ["099720109477"]
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-*"]
|
||||
}
|
||||
}
|
71
main.tf
71
main.tf
|
@ -1,4 +1,4 @@
|
|||
resource "aws_vpc" "ml-survey-vpc" {
|
||||
resource "aws_vpc" "mlsurvey_vpc" {
|
||||
cidr_block = "10.0.0.0/16"
|
||||
enable_dns_hostnames = true
|
||||
enable_dns_support = true
|
||||
|
@ -7,12 +7,75 @@ resource "aws_vpc" "ml-survey-vpc" {
|
|||
}
|
||||
}
|
||||
|
||||
resource "aws_subnet" "ml-survey-public-subnet" {
|
||||
vpc_id = aws_vpc.ml-survey-vpc.id
|
||||
resource "aws_subnet" "mlsurvey_public_subnet" {
|
||||
vpc_id = aws_vpc.mlsurvey_vpc.id
|
||||
cidr_block = "10.0.1.0/24"
|
||||
map_public_ip_on_launch = true
|
||||
availability_zone = "eu-central-1"
|
||||
availability_zone = "eu-central-1a"
|
||||
tags = {
|
||||
Name = "ml-survey-public"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_internet_gateway" "mlsurvey_internet_gateway" {
|
||||
vpc_id = aws_vpc.mlsurvey_vpc.id
|
||||
tags = {
|
||||
Name = "ml-survey-igw"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route_table" "mlsurvey_public_rt" {
|
||||
vpc_id = aws_vpc.mlsurvey_vpc.id
|
||||
tags = {
|
||||
Name = "ml-survey-rt"
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_route" "mlsurvey_default_route" {
|
||||
route_table_id = aws_route_table.mlsurvey_public_rt.id
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = aws_internet_gateway.mlsurvey_internet_gateway.id
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "mlsurvey_public_assoc" {
|
||||
subnet_id = aws_subnet.mlsurvey_public_subnet.id
|
||||
route_table_id = aws_route_table.mlsurvey_public_rt.id
|
||||
}
|
||||
|
||||
resource "aws_security_group" "mlsurvey_sg" {
|
||||
name = "ml-survey-sg"
|
||||
description = "ml-survey security group"
|
||||
vpc_id = aws_vpc.mlsurvey_vpc.id
|
||||
|
||||
ingress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
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_key_pair" "mlsurvey_auth" {
|
||||
key_name = "ml-survey-key"
|
||||
public_key = file("~/.ssh/ml-survey-key.pub")
|
||||
}
|
||||
|
||||
resource "aws_instance" "dev_node" {
|
||||
instance_type = "t2.micro"
|
||||
ami = data.aws_ami.server_ami.id
|
||||
key_name = aws_key_pair.mlsurvey_auth.id
|
||||
vpc_security_group_ids = [aws_security_group.mlsurvey_sg.id]
|
||||
subnet_id = aws_subnet.mlsurvey_public_subnet.id
|
||||
user_data = file("userdata.tpl")
|
||||
|
||||
tags = {
|
||||
Name = "dev-node"
|
||||
}
|
||||
}
|
||||
|
|
3
userdata.tpl
Executable file
3
userdata.tpl
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
sudo apt-get update -y &&
|
||||
sudo apt-get install -y apt-transport-https ca-certifictes curl gnupg-agent
|
Loading…
Add table
Reference in a new issue