Git Product home page Git Product logo

dq-tf-ad's Introduction

Active Directory Terraform Module

Provides an Active Directory in a dedicated VPC that you can then peer with and consume.

Features

  • Automatically comes up in all the availability zones in your given region
  • Requires bare minimum ceremony of configuration to use
  • Provides an Ad Writer IAM Role which can be assigned to your AD manager instances
  • Sets up DHCP options on supplied VPCs
  • Encrypt the AD password with KMS

Usage

module "ad" {
  source = "github.com/ukhomeoffice/dq-tf-ad"
  peer_with = [
    "${aws_vpc.YOURVPC1.id}",
    "${aws_vpc.YOURVPC2.id}"
  ]
  peer_count   = 2
  subnets      = [
  "${aws_subnet.YOUSSUBNET1.id}",
  "${aws_subnet.YOUSSUBNET2.id}",
  ]
  subnet_count = 2
  Domain = {
    address = "mydomain.com"
    directoryOU = "OU=mydomain,DC=mydomain,DC=com"
  }
}

resource "aws_instance" "ad_writer" {
#...
  iam_instance_profile = "${module.ad.ad_writer_instance_profile_name}"
#...
}

resource "aws_ssm_association" "win" {
  name        = "${module.ad.ad_aws_ssm_document_name}"
  instance_id = "${aws_instance.ad_writer.id}"
}

Or a more complete example

Joining instances

New windows instances can be simply assigned the iam_instance_profile and it'll 'just work'.

For existing or linux you should login to an AD Writer instance and make a user with delegated permissions to.

For implementation see the ec2 instances in the explorative demo that preceeded this module where I hacked some instances to auto join by provisioning them with some user_data. Be warned though, adding even a restriced AD account password here is a really bad idea.

Keeping the AD Admin password in KMS

echo -n 'Sup3rS3cret' > plaintext-password
aws kms encrypt \
 --key-id YOUR_KEY_ID \
 --plaintext fileb://plaintext-password \
 --encryption-context terraform=active_directory \
 --output text --query CiphertextBlob
AQECA......P8dPp28OoAQ==
data "aws_kms_secret" "ad_admin_password" {
  secret {
    name    = "pass"
    payload = "AQECA......P8dPp28OoAQ=="

    context {
      terraform = "active_directory"
    }
  }
}

module "ad" {
  AdminPassword = "${data.aws_kms_secret.ad_admin_password.pass}"
}

Related reading

This module is based off the explorative work done in the dq-tf-ad-demo repository.

Contributions

Pull requests welcome!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.