File size: 4,386 Bytes
4112f82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Parameters": {
        "DomainName": {
            "Description": "FQDN of the domain for this directory",
            "Type": "String",
            "Default": "corp.example.com"
        },
        "SimpleADShortName": {
            "Description": "Netbios name of the domain for this directory",
            "Type": "String",
            "Default": "corp"
        },
        "CreateAlias": {
            "Description": "Only required for applications which need a URL to connect to the directory",
            "Type": "String",
            "AllowedValues": [
                "true",
                "false"
            ],
            "Default": "false"
        },
        "PrivateSubnet1": {
            "Description": "Subnet to be used for the Directoty",
            "Type": "List<AWS::EC2::Subnet::Id>"
        },
        "PrivateSubnet2": {
            "Description": "Subnet to be used for the Directoty",
            "Type": "List<AWS::EC2::Subnet::Id>"
        },
        "VPCID": {
            "Description": "The VPC the directory will be created in",
            "Type": "List<AWS::EC2::VPC::Id>"
        },
        "Size": {
            "Description": "Size of the Simple AD",
            "Type": "String",
            "AllowedValues": [
                "Small",
                "Large"
            ],
            "Default": "Small"
        }
    },
    "Conditions": {
        "Alias": {
            "Fn::Equals": [
                {
                    "Ref": "CreateAlias"
                },
                "true"
            ]
        }
    },
    "Resources": {
        "SimpleAD": {
            "Type": "AWS::DirectoryService::SimpleAD",
            "Properties": {
                "CreateAlias": false,
                "EnableSso": false,
                "Name": {
                    "Ref": "DomainName"
                },
                "Password": "{{resolve:secretsmanager:simple-ad-pw:SecretString:pasword}}",
                "ShortName": {
                    "Ref": "SimpleADShortName"
                },
                "Size": {
                    "Ref": "Size"
                },
                "VpcSettings": {
                    "SubnetIds": [
                        {
                            "Fn::Select": [
                                "0",
                                {
                                    "Ref": "PrivateSubnet1"
                                }
                            ]
                        },
                        {
                            "Fn::Select": [
                                "0",
                                {
                                    "Ref": "PrivateSubnet2"
                                }
                            ]
                        }
                    ],
                    "VpcId": {
                        "Fn::Select": [
                            "0",
                            {
                                "Ref": "VPCID"
                            }
                        ]
                    }
                }
            }
        }
    },
    "Outputs": {
        "DirectoryID": {
            "Description": "ID of the SimpleAD",
            "Value": {
                "Ref": "SimpleAD"
            }
        },
        "PrimaryDNS": {
            "Description": "DNS IPs of the SimpleAD",
            "Value": {
                "Fn::Select": [
                    0,
                    {
                        "Fn::GetAtt": [
                            "SimpleAD",
                            "DnsIpAddresses"
                        ]
                    }
                ]
            }
        },
        "SecondaryDNS": {
            "Description": "DNS IPs of the SimpleAD",
            "Value": {
                "Fn::Select": [
                    1,
                    {
                        "Fn::GetAtt": [
                            "SimpleAD",
                            "DnsIpAddresses"
                        ]
                    }
                ]
            }
        },
        "DirectoryAlias": {
            "Description": "URL for the alias",
            "Value": {
                "Fn::GetAtt": [
                    "SimpleAD",
                    "Alias"
                ]
            },
            "Condition": "Alias"
        }
    }
}