Azure / terraform-azurerm-diskencrypt

Module to enable Azure Disk encryption with storing of keys in Azure KeyVault. Azure Disk Encryption (ADE) is a capability that helps you encrypt your Windows and Linux IaaS virtual machine disks. ADE leverages the industry standard BitLocker feature of Windows and the DM-Crypt feature of Linux to provide volume encryption for the OS and data disks. The solution is integrated with Azure Key Vault to help you control and manage the disk-encryption keys and secrets. The solution also ensures that all data on the virtual machine disks are encrypted at rest in your Azure storage.
MIT License
19 stars 24 forks source link

terraform-azurerm-diskencrypt

Build Status

Encrypt an existing Virtual Machine in Azure

This module implements Azure Disk Encryption feature to encrypt currently running VM's. ADE leverages the industry standard BitLocker feature of Windows and DM-Crypt feature of linux to provide volume encryption for the OS and data disks.

prerequisites

All the prerequsites can be found at the Azure Disk Encryption prerequisites

Setting the Advanced access policies for the Key Vault is required for this module to work.

Important Note We need to enable disk backup to encrypt managed data disks.

Usage


module "diskencrypt" {
  source               = "Azure/diskencrypt/azurerm"
  resource_group_name  = "myapp"
  location             = "westus"
  vm_name              = "ubuntu1"
  key_vault_name       = "testkeyvault123"
  encryption_algorithm = "RSA-OAEP"
  encryption_key_url   = "https://testkeyVault123.vault.azure.net:443/keys/ContosoFirstKey/9465333262aa49468c7f0dad5a167ee8"

  tags = {
    environment = "dev"
    costcenter  = "it"
  }
}

Test

Configurations

We provide 2 ways to build, run, and test the module on a local development machine. Native (Mac/Linux) or Docker.

Native (Mac/Linux)

Prerequisites

Environment setup

We provide simple script to quickly set up module development environment:

$ curl -sSL https://raw.githubusercontent.com/Azure/terramodtest/master/tool/env_setup.sh | sudo bash

Run test

Then simply run it in local shell:

$ cd $GOPATH/src/{directory_name}/
$ bundle install
$ rake build
$ rake e2e

Docker

We provide a Dockerfile to build a new image based FROM the microsoft/terraform-test Docker hub image which adds additional tools / packages specific for this module (see Custom Image section). Alternatively use only the microsoft/terraform-test Docker hub image by using these instructions.

Prerequisites

Custom Image

This builds the custom image:

$ docker build --build-arg BUILD_ARM_SUBSCRIPTION_ID=$ARM_SUBSCRIPTION_ID --build-arg BUILD_ARM_CLIENT_ID=$ARM_CLIENT_ID --build-arg BUILD_ARM_CLIENT_SECRET=$ARM_CLIENT_SECRET --build-arg BUILD_ARM_TENANT_ID=$ARM_TENANT_ID -t azure-diskencrypt .

This runs the build and unit tests:

$ docker run --rm azure-diskencrypt /bin/bash -c "bundle install && rake build"

This runs the end to end tests:

$ docker run --rm azure-diskencrypt /bin/bash -c "bundle install && rake e2e"

This runs the full tests:

$ docker run --rm azure-diskencrypt /bin/bash -c "bundle install && rake full"

Authors

Originally created by Vaijanath Angadihiremath

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.