-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.tf
More file actions
65 lines (53 loc) · 1.58 KB
/
Copy pathmain.tf
File metadata and controls
65 lines (53 loc) · 1.58 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
provider "aws" {
region = var.aws_region
}
locals {
default_tags = merge(
var.aws_tags,
{
ManagedBy = "terraform"
Application = "strongdm"
}
)
user_data = templatefile("${path.module}/scripts/user_data.sh", {
ADMIN_TOKEN_SECRET_NAME = var.sdm_admin_token_secret_name,
AWS_REGION = var.aws_region,
ADMIN_TOKEN_SECRET_KEY = var.sdm_admin_token_secret_key,
SDM_APP_DOMAIN = var.sdm_app_domain,
SDM_NODE_NAME = var.sdm_node_name,
SDM_USE_INSTANCE_NAME = var.sdm_use_instance_name
})
}
data "aws_vpc" "vpc" {
id = var.aws_vpc_id
}
data "aws_subnet" "subnet" {
id = var.aws_subnet_id
}
data "aws_ami" "latest_gateway" {
most_recent = true
owners = ["522179138863"] # StrongDM's account ID
filter {
name = "name"
values = ["strongdm/gateway/*"]
}
}
resource "aws_instance" "gateway_ec2" {
ami = var.ami_id != "" ? var.ami_id : data.aws_ami.latest_gateway.id
instance_type = var.aws_instance_type
subnet_id = data.aws_subnet.subnet.id
vpc_security_group_ids = [var.aws_security_group_id]
associate_public_ip_address = var.associate_public_ip_address
user_data_base64 = base64encode(local.user_data)
tags = merge(local.default_tags, {
Name = var.sdm_gateway_instance_name
})
metadata_options {
http_tokens = "required"
http_endpoint = "enabled"
}
root_block_device {
encrypted = true
}
iam_instance_profile = var.aws_iam_instance_profile != "" ? var.aws_iam_instance_profile : null
}