Skip to content

Commit

Permalink
Merge pull request #94 from lorengordon/ad-connector
Browse files Browse the repository at this point in the history
  • Loading branch information
lorengordon authored Mar 25, 2021
2 parents 338b4b5 + b1a519a commit 29807d5
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.0
current_version = 2.1.0
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
.tardigrade-ci
tardigrade-ci/

# eclint
.git/

# terratest
tests/go.*

# terraform lock file
.terraform.lock.hcl
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### 2.1.0

**Released**: 2021.03.24

**Commit Delta**: [Change from 2.0.0 release](https://github.com/plus3it/terraform-aws-tardigrade-directory-service/compare/2.0.0...2.1.0)

**Summary**:

* Enables support for AD Connector.

### 2.0.0

**Released**: 2020.10.19

**Commit Delta**: [Change from 1.1.0 release](https://github.com/plus3it/terraform-aws-tardigrade-directory-service/compare/1.1.0...2.0.0)

**Summary**:

* Removes module-wide "create" variable. Use module-level for_each with Terraform
0.13 to disable the module.

### 1.1.0

**Released**: 2020.04.17
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ Terraform module to create a directory
|------|-------------|------|---------|:--------:|
| name | The fully qualified name for the directory, such as corp.example.com | `string` | n/a | yes |
| password | The password for the directory administrator or connector user | `string` | n/a | yes |
| subnet\_ids | The identifiers of the subnets for the directory servers (2 subnets in 2 different AZs) | `list(string)` | n/a | yes |
| vpc\_id | The identifier of the VPC that the directory is in | `string` | n/a | yes |
| subnet\_ids | Subnet IDs for the directory servers/connectors (2 subnets in 2 different AZs) | `list(string)` | n/a | yes |
| alias | The alias for the directory, unique amongst all aliases in AWS (required for enable\_sso) | `string` | `null` | no |
| connect\_settings | Connector related information about the directory (required for ADConnector) | `list(string)` | `[]` | no |
| connect\_settings | Connector related information about the directory (required for ADConnector) | <pre>object({<br> # The username corresponding to the password provided.<br> customer_username = string<br> # The DNS IP addresses of the domain to connect to.<br> customer_dns_ips = list(string)<br> })</pre> | `null` | no |
| description | A textual description for the directory | `string` | `null` | no |
| edition | (Required for the MicrosoftAD type only) The MicrosoftAD edition (Standard or Enterprise). | `string` | `null` | no |
| enable\_sso | Whether to enable single-sign on for the directory (requires alias) | `bool` | `false` | no |
Expand Down
22 changes: 13 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resource "aws_directory_service_directory" "this" {

name = var.name
short_name = var.short_name
password = var.password
Expand All @@ -9,22 +8,27 @@ resource "aws_directory_service_directory" "this" {
description = var.description
enable_sso = var.enable_sso
edition = var.edition
tags = var.tags

vpc_settings {
vpc_id = var.vpc_id
subnet_ids = var.subnet_ids
dynamic "vpc_settings" {
for_each = var.type != "ADConnector" ? ["1"] : []
content {
subnet_ids = var.subnet_ids
vpc_id = data.aws_subnet.this.vpc_id
}
}

dynamic "connect_settings" {
for_each = var.connect_settings
for_each = var.type == "ADConnector" ? [var.connect_settings] : []
content {
customer_dns_ips = connect_settings.value.customer_dns_ips
customer_username = connect_settings.value.customer_username
subnet_ids = connect_settings.value.subnet_ids
vpc_id = connect_settings.value.vpc_id
subnet_ids = var.subnet_ids
vpc_id = data.aws_subnet.this.vpc_id
}
}

tags = var.tags
}

data "aws_subnet" "this" {
id = var.subnet_ids[0]
}
60 changes: 60 additions & 0 deletions tests/ad_connector/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
provider "aws" {
region = "us-east-1"
}

module "ad_connector" {
source = "../../"

name = "corp.${random_string.domain.result}.com"
password = random_string.password.result
size = "Small"
subnet_ids = module.vpc.private_subnets
type = "ADConnector"

connect_settings = {
customer_username = "Administrator"
customer_dns_ips = module.directory_service.dns_ip_addresses
}

tags = {
Name = "tardigrade-test-directory-service-${random_string.domain.result}"
}
}

module "directory_service" {
source = "../../"

name = "corp.${random_string.domain.result}.com"
password = random_string.password.result
size = "Small"
subnet_ids = module.vpc.private_subnets
type = "SimpleAD"

tags = {
Name = "tardigrade-test-directory-service-${random_string.domain.result}"
}
}

module "vpc" {
source = "git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git?ref=v2.77.0"

name = "tardigrade-test-directory-service-${random_string.domain.result}"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
}

resource "random_string" "password" {
length = 10
min_upper = 1
min_lower = 1
min_numeric = 1
min_special = 1
}

resource "random_string" "domain" {
length = 10
upper = false
number = false
special = false
}
16 changes: 6 additions & 10 deletions tests/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ resource "random_string" "domain" {
}

module "vpc" {
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0"
source = "git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git?ref=v2.77.0"

providers = {
aws = aws
}

name = "tardigrade-director-service-testing"
name = "tardigrade-test-directory-service-${random_string.domain.result}"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
}

module "directory_service" {
source = "../../"
providers = {
aws = aws
}

name = "corp.${random_string.domain.result}.com"
password = random_string.password.result
size = "Small"
subnet_ids = module.vpc.private_subnets
vpc_id = module.vpc.vpc_id

tags = {
Name = "tardigrade-test-directory-service-${random_string.domain.result}"
}
}
15 changes: 4 additions & 11 deletions tests/enable_sso/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,27 @@ resource "random_string" "domain" {
}

module "vpc" {
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0"
source = "git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git?ref=v2.77.0"

providers = {
aws = aws
}

name = "tardigrade-director-service-testing"
name = "tardigrade-test-directory-service-${random_string.domain.result}"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
}

module "directory_service" {
source = "../../"
providers = {
aws = aws
}

name = "corp.${random_string.domain.result}.com"
alias = random_string.alias.result
short_name = "CORP"
password = random_string.password.result
size = "Small"
subnet_ids = module.vpc.private_subnets
vpc_id = module.vpc.vpc_id
enable_sso = true
description = "A test of terraform creating a directory service"

tags = {
"environment" = "testing"
Name = "tardigrade-test-directory-service-${random_string.domain.result}"
}
}
16 changes: 6 additions & 10 deletions tests/microsoft_ad/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,24 @@ resource "random_string" "domain" {
}

module "vpc" {
source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v2.15.0"
source = "git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git?ref=v2.77.0"

providers = {
aws = aws
}

name = "tardigrade-directory-service-testing"
name = "tardigrade-test-directory-service-${random_string.domain.result}"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
}

module "directory_service" {
source = "../../"
providers = {
aws = aws
}

name = "corp.${random_string.domain.result}.com"
password = random_string.password.result
type = "MicrosoftAD"
edition = "Standard"
subnet_ids = module.vpc.private_subnets
vpc_id = module.vpc.vpc_id

tags = {
Name = "tardigrade-test-directory-service-${random_string.domain.result}"
}
}
26 changes: 18 additions & 8 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ variable "size" {
default = null
}

variable "vpc_id" {
description = "The identifier of the VPC that the directory is in"
type = string
}

variable "subnet_ids" {
description = "The identifiers of the subnets for the directory servers (2 subnets in 2 different AZs)"
description = "Subnet IDs for the directory servers/connectors (2 subnets in 2 different AZs)"
type = list(string)
}

variable "connect_settings" {
description = "Connector related information about the directory (required for ADConnector)"
type = list(string)
default = []
type = object({
# The username corresponding to the password provided.
customer_username = string
# The DNS IP addresses of the domain to connect to.
customer_dns_ips = list(string)
})
default = null
}

variable "alias" {
Expand Down Expand Up @@ -57,12 +57,22 @@ variable "type" {
description = "Either SimpleAD, ADConnector or MicrosoftAD"
type = string
default = "SimpleAD"

validation {
condition = contains(["SimpleAD", "ADConnector", "MicrosoftAD"], var.type)
error_message = "`type` must be one of: \"SimpleAD\", \"ADConnector\", \"MicrosoftAD\"."
}
}

variable "edition" {
description = "(Required for the MicrosoftAD type only) The MicrosoftAD edition (Standard or Enterprise)."
type = string
default = null

validation {
condition = var.edition != null ? contains(["Standard", "Enterprise"], var.edition) : true
error_message = "`type` must be one of: \"Standard\", \"Enterprise\"."
}
}

variable "tags" {
Expand Down

0 comments on commit 29807d5

Please sign in to comment.