Skip to content

Commit

Permalink
update KV secrets to have content type & expiration dates compliant w…
Browse files Browse the repository at this point in the history
…ith BAPS360SecurityPolicy
  • Loading branch information
dayland committed Aug 19, 2024
1 parent a95d3de commit b847a15
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 32 deletions.
6 changes: 5 additions & 1 deletion infra/arm_templates/kv_secret/kv_secret.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
},
"expiration": {
"type": "string"
},
"contentType": {
"type": "string"
}
},
"resources": [
Expand All @@ -29,7 +32,8 @@
"attributes": {
"enabled": true,
"exp": "[parameters('expiration')]"
}
},
"contentType": "[parameters('contentType')]"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions infra/core/ai/bingSearch/bingSearch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ module "bing_search_key" {
alias = "bingkey"
tags = var.tags
kv_secret_expiration = var.kv_secret_expiration
contentType = "application/vnd.bag-StrongEncPasswordString"
}
1 change: 1 addition & 0 deletions infra/core/ai/cogServices/cogServices.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module "cog_service_key" {
alias = "aisvckey"
tags = var.tags
kv_secret_expiration = var.kv_secret_expiration
contentType = "application/vnd.bag-StrongEncPasswordString"
}

data "azurerm_subnet" "subnet" {
Expand Down
5 changes: 0 additions & 5 deletions infra/core/ai/docintelligence/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,4 @@ variable "subnet_name" {

variable "arm_template_schema_mgmt_api" {
type = string
}

variable "kv_secret_expiration" {
type = string
description = "The value for key vault secret expiration in seconds since 1970-01-01T00:00:00Z"
}
5 changes: 0 additions & 5 deletions infra/core/ai/openaiservices/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ variable "arm_template_schema_mgmt_api" {
type = string
}

variable "kv_secret_expiration" {
type = string
description = "The value for key vault secret expiration in seconds since 1970-01-01T00:00:00Z"
}

variable "logAnalyticsWorkspaceResourceId" {
type = string
}
5 changes: 0 additions & 5 deletions infra/core/db/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,4 @@ variable "subnet_name" {

variable "arm_template_schema_mgmt_api" {
type = string
}

variable "kv_secret_expiration" {
type = string
description = "The value for key vault secret expiration in seconds since 1970-01-01T00:00:00Z"
}
5 changes: 0 additions & 5 deletions infra/core/search/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,4 @@ variable "private_dns_zone_ids" {

variable "arm_template_schema_mgmt_api" {
type = string
}

variable "kv_secret_expiration" {
type = string
description = "The value for key vault secret expiration in seconds since 1970-01-01T00:00:00Z"
}
5 changes: 0 additions & 5 deletions infra/core/security/keyvault/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,4 @@ variable "azure_keyvault_domain" {

variable "arm_template_schema_mgmt_api" {
type = string
}

variable "kv_secret_expiration" {
type = string
description = "The value for key vault secret expiration in seconds since 1970-01-01T00:00:00Z"
}
1 change: 1 addition & 0 deletions infra/core/security/keyvaultSecret/keyvaultSecret.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ resource "azurerm_resource_group_template_deployment" "kv_secret" {
"value" = { value = "${var.secret_value}" },
"tags" = { value = var.tags },
"expiration" = { value = var.kv_secret_expiration },
"contentType" = { value = var.contentType },
})
template_content = data.template_file.workflow.template
# The filemd5 forces this to run when the file is changed
Expand Down
4 changes: 4 additions & 0 deletions infra/core/security/keyvaultSecret/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ variable "alias" {
variable "kv_secret_expiration" {
type = string
description = "The value for key vault secret expiration in seconds since 1970-01-01T00:00:00Z"
}

variable "contentType" {
type = string
}
1 change: 1 addition & 0 deletions infra/core/storage/storage-account.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ module "storage_connection_string" {
tags = var.tags
alias = "blobconnstring"
kv_secret_expiration = var.kv_secret_expiration
contentType = "application/vnd.ms-StorageConnectionString"
}

data "azurerm_subnet" "subnet" {
Expand Down
5 changes: 0 additions & 5 deletions infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ module "kvModule" {
depends_on = [ module.entraObjects, module.privateDnsZoneKeyVault[0] ]
azure_keyvault_domain = var.azure_keyvault_domain
arm_template_schema_mgmt_api = var.arm_template_schema_mgmt_api
kv_secret_expiration = var.kv_secret_expiration
}

module "enrichmentApp" {
Expand Down Expand Up @@ -505,7 +504,6 @@ module "openaiServices" {
private_dns_zone_ids = var.is_secure_mode ? [module.privateDnsZoneAzureOpenAi[0].privateDnsZoneResourceId] : null
arm_template_schema_mgmt_api = var.arm_template_schema_mgmt_api
key_vault_name = module.kvModule.keyVaultName
kv_secret_expiration = var.kv_secret_expiration
logAnalyticsWorkspaceResourceId = module.logging.logAnalyticsId

deployments = [
Expand Down Expand Up @@ -547,7 +545,6 @@ module "aiDocIntelligence" {
vnet_name = var.is_secure_mode ? module.network[0].vnet_name : null
private_dns_zone_ids = var.is_secure_mode ? [module.privateDnsZoneAzureAi[0].privateDnsZoneResourceId] : null
arm_template_schema_mgmt_api = var.arm_template_schema_mgmt_api
kv_secret_expiration = var.kv_secret_expiration
}

module "cognitiveServices" {
Expand Down Expand Up @@ -580,7 +577,6 @@ module "searchServices" {
private_dns_zone_ids = var.is_secure_mode ? [module.privateDnsZoneSearchService[0].privateDnsZoneResourceId] : null
arm_template_schema_mgmt_api = var.arm_template_schema_mgmt_api
key_vault_name = module.kvModule.keyVaultName
kv_secret_expiration = var.kv_secret_expiration
}

module "cosmosdb" {
Expand All @@ -597,7 +593,6 @@ module "cosmosdb" {
vnet_name = var.is_secure_mode ? module.network[0].vnet_name : null
private_dns_zone_ids = var.is_secure_mode ? [module.privateDnsZoneCosmosDb[0].privateDnsZoneResourceId] : null
arm_template_schema_mgmt_api = var.arm_template_schema_mgmt_api
kv_secret_expiration = var.kv_secret_expiration
}

module "acr"{
Expand Down
2 changes: 1 addition & 1 deletion scripts/environments/local.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export REQUIRE_WEBSITE_SECURITY_MEMBERSHIP=false # Required
# with Microsoft's recommended guardrails for Azure Key Vault policy. We have NOT included automatic secret rotation in this deployment. See
# https://learn.microsoft.com/en-us/azure/key-vault/keys/how-to-configure-key-rotation for more information on enabling cryptographic key auto-rotation.
# The following setting will set the secret expiration to the current day plus the number of days specified.
export SECRET_EXPIRATION_DAYS=120 # Required
export SECRET_EXPIRATION_DAYS=730 # Required

# Uncomment this if you want to avoid the "are you sure?" prompt when applying TF changes
# export SKIP_PLAN_CHECK=1
Expand Down

0 comments on commit b847a15

Please sign in to comment.