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

Add support for CMK options in workflows #4249

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
15 changes: 15 additions & 0 deletions .github/actions/devcontainer_run_command/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ inputs:
description: "Application Gateway SKU"
required: false
default: ""
ENABLE_CMK_ENCRYPTION:
description: "A boolean indicating if we should enable CMK on supported resources"
required: false
default: "false"
ENCRYPTION_KV_NAME:
description: ""
required: false
default: "The name of the keyvault that will be created for CMK"
EXTERNAL_KEY_STORE_ID:
description: "The Azure Resource ID for an external key store to use for CMK"
required: false
default: ""

runs:
using: composite
Expand Down Expand Up @@ -244,6 +256,9 @@ runs:
&& inputs.RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE) || 5 }}" \
-e TF_VAR_firewall_sku=${{ inputs.FIREWALL_SKU }} \
-e TF_VAR_app_gateway_sku=${{ inputs.APP_GATEWAY_SKU }} \
-e TF_VAR_enable_cmk_encryption="${{ inputs.ENABLE_CMK_ENCRYPTION }}" \
-e TF_VAR_encryption_kv_name="${{ inputs.ENCRYPTION_KV_NAME }}" \
-e TF_VAR_external_key_store_id="${{ inputs.EXTERNAL_KEY_STORE_ID }}" \
-e E2E_TESTS_NUMBER_PROCESSES="${{ inputs.E2E_TESTS_NUMBER_PROCESSES }}" \
'${{ inputs.CI_CACHE_ACR_NAME }}${{ env.ACR_DOMAIN_SUFFIX }}/tredev:${{ inputs.DEVCONTAINER_TAG }}' \
bash -c "${{ inputs.COMMAND }}"
5 changes: 5 additions & 0 deletions .github/workflows/build_validation_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ jobs:
terraform_workspace_services:
- templates/workspace_services/**/terraform/**/*.tf

- uses: hashicorp/setup-terraform@v3
if: ${{ steps.filter.outputs.terraform == 'true' }}
with:
terraform_version: "1.9.8"

- name: Terraform format check
if: ${{ steps.filter.outputs.terraform == 'true' }}
run: terraform fmt -check -recursive
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ concurrency:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy_tre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ jobs:
TEST_ACCOUNT_CLIENT_SECRET: "${{ secrets.TEST_ACCOUNT_CLIENT_SECRET }}"
TRE_ID: ${{ secrets.TRE_ID }}
CI_CACHE_ACR_NAME: ${{ secrets.ACR_NAME }}
ENCRYPTION_KV_NAME: ${{ secrets.ENCRYPTION_KV_NAME }}
EXTERNAL_KEY_STORE_ID: ${{ secrets.EXTERNAL_KEY_STORE_ID }}
2 changes: 2 additions & 0 deletions .github/workflows/deploy_tre_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ jobs:
TEST_ACCOUNT_CLIENT_SECRET: "${{ secrets.TEST_ACCOUNT_CLIENT_SECRET }}"
TRE_ID: ${{ format('tre{0}', needs.prepare-not-main.outputs.refid) }}
CI_CACHE_ACR_NAME: ${{ secrets.ACR_NAME }}
ENCRYPTION_KV_NAME: ${{ format('tre{0}mgmt', needs.prepare-not-main.outputs.refid) }}
EXTERNAL_KEY_STORE_ID: ${{ secrets.EXTERNAL_KEY_STORE_ID }}
12 changes: 12 additions & 0 deletions .github/workflows/deploy_tre_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ on: # yamllint disable-line rule:truthy
AZURE_CREDENTIALS:
description: ""
required: true
ENCRYPTION_KV_NAME:
description: ""
required: false
EXTERNAL_KEY_STORE_ID:
description: ""
required: false

# This will prevent multiple runs of this entire workflow.
# We should NOT cancel in progress runs as that can destabilize the environment.
Expand Down Expand Up @@ -246,6 +252,9 @@ jobs:
TERRAFORM_STATE_CONTAINER_NAME: ${{ vars.TERRAFORM_STATE_CONTAINER_NAME }}
MGMT_RESOURCE_GROUP_NAME: ${{ secrets.MGMT_RESOURCE_GROUP_NAME }}
MGMT_STORAGE_ACCOUNT_NAME: ${{ secrets.MGMT_STORAGE_ACCOUNT_NAME }}
ENABLE_CMK_ENCRYPTION: ${{ vars.ENABLE_CMK_ENCRYPTION }}
ENCRYPTION_KV_NAME: ${{ secrets.ENCRYPTION_KV_NAME }}
EXTERNAL_KEY_STORE_ID: ${{ secrets.EXTERNAL_KEY_STORE_ID }}

- name: ACR Login
# failure in the first attempt indicates a new ACR, so we need to try again after it's been created
Expand Down Expand Up @@ -359,6 +368,9 @@ jobs:
RP_BUNDLE_VALUES: ${{ vars.RP_BUNDLE_VALUES }}
FIREWALL_SKU: ${{ vars.FIREWALL_SKU}}
APP_GATEWAY_SKU: ${{ vars.APP_GATEWAY_SKU }}
ENABLE_CMK_ENCRYPTION: ${{ vars.ENABLE_CMK_ENCRYPTION }}
ENCRYPTION_KV_NAME: ${{ secrets.ENCRYPTION_KV_NAME }}
EXTERNAL_KEY_STORE_ID: ${{ secrets.EXTERNAL_KEY_STORE_ID }}

- name: API Healthcheck
uses: ./.github/actions/devcontainer_run_command
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_comment_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,4 @@ jobs:
TEST_ACCOUNT_CLIENT_SECRET: "${{ secrets.TEST_ACCOUNT_CLIENT_SECRET }}"
TRE_ID: ${{ format('tre{0}', needs.pr_comment.outputs.prRefId) }}
CI_CACHE_ACR_NAME: ${{ secrets.ACR_NAME }}
ENCRYPTION_KV_NAME: ${{ format('tre{0}mgmt', needs.pr_comment.outputs.prRefId) }}
12 changes: 12 additions & 0 deletions config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
"description": "The Azure subscription ID for all resources.",
"type": "string",
"pattern": "^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$"
},
"encryption_kv_name": {
"description": "Name of Key Vault for encryption keys.",
"type": "string"
},
"external_key_store_id": {
"description": "ID of external Key Vault to store CMKs.",
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -96,6 +104,10 @@
"custom_domain": {
"description": "Custom domain name.",
"type": "string"
},
"enable_cmk_encryption": {
"description": "Enables customer-managed key encryption for all supported resources.",
"type": "boolean"
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions core/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ variable "enable_cmk_encryption" {
type = bool
description = "A boolean indicating if customer managed keys will be used for encryption of supporting resources"
default = false

validation {
condition = var.enable_cmk_encryption == false || (var.enable_cmk_encryption == true && (
(try(length(var.external_key_store_id), 0) > 0 && try(length(var.encryption_kv_name), 0) == 0) ||
(try(length(var.external_key_store_id), 0) == 0 && try(length(var.encryption_kv_name), 0) > 0)
))
error_message = "Exactly one of 'external_key_store_id' or 'encryption_kv_name' must be non-empty when enable_cmk_encryption is true."
}
}

variable "external_key_store_id" {
Expand Down
2 changes: 1 addition & 1 deletion core/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.15"
__version__ = "0.11.16"
8 changes: 8 additions & 0 deletions devops/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ variable "enable_cmk_encryption" {
type = bool
description = "A boolean indicating if customer managed keys will be used for encryption of supporting resources"
default = false

validation {
condition = var.enable_cmk_encryption == false || (var.enable_cmk_encryption == true && (
(try(length(var.external_key_store_id), 0) > 0 && try(length(var.encryption_kv_name), 0) == 0) ||
(try(length(var.external_key_store_id), 0) == 0 && try(length(var.encryption_kv_name), 0) > 0)
))
error_message = "Exactly one of 'external_key_store_id' or 'encryption_kv_name' must be non-empty when enable_cmk_encryption is true."
}
}

variable "external_key_store_id" {
Expand Down
2 changes: 1 addition & 1 deletion devops/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.5"
__version__ = "0.5.6"
4 changes: 3 additions & 1 deletion docs/tre-admins/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
| `FIREWALL_SKU` | Optional. The SKU of the Azure Firewall instance. Default value is `Standard`. Allowed values [`Basic`, `Standard`, `Premium`]. See [Azure Firewall SKU feature comparison](https://learn.microsoft.com/en-us/azure/firewall/choose-firewall-sku). |
| `APP_GATEWAY_SKU` | Optional. The SKU of the Application Gateway. Default value is `Standard_v2`. Allowed values [`Standard_v2`, `WAF_v2`] |
| `CUSTOM_DOMAIN` | Optional. Custom domain name to access the Azure TRE portal. See [Custom domain name](custom-domain.md). |
| `ENABLE_CMK_ENCRYPTION` | If set to `true`, customer-managed key encryption will be enabled for all supported resources. |
| `ENABLE_CMK_ENCRYPTION` | Optional. Default is `false`, if set to `true` customer-managed key encryption will be enabled for all supported resources. |

## For authentication in `/config.yaml`

| Variable | Description |
Expand All @@ -60,6 +61,7 @@
| `WORKSPACE_API_CLIENT_SECRET` | Each workspace is secured behind it's own AD Application. This is the secret for that application.|

## For CI/CD pipelines in github environment secrets

| Variable | Description |
| -------- | ----------- |
| `AZURE_CREDENTIALS`| Credentials used to authorize CI/CD workflows to provision resources for the TRE workspaces and workspace services. This is basically your ARM client credentials in json format. Read more about how to create it and its format [here](./setup-instructions/workflows.md##create-a-service principal-for-provisioning-resources)|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Configure the following secrets in your github environment:
| `MGMT_RESOURCE_GROUP_NAME` | The name of the shared resource group for all Azure TRE core resources. |
| `MGMT_STORAGE_ACCOUNT_NAME` | The name of the storage account to hold the Terraform state and other deployment artifacts. E.g. `mystorageaccount`. |
| `ACR_NAME` | A globally unique name for the Azure Container Registry (ACR) that will be created to store deployment images. |
| `EXTERNAL_KEY_STORE_ID` | Optional. The ID of the external Key Vault to store CMKs in. Should not be set if `ENCRYPTION_KV_NAME` is set and only required if `ENABLE_CMK_ENCRYPTION` is true. |
| `ENCRYPTION_KV_NAME` | Optional. The name of the Key Vault for encryption keys. Should not be set if `EXTERNAL_KEY_STORE_ID` is set and only required if `ENABLE_CMK_ENCRYPTION` is true. |


### Configure Core Variables
Expand All @@ -86,6 +88,7 @@ Configure the following **variables** in your github environment:
| `FIREWALL_SKU` | Optional. The SKU of the Azure Firewall instance. Default value is `Standard`. Allowed values [`Basic`, `Standard`, `Premium`]. See [Azure Firewall SKU feature comparison](https://learn.microsoft.com/en-us/azure/firewall/choose-firewall-sku). |
| `APP_GATEWAY_SKU` | Optional. The SKU of the Application Gateway. Default value is `Standard_v2`. Allowed values [`Standard_v2`, `WAF_v2`] |
| `CUSTOM_DOMAIN` | Optional. Custom domain name to access the Azure TRE portal. See [Custom domain name](../custom-domain.md). |
| `ENABLE_CMK_ENCRYPTION` | Optional. Default is `false`, if set to `true` customer-managed key encryption will be enabled for all supported resources. |

### Configure Authentication Secrets

Expand Down
2 changes: 1 addition & 1 deletion docs/tre-admins/setup-instructions/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Configure variables used in the deployment workflow:
| `ENABLE_SWAGGER` | Optional. Determines whether the Swagger interface for the API will be available. Default value is `false`. |
| `FIREWALL_SKU` | Optional. The SKU of the Azure Firewall instance. Default value is `Standard`. Allowed values [`Basic`, `Standard`, `Premium`]. See [Azure Firewall SKU feature comparison](https://learn.microsoft.com/en-us/azure/firewall/choose-firewall-sku). |
| `APP_GATEWAY_SKU` | Optional. The SKU of the Application Gateway. Default value is `Standard_v2`. Allowed values [`Standard_v2`, `WAF_v2`] |

| `ENABLE_CMK_ENCRYPTION` | Optional. Default is `false`, if set to `true` customer-managed key encryption will be enabled for all supported resources. |

### Deploy the TRE using the workflow

Expand Down
Loading