Skip to content

Key vault IP Restriction for Cosmos apps #65

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

Merged
merged 4 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@

param principalId string = ''

// Allow public network access to Key Vault
param allowPublicNetworkAccess bool = true

// Allow all Azure services to bypass Key Vault network rules
param allowAzureServicesAccess bool = true

param networkAcls object = {
bypass: allowAzureServicesAccess ? 'AzureServices' : 'None'
defaultAction: allowPublicNetworkAccess ? 'Allow' : 'Deny'
ipRules: []
virtualNetworkRules: []
}

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
name: name
location: location
tags: tags
properties: {
tenantId: subscription().tenantId
sku: { family: 'A', name: 'standard' }
networkAcls: networkAcls
accessPolicies: !empty(principalId) ? [
{
objectId: principalId
Expand Down
9 changes: 9 additions & 0 deletions {{cookiecutter.__src_folder_name}}/infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ var resourceToken = toLower(uniqueString(subscription().id, name, location))
var prefix = '${name}-${resourceToken}'
var tags = { 'azd-env-name': name }

var allowAzureServicesAccess = true
var defaultAction = false


resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: '${name}-rg'
location: location
Expand All @@ -47,6 +51,11 @@ module keyVault './core/security/keyvault.bicep' = {
location: location
tags: tags
principalId: principalId
allowPublicNetworkAccess: false
networkAcls: {
allowAzureServicesAccess: allowAzureServicesAccess
defaultAction: defaultAction
}
}
}

Expand Down
Loading