-
Notifications
You must be signed in to change notification settings - Fork 1
/
directoryservice.tf
60 lines (51 loc) · 1.6 KB
/
directoryservice.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
48
49
50
51
52
53
54
55
56
57
58
59
resource "aws_directory_service_directory" "ad" {
name = var.domain_name
password = var.domain_admin_password
edition = var.directory_edition
type = var.directory_type
count = var.ad_enabled ? 1 : 0
vpc_settings {
vpc_id = aws_vpc.main.id
subnet_ids = [
aws_subnet.private_a.id,
aws_subnet.private_b.id,
]
}
tags = {
Name = "${upper(var.environment_name)}-Directory Service"
Env = var.environment_name
App = var.app_name
CUSTOMER = var.customer_tag
Terraform = true
}
}
resource "aws_ssm_document" "ad_join_doc" {
name = "ad_join_${var.app_name}-${var.environment_name}"
document_type = "Command"
count = var.ad_enabled ? 1 : 0
content = <<DOC
{
"schemaVersion": "1.0",
"description": "Join an instance to a domain",
"runtimeConfig": {
"aws:domainJoin": {
"properties": {
"directoryId": "${aws_directory_service_directory.ad[count.index].id}",
"directoryName": "${var.domain_name}",
"dnsIpAddresses": [
"${sort(aws_directory_service_directory.ad[count.index].dns_ip_addresses).0}",
"${sort(aws_directory_service_directory.ad[count.index].dns_ip_addresses).1}"
]
}
}
}
}
DOC
tags = {
Env = var.environment_name
App = var.app_name
CUSTOMER = var.customer_tag
Terraform = true
}
depends_on = [aws_directory_service_directory.ad]
}