forked from poush/terraform-aws-pritunl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
47 lines (39 loc) · 1.29 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
data "aws_ami" "oracle" {
most_recent = true
filter {
name = "name"
values = ["OL8.4-x86_64-HVM-2021-05-28"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["131827586825"] # Oracle
}
resource "aws_instance" "pritunl" {
ami = data.aws_ami.oracle.id
instance_type = var.instance_type
key_name = var.aws_key_name
user_data = file("${path.module}/provision.sh")
iam_instance_profile = var.iam_instance_profile
root_block_device {
volume_size = var.volume_size
tags = merge(tomap({ "Name" = format("%s-%s", var.resource_name_prefix, "vpn") }), var.tags, )
delete_on_termination = false
}
lifecycle {
ignore_changes = [user_data, ami]
}
vpc_security_group_ids = compact(flatten([
aws_security_group.pritunl.id,
var.additional_security_group
]))
subnet_id = var.public_subnet_id
associate_public_ip_address = true
tags = merge(tomap({ "Name" = format("%s-%s", var.resource_name_prefix, "vpn") }), var.tags, )
}
resource "aws_eip" "pritunl" {
instance = aws_instance.pritunl.id
vpc = true
tags = merge(tomap({ "Name" = format("%s-%s", var.resource_name_prefix, "vpn") }), var.tags, )
}