Sets up a MicrosoftAD directory with a VPC and two subnets in AWS.

Terraform Template

resource "aws_directory_service_directory" "bar" {
  edition = "Standard"
  name = "corp.notexample.com"
  password = "SuperSecretPassw0rd"

  tags = {
    Project = "foo"
  }
  type = "MicrosoftAD"

  vpc_settings {
    subnet_ids = [aws_subnet.foo.id, aws_subnet.bar.id]
    vpc_id = aws_vpc.main.id
  }
}

resource "aws_subnet" "bar" {
  availability_zone = "us-west-2b"
  cidr_block = "10.0.2.0/24"
  vpc_id = aws_vpc.main.id
}

resource "aws_subnet" "foo" {
  availability_zone = "us-west-2a"
  cidr_block = "10.0.1.0/24"
  vpc_id = aws_vpc.main.id
}

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}