-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvm.tf
37 lines (30 loc) · 922 Bytes
/
vm.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
data "aws_ami" "latest-ubuntu" {
most_recent = true
owners = ["099720109477"] # Canonical
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
data "template_file" "userdata" {
template = file("${path.module}/userdata.sh")
}
resource "aws_key_pair" "machine_key" {
key_name = var.application_name
public_key = var.public_key
}
resource "aws_instance" "vpnserver" {
ami = data.aws_ami.latest-ubuntu.id
instance_type = var.instancetype
user_data = data.template_file.userdata.rendered
key_name = aws_key_pair.machine_key.key_name
vpc_security_group_ids = [aws_security_group.vpnsecuritygroup.id]
associate_public_ip_address = true
tags = {
Name = var.application_name
}
}