-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ER: Azure - Key Vault with SSL certificate * ER: App Service Custom Domain * ER: App Service SSL Certificate * ER: App Gateway * ER-704: Unit tests * ER-704: Key Vault exception --------- Co-authored-by: Sunny Sidhu <[email protected]>
- Loading branch information
1 parent
0c0f467
commit f857115
Showing
12 changed files
with
663 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# Create Key Vault | ||
data "azurerm_client_config" "az_config" {} | ||
|
||
resource "azurerm_key_vault" "kv" { | ||
# Key Vault only deployed to the Test and Production subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
name = "${var.resource_name_prefix}-kv" | ||
resource_group_name = var.resource_group | ||
location = var.location | ||
tenant_id = data.azurerm_client_config.az_config.tenant_id | ||
enabled_for_disk_encryption = true | ||
soft_delete_retention_days = 7 | ||
purge_protection_enabled = true | ||
sku_name = "standard" | ||
|
||
lifecycle { | ||
ignore_changes = [tags] | ||
} | ||
|
||
#checkov:skip=CKV_AZURE_109:Access Policies configured | ||
#checkov:skip=CKV_AZURE_189:Access Policies configured | ||
#checkov:skip=CKV2_AZURE_32:VNET configuration adequate | ||
} | ||
|
||
resource "azurerm_user_assigned_identity" "kv_mi" { | ||
# Key Vault only deployed to the Test and Production subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
name = "${var.resource_name_prefix}-agw-mi" | ||
location = var.location | ||
resource_group_name = var.resource_group | ||
} | ||
|
||
resource "azurerm_key_vault_access_policy" "kv_ap" { | ||
# Key Vault only deployed to the Test and Production subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
key_vault_id = azurerm_key_vault.kv[0].id | ||
tenant_id = data.azurerm_client_config.az_config.tenant_id | ||
object_id = data.azurerm_client_config.az_config.object_id | ||
|
||
secret_permissions = [ | ||
"Get" | ||
] | ||
|
||
certificate_permissions = [ | ||
"Create", | ||
"Get", | ||
"GetIssuers", | ||
"Import", | ||
"List", | ||
"ListIssuers", | ||
"ManageContacts", | ||
"ManageIssuers", | ||
"SetIssuers", | ||
"Update" | ||
] | ||
} | ||
|
||
resource "azurerm_key_vault_access_policy" "kv_mi_ap" { | ||
# Key Vault only deployed to the Test and Production subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
key_vault_id = azurerm_key_vault.kv[0].id | ||
tenant_id = data.azurerm_client_config.az_config.tenant_id | ||
object_id = azurerm_user_assigned_identity.kv_mi[0].principal_id | ||
|
||
secret_permissions = [ | ||
"Get" | ||
] | ||
|
||
certificate_permissions = [ | ||
"Get" | ||
] | ||
} | ||
|
||
resource "azurerm_key_vault_certificate_issuer" "kv_ca" { | ||
# Key Vault only deployed to the Test and Production subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
name = var.kv_certificate_authority_label | ||
key_vault_id = azurerm_key_vault.kv[0].id | ||
provider_name = var.kv_certificate_authority_name | ||
account_id = var.kv_certificate_authority_username | ||
password = var.kv_certificate_authority_password | ||
|
||
admin { | ||
email_address = var.kv_certificate_authority_admin_email | ||
first_name = var.kv_certificate_authority_admin_first_name | ||
last_name = var.kv_certificate_authority_admin_last_name | ||
phone = var.kv_certificate_authority_admin_phone_no | ||
} | ||
} | ||
|
||
resource "azurerm_key_vault_certificate" "kv_cert" { | ||
# Key Vault only deployed to the Test and Production subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
name = var.kv_certificate_label | ||
key_vault_id = azurerm_key_vault.kv[0].id | ||
|
||
certificate_policy { | ||
issuer_parameters { | ||
name = var.kv_certificate_authority_label | ||
} | ||
|
||
key_properties { | ||
exportable = true | ||
key_size = 2048 | ||
key_type = "RSA" | ||
reuse_key = true | ||
} | ||
|
||
lifetime_action { | ||
action { | ||
action_type = "AutoRenew" | ||
} | ||
|
||
trigger { | ||
days_before_expiry = 30 | ||
} | ||
} | ||
|
||
secret_properties { | ||
content_type = "application/x-pkcs12" | ||
} | ||
|
||
x509_certificate_properties { | ||
extended_key_usage = ["1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2"] | ||
key_usage = ["digitalSignature", "keyEncipherment"] | ||
subject = var.kv_certificate_subject | ||
validity_in_months = 12 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Create PIP for App Gateway | ||
resource "azurerm_public_ip" "agw_pip" { | ||
# Application Gateway is not deployed to the Development subscription | ||
count = var.environment != "development" ? 1 : 0 | ||
|
||
name = "${var.resource_name_prefix}-agw-pip" | ||
resource_group_name = var.resource_group | ||
location = var.location | ||
allocation_method = "Static" | ||
ip_version = "IPv4" | ||
sku = "Standard" | ||
sku_tier = "Regional" | ||
zones = [] | ||
idle_timeout_in_minutes = 4 | ||
|
||
lifecycle { | ||
ignore_changes = [tags] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.