forked from Azure/deployment-environments
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
put keyvault fro shared aks to mongo part
- Loading branch information
Showing
14 changed files
with
172 additions
and
63 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
15 changes: 0 additions & 15 deletions
15
Environments/Todo-Mongo-AKS/core/database/cosmos/cosmos-connection-string.bicep
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
Environments/Todo-Mongo-AKS/core/security/aks-managed-cluster-access.bicep
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 @@ | ||
metadata description = 'Assigns RBAC role to the specified AKS cluster and principal.' | ||
param clusterName string | ||
param principalId string | ||
|
||
var aksClusterAdminRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b1ff04bb-8a4e-4dc4-8eb5-8693973ce19b') | ||
|
||
resource aksRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
scope: aksCluster // Use when specifying a scope that is different than the deployment scope | ||
name: guid(subscription().id, resourceGroup().id, principalId, aksClusterAdminRole) | ||
properties: { | ||
roleDefinitionId: aksClusterAdminRole | ||
principalType: 'User' | ||
principalId: principalId | ||
} | ||
} | ||
|
||
resource aksCluster 'Microsoft.ContainerService/managedClusters@2023-10-02-preview' existing = { | ||
name: clusterName | ||
} |
22 changes: 22 additions & 0 deletions
22
Environments/Todo-Mongo-AKS/core/security/keyvault-access.bicep
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,22 @@ | ||
metadata description = 'Assigns an Azure Key Vault access policy.' | ||
param name string = 'add' | ||
|
||
param keyVaultName string | ||
param permissions object = { secrets: [ 'get', 'list' ] } | ||
param principalId string | ||
|
||
resource keyVaultAccessPolicies 'Microsoft.KeyVault/vaults/accessPolicies@2022-07-01' = { | ||
parent: keyVault | ||
name: name | ||
properties: { | ||
accessPolicies: [ { | ||
objectId: principalId | ||
tenantId: subscription().tenantId | ||
permissions: permissions | ||
} ] | ||
} | ||
} | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | ||
name: keyVaultName | ||
} |
31 changes: 31 additions & 0 deletions
31
Environments/Todo-Mongo-AKS/core/security/keyvault-secret.bicep
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,31 @@ | ||
metadata description = 'Creates or updates a secret in an Azure Key Vault.' | ||
param name string | ||
param tags object = {} | ||
param keyVaultName string | ||
param contentType string = 'string' | ||
@description('The value of the secret. Provide only derived values like blob storage access, but do not hard code any secrets in your templates') | ||
@secure() | ||
param secretValue string | ||
|
||
param enabled bool = true | ||
param exp int = 0 | ||
param nbf int = 0 | ||
|
||
resource keyVaultSecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { | ||
name: name | ||
tags: tags | ||
parent: keyVault | ||
properties: { | ||
attributes: { | ||
enabled: enabled | ||
exp: exp | ||
nbf: nbf | ||
} | ||
contentType: contentType | ||
value: secretValue | ||
} | ||
} | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | ||
name: keyVaultName | ||
} |
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,26 @@ | ||
metadata description = 'Creates an Azure Key Vault.' | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param principalId string = '' | ||
|
||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { | ||
name: name | ||
location: location | ||
tags: tags | ||
properties: { | ||
tenantId: subscription().tenantId | ||
sku: { family: 'A', name: 'standard' } | ||
accessPolicies: !empty(principalId) ? [ | ||
{ | ||
objectId: principalId | ||
permissions: { secrets: [ 'get', 'list' ] } | ||
tenantId: subscription().tenantId | ||
} | ||
] : [] | ||
} | ||
} | ||
|
||
output endpoint string = keyVault.properties.vaultUri | ||
output name string = keyVault.name |
19 changes: 19 additions & 0 deletions
19
Environments/Todo-Mongo-AKS/core/security/registry-access.bicep
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 @@ | ||
metadata description = 'Assigns ACR Pull permissions to access an Azure Container Registry.' | ||
param containerRegistryName string | ||
param principalId string | ||
|
||
var acrPullRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d') | ||
|
||
resource aksAcrPull 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
scope: containerRegistry // Use when specifying a scope that is different than the deployment scope | ||
name: guid(subscription().id, resourceGroup().id, principalId, acrPullRole) | ||
properties: { | ||
roleDefinitionId: acrPullRole | ||
principalType: 'ServicePrincipal' | ||
principalId: principalId | ||
} | ||
} | ||
|
||
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' existing = { | ||
name: containerRegistryName | ||
} |
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,21 @@ | ||
metadata description = 'Creates a role assignment for a service principal.' | ||
param principalId string | ||
|
||
@allowed([ | ||
'Device' | ||
'ForeignGroup' | ||
'Group' | ||
'ServicePrincipal' | ||
'User' | ||
]) | ||
param principalType string = 'ServicePrincipal' | ||
param roleDefinitionId string | ||
|
||
resource role 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid(subscription().id, resourceGroup().id, principalId, roleDefinitionId) | ||
properties: { | ||
principalId: principalId | ||
principalType: principalType | ||
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId) | ||
} | ||
} |
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