Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk Encryption Set with CMK #296

Merged
merged 35 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b06c052
added disk_encyrption_set module
jorseng Feb 26, 2021
83311ac
update key access policy for encyrption set
jorseng Feb 26, 2021
ccff014
added disk encryption addition to vm module
jorseng Feb 26, 2021
784234f
pass disk_encryption_set local combined object to virtual_machines.tf
jorseng Feb 26, 2021
2bb9cd4
fixed vm modules to handle disk_encryption_set_id when disk_encryptio…
jorseng Mar 1, 2021
3d25e84
fix vm module on disk_encryption_set_id to correct attribute value.
jorseng Mar 3, 2021
f0f8749
added example configuration for disk encryption set
jorseng Mar 3, 2021
71c1a09
Fix disk-encryption-set
anamikanayal01 Mar 3, 2021
84fdc5b
Add standalone module for linux
anamikanayal01 Mar 3, 2021
2035f31
Merge branch 'js-encrypt-disk-cmk' of https://github.com/aztfmod/terr…
anamikanayal01 Mar 3, 2021
9cec49f
DES_Example-100 added standalone for linux vm
anamikanayal01 Mar 3, 2021
3e97448
Enabled VM MSI and reverted changes to vm_linux.tf and vm_windows.tf …
anamikanayal01 Mar 4, 2021
0a29e94
Added tag to KV map to test
anamikanayal01 Mar 4, 2021
7378739
added tags in akv block in example 105_Standalone winows vm
anamikanayal01 Mar 4, 2021
ee26474
updated keyvault_key module with the tags attribute- 105 windows VM
anamikanayal01 Mar 4, 2021
23ff587
added logged_in_app attribute value in access policy in config.tfvars
anamikanayal01 Mar 4, 2021
2d12dff
:added access policy in config.tfvars
anamikanayal01 Mar 4, 2021
a8ca0a0
DES creation with CMK-100-single-linux VM
anamikanayal01 Mar 8, 2021
4745ea5
DES with CMK- standalone-100- linux VM
anamikanayal01 Mar 8, 2021
6e3a203
DES with CMK- Standalone-105-windows vm
anamikanayal01 Mar 8, 2021
4ceb6fa
FMT
Mar 10, 2021
20fcb63
DES with CMK- Linux 100 & windows 105 example test
anamikanayal01 Mar 10, 2021
72d00bf
Merge branch 'js-encrypt-disk-cmk' of github.com:aztfmod/terraform-az…
anamikanayal01 Mar 10, 2021
d513520
Fix ci
LaurentLesle Mar 17, 2021
b6c99e3
Merge branch 'master' into js-encrypt-disk-cmk
LaurentLesle Mar 17, 2021
1465fd0
Merge remote-tracking branch 'origin/master' into js-encrypt-disk-cmk
LaurentLesle Mar 23, 2021
97d99ba
Fix Disk encryption set policy
LaurentLesle Mar 23, 2021
48cd81c
Merge branch 'master' into js-encrypt-disk-cmk
LaurentLesle Mar 24, 2021
b909540
Update standalone
LaurentLesle Mar 24, 2021
09b55b8
Update example
LaurentLesle Mar 24, 2021
eb5cfa2
Update example
LaurentLesle Mar 24, 2021
91eb00d
Fix CMK on storage account
LaurentLesle Mar 25, 2021
7dbc564
Merge branch 'master' into js-encrypt-disk-cmk
arnaudlh Mar 25, 2021
cb81b51
Fix for storage account without CMK
LaurentLesle Mar 25, 2021
7c0c09b
Merge branch 'master' into js-encrypt-disk-cmk
LaurentLesle Mar 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "cp -R /tmp/.ssh-localhost/* ~/.ssh && sudo chmod 600 ~/.ssh/* && sudo chown -R $(whoami) /tf/caf && git config --global core.editor vi && pre-commit install && pre-commit autoupdate",
"postCreateCommand": "sudo cp -R /tmp/.ssh-localhost/* ~/.ssh && sudo chmod 600 ~/.ssh/* && sudo chown -R $(whoami) /tf/caf && git config --global core.editor vi && pre-commit install && pre-commit autoupdate",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/master-100-tf13.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
"compute/virtual_machine/101-single-windows-vm",
"compute/virtual_machine/104-single-windows-backup",
"compute/virtual_machine/211-vm-bastion-winrm-agents",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-gremlin",
"cosmos_db/100-simple-cosmos-db-mongo",
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/master-100-tf14.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#
#
# Copyright (c) Microsoft Corporation
# Licensed under the MIT License.
#
Expand Down Expand Up @@ -91,6 +91,7 @@ jobs:
"compute/virtual_machine/101-single-windows-vm",
"compute/virtual_machine/104-single-windows-backup",
"compute/virtual_machine/211-vm-bastion-winrm-agents",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-gremlin",
"cosmos_db/100-simple-cosmos-db-mongo",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/master-100-tf15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
"compute/virtual_machine/101-single-windows-vm",
"compute/virtual_machine/104-single-windows-backup",
"compute/virtual_machine/211-vm-bastion-winrm-agents",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-gremlin",
"cosmos_db/100-simple-cosmos-db-mongo",
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/master-standalone-tf13.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
"compute/virtual_machine/104-single-windows-backup",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"compute/virtual_machine/211-vm-bastion-winrm-agents",
"compute/virtual_machine/210-vm-bastion-winrm",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-gremlin",
Expand Down Expand Up @@ -106,7 +107,7 @@ jobs:
"recovery_vault/103-asr-with-private-endpoint",
"redis_cache/100-redis-standard",
"storage_accounts/100-simple-storage-account-blob-container",
"storage_accounts/102-storage-account-advanced-options",
"storage_accounts/102-storage-account-advanced-options",
"synapse_analytics/100-synapse",
"synapse_analytics/101-synapse-sparkpool",
"webapps/appservice/101-appservice-simple",
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/master-standalone-tf14.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ jobs:
"compute/virtual_machine/102-single-vm-data-disks",
"compute/virtual_machine/104-single-windows-backup",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"compute/virtual_machine/210-vm-bastion-winrm",
"compute/virtual_machine/211-vm-bastion-winrm-agents",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-gremlin",
"cosmos_db/100-simple-cosmos-db-gremlin",
"cosmos_db/100-simple-cosmos-db-sql",
"cosmos_db/100-simple-cosmos-db-table",
"cosmos_db/100-simple-cosmos-db-table",
"databricks/100-simple-databricks",
"datalake/101-datalake-storage",
"eventhub/100-simple-eventhub-namespace",
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/master-standalone-tf15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ jobs:
"compute/kubernetes_services/101-single-cluster",
"compute/kubernetes_services/102-multi-nodepools",
"compute/proximity_placement_group",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"compute/virtual_machine/100-single-linux-vm",
"compute/virtual_machine/211-vm-bastion-winrm-agents",
"compute/virtual_machine/105-single-windows-vm-kv-admin-secrets",
"compute/virtual_machine/210-vm-bastion-winrm",
"cosmos_db/100-simple-cosmos-db-cassandra",
"cosmos_db/100-simple-cosmos-db-gremlin",
"cosmos_db/100-simple-cosmos-db-sql",
Expand Down
16 changes: 16 additions & 0 deletions disk_encryption_sets.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module "disk_encryption_sets" {
source = "./modules/security/disk_encryption_set"
for_each = local.security.disk_encryption_sets

global_settings = local.global_settings
client_config = local.client_config
settings = each.value
resource_groups = module.resource_groups
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
key_vault_key_ids = module.keyvault_keys
keyvault_id = local.combined_objects_keyvaults[try(each.value.keyvault.lz_key, local.client_config.landingzone_key)][each.value.keyvault.key].id
}

output disk_encryption_sets {
value = module.disk_encryption_sets
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ virtual_machines = {
size = "Standard_F2"
admin_username = "adminuser"
disable_password_authentication = true

#custom_data = "scripts/cloud-init/install-rover-tools.config"
custom_data = "../../examples/compute/virtual_machine/100-single-linux-vm/scripts/cloud-init/install-rover-tools.config"

# Spot VM to save money
Expand All @@ -56,11 +58,14 @@ virtual_machines = {
network_interface_keys = ["nic0"]

os_disk = {
name = "example_vm1-os"
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
name = "example_vm1-os"
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
disk_encryption_set_key = "set1"
}
identity = {
type = "SystemAssigned"
}

source_image_reference = {
publisher = "Canonical"
offer = "UbuntuServer"
Expand All @@ -70,7 +75,18 @@ virtual_machines = {

}
}

data_disks = {
data1 = {
name = "server1-data1"
storage_account_type = "Standard_LRS"
# Only Empty is supported. More community contributions required to cover other scenarios
create_option = "Empty"
disk_size_gb = "10"
lun = 1
zones = ["1"]
disk_encryption_set_key = "set1"
}
}
}
}

Expand All @@ -91,17 +107,44 @@ diagnostic_storage_accounts = {

keyvaults = {
example_vm_rg1 = {
name = "vmsecrets"
resource_group_key = "vm_region1"
sku_name = "standard"
name = "vmlinuxakv"
resource_group_key = "vm_region1"
sku_name = "standard"
soft_delete_enabled = true
purge_protection_enabled = true
enabled_for_disk_encryption = true
tags = {
env = "Standalone"
}
creation_policies = {
logged_in_user = {
secret_permissions = ["Set", "Get", "List", "Delete", "Purge", "Recover"]
key_permissions = ["Get", "List", "Update", "Create", "Import", "Delete", "Recover", "Backup", "Restore", "Decrypt", "Encrypt", "UnwrapKey", "WrapKey", "Verify", "Sign", "Purge"]
}
}
}
}

keyvault_keys = {
key1 = {
keyvault_key = "example_vm_rg1"
name = "disk-key"
key_type = "RSA"
key_size = "2048"
key_opts = ["encrypt", "decrypt", "sign", "verify", "wrapKey", "unwrapKey"]
}
}

disk_encryption_sets = {
set1 = {
name = "deskey1"
resource_group_key = "vm_region1"
key_vault_key_key = "key1"
keyvault = {
key = "example_vm_rg1"
}
}
}
vnets = {
vnet_region1 = {
resource_group_key = "vm_region1"
Expand Down
27 changes: 27 additions & 0 deletions examples/compute/virtual_machine/100-single-linux-vm/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
You can test this module outside of a landingzone using

```bash
configuration_folder=/tf/caf/examples/compute/virtual_machine/100-single-linux-vm
parameter_files=$(find ${configuration_folder} | grep .tfvars | sed 's/.*/-var-file &/' | xargs)

cd /tf/caf/landingzones/caf_example
terraform init
terraform [plan | apply | destroy ] \
-var-file ../configuration.tfvars


```

To test this deployment in the example landingzone. Make sure the launchpad has been deployed first

```bash

configuration_folder=/tf/caf/examples/compute/virtual_machine/100-single-linux-vm

rover \
-lz /tf/caf/landingzones/caf_example \
-var-folder ${configuration_folder} \
-level level1 \
-a [plan | apply | destroy ]

```
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@

global_settings = {
default_region = "region1"
prefix = null
regions = {
region1 = "southeastasia"
}
}
tags = {
level = "100"
}

resource_groups = {
vm_region1 = {
name = "example-virtual-machine-rg1"
tags = {
env = "standalone"
}
}
}

Expand All @@ -20,7 +25,7 @@ virtual_machines = {
example_vm1 = {
resource_group_key = "vm_region1"
provision_vm_agent = true
boot_diagnostics_storage_account_key = "bootdiag_region1"
boot_diagnostics_storage_account_key = "sa1"

os_type = "windows"

Expand All @@ -44,6 +49,7 @@ virtual_machines = {
windows = {
name = "example_vm2"
size = "Standard_F2"
zone = "1"

admin_username_key = "vmadmin-username"
admin_password_key = "vmadmin-password"
Expand All @@ -56,11 +62,18 @@ virtual_machines = {
network_interface_keys = ["nic0"]

os_disk = {
name = "example_vm1-os"
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
name = "example_vm1-os"
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
managed_disk_type = "StandardSSD_LRS"
disk_size_gb = "128"
create_option = "FromImage"
disk_encryption_set_key = "set1"
}

identity = {
type = "SystemAssigned"
}
source_image_reference = {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
Expand All @@ -70,7 +83,18 @@ virtual_machines = {

}
}

data_disks = {
data1 = {
name = "server1-data1"
storage_account_type = "Standard_LRS"
# Only Empty is supported. More community contributions required to cover other scenarios
create_option = "Empty"
disk_size_gb = "10"
lun = 1
zones = ["1"]
disk_encryption_set_key = "set1"
}
}
}
}

Expand All @@ -90,20 +114,23 @@ dynamic_keyvault_secrets = {

keyvaults = {
example_vm_rg1 = {
name = "vmsecrets"
resource_group_key = "vm_region1"
sku_name = "standard"

name = "vmsecretskv"
resource_group_key = "vm_region1"
sku_name = "standard"
soft_delete_enabled = true
purge_protection_enabled = true
enabled_for_disk_encryption = true
tags = {
env = "Standalone"
}
creation_policies = {
logged_in_user = {
certificate_permissions = ["Get", "List", "Update", "Create", "Import", "Delete", "Purge", "Recover"]
secret_permissions = ["Set", "Get", "List", "Delete", "Purge", "Recover"]
secret_permissions = ["Set", "Get", "List", "Delete", "Purge", "Recover"]
key_permissions = ["Get", "List", "Update", "Create", "Import", "Delete", "Recover", "Backup", "Restore", "Decrypt", "Encrypt", "UnwrapKey", "WrapKey", "Verify", "Sign", "Purge"]
}
}
}
}


vnets = {
vnet_region1 = {
resource_group_key = "vm_region1"
Expand Down Expand Up @@ -132,4 +159,53 @@ public_ip_addresses = {
idle_timeout_in_minutes = "4"

}
}

storage_accounts = {
sa1 = {
name = "sa1dev"
resource_group_key = "vm_region1"
# Account types are BlobStorage, BlockBlobStorage, FileStorage, Storage and StorageV2. Defaults to StorageV2
account_kind = "BlobStorage"
# Account Tier options are Standard and Premium. For BlockBlobStorage and FileStorage accounts only Premium is valid.
account_tier = "Standard"
# Valid options are LRS, GRS, RAGRS, ZRS, GZRS and RAGZRS
account_replication_type = "LRS" # https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy
min_tls_version = "TLS1_2"
allow_blob_public_access = true
tags = {
environment = "dev"
team = "IT"
##
}
enable_system_msi = {
type = "SystemAssigned"
}
containers = {
dev = {
name = "random"
}
}
}

}
keyvault_keys = {
key1 = {
keyvault_key = "example_vm_rg1"
name = "disk-key"
key_type = "RSA"
key_size = "2048"
key_opts = ["encrypt", "decrypt", "sign", "verify", "wrapKey", "unwrapKey"]
}
}

disk_encryption_sets = {
set1 = {
name = "deskey1"
resource_group_key = "vm_region1"
key_vault_key_key = "key1"
keyvault = {
key = "example_vm_rg1"
}
}
}
Loading