-
Notifications
You must be signed in to change notification settings - Fork 437
[Modules] Added CMK implementation to Container Instances module & fixed default ports parameter #1554
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
[Modules] Added CMK implementation to Container Instances module & fixed default ports parameter #1554
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e423421
Added first draft for CMK + minor fixes
AlexanderSehr db8a01d
Merge branch 'main' into users/alsehr/778_cmk
AlexanderSehr 08bace4
Disabled ports for testing
AlexanderSehr 6b0c30b
Disabled test file & pester
AlexanderSehr 7ea48fc
URL & port tests
AlexanderSehr b64a63d
Undid changes
AlexanderSehr 672185f
Updated docs
AlexanderSehr 7edcef2
Updated wiki
AlexanderSehr 25ad60c
Updated wiki
AlexanderSehr cc1f776
Update to latest
AlexanderSehr d6de3df
Removed redundant param
AlexanderSehr d527f87
Merged latest main
AlexanderSehr 98cd5d0
Minor change in prep
AlexanderSehr 50e409a
Updated versioning
AlexanderSehr f7a1a0c
Updated versioning
AlexanderSehr b244c17
Update to latest
AlexanderSehr cb129b0
Update to latest
AlexanderSehr 1b6acc1
Cleanup
AlexanderSehr 89c478c
Update to latest
AlexanderSehr 13e3a38
Update to latest
AlexanderSehr b6e85c3
Merged latest main
AlexanderSehr e10655e
Update to latest
AlexanderSehr 66822f2
Merge branch 'main' into users/alsehr/778_cmk
AlexanderSehr bc65357
cleanup
AlexanderSehr ff0f10e
Latest somehow working
AlexanderSehr 6ff9871
Updated docs
AlexanderSehr 7b18342
Update to latest
AlexanderSehr 4fe8e52
Merged with latest main
AlexanderSehr 41fd8aa
Push updated API Specs file
ffb7c03
Small fixes
AlexanderSehr 26b5a97
Merge branch 'main' into users/alsehr/778_cmk
AlexanderSehr 7ec486b
Push updated API Specs file
ebd7701
Update to latest
AlexanderSehr 3b8f916
Update to latest
AlexanderSehr cd104fb
Push updated API Specs file
5838142
Update docs/wiki/Getting started - Scenario 2 Onboard module library …
AlexanderSehr ebbe749
Update modules/Microsoft.ContainerInstance/containerGroups/.test/encr…
AlexanderSehr 6f06117
Update to latest
AlexanderSehr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
modules/Microsoft.ContainerInstance/containerGroups/.test/encr/dependencies.bicep
This file contains hidden or 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,61 @@ | ||
| @description('Required. The name of the managed identity to create.') | ||
| param managedIdentityName string | ||
|
|
||
| @description('Optional. The location to deploy resources to.') | ||
| param location string = resourceGroup().location | ||
|
|
||
| @description('Required. The name of the Key Vault to create.') | ||
| @minLength(3) | ||
| @maxLength(24) | ||
| param keyVaultName string | ||
|
|
||
| resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { | ||
| name: managedIdentityName | ||
| location: location | ||
| } | ||
|
|
||
| resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = { | ||
| name: keyVaultName | ||
| location: location | ||
| properties: { | ||
| sku: { | ||
| family: 'A' | ||
| name: 'standard' | ||
| } | ||
| tenantId: tenant().tenantId | ||
| enablePurgeProtection: true // Required by batch account | ||
| softDeleteRetentionInDays: 7 | ||
| enabledForTemplateDeployment: true | ||
| enabledForDiskEncryption: true | ||
| enabledForDeployment: true | ||
| enableRbacAuthorization: true | ||
| accessPolicies: [] | ||
| } | ||
|
|
||
| resource key 'keys@2022-07-01' = { | ||
| name: 'keyEncryptionKey' | ||
| properties: { | ||
| kty: 'RSA' | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Ref: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-encrypt-data#create-service-principal-for-aci | ||
| resource keyPermissions 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid('msi-${keyVault::key.id}-${location}-Azure Container Instance Service-Key Vault Crypto User') | ||
| scope: keyVault | ||
| properties: { | ||
| principalId: '8b659b68-1eb9-4ea5-ab00-a6a182520436' // Replace with your tenant 'Azure Container Instance Service' Service Principal Object Id | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'e147488a-f6f5-4113-8e2d-b22465e65bf6') // Key Vault Crypto Service Encryption User. Allows Keys: get, list, wrap key, unwrap key | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| @description('The resource ID of the created managed identity.') | ||
| output managedIdentityResourceId string = managedIdentity.id | ||
|
|
||
| @description('The resource ID of the created Key Vault.') | ||
| output keyVaultResourceId string = keyVault.id | ||
|
|
||
| @description('The name of the Key Vault Encryption Key.') | ||
| output keyVaultEncryptionKeyName string = keyVault::key.name | ||
117 changes: 117 additions & 0 deletions
117
modules/Microsoft.ContainerInstance/containerGroups/.test/encr/deploy.test.bicep
This file contains hidden or 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,117 @@ | ||
| targetScope = 'subscription' | ||
|
|
||
| // ========== // | ||
| // Parameters // | ||
| // ========== // | ||
| @description('Optional. The name of the resource group to deploy for testing purposes.') | ||
| @maxLength(90) | ||
| param resourceGroupName string = 'ms.containerinstance.containergroups-${serviceShort}-rg' | ||
|
|
||
| @description('Optional. The location to deploy resources to.') | ||
| param location string = deployment().location | ||
|
|
||
| @description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') | ||
| param serviceShort string = 'cicgecr' | ||
|
|
||
| @description('Generated. Used as a basis for unique resource names.') | ||
| param baseTime string = utcNow('u') | ||
|
|
||
| @description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).') | ||
| param enableDefaultTelemetry bool = true | ||
|
|
||
| // =========== // | ||
| // Deployments // | ||
| // =========== // | ||
|
|
||
| // General resources | ||
| // ================= | ||
| resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { | ||
| name: resourceGroupName | ||
| location: location | ||
| } | ||
|
|
||
| module resourceGroupResources 'dependencies.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name, location)}-paramNested' | ||
| params: { | ||
| managedIdentityName: 'dep-<<namePrefix>>-msi-${serviceShort}' | ||
| // Adding base time to make the name unique as purge protection must be enabled (but may not be longer than 24 characters total) | ||
| keyVaultName: 'dep-<<namePrefix>>-kv-${serviceShort}-${substring(uniqueString(baseTime), 0, 3)}' | ||
| } | ||
| } | ||
|
|
||
| // ============== // | ||
| // Test Execution // | ||
| // ============== // | ||
|
|
||
| module testDeployment '../../deploy.bicep' = { | ||
| scope: resourceGroup | ||
| name: '${uniqueString(deployment().name)}-test-${serviceShort}' | ||
| params: { | ||
| enableDefaultTelemetry: enableDefaultTelemetry | ||
| name: '<<namePrefix>>${serviceShort}001' | ||
| lock: 'CanNotDelete' | ||
| containers: [ | ||
| { | ||
| name: '<<namePrefix>>-az-aci-x-001' | ||
| properties: { | ||
| command: [] | ||
| environmentVariables: [] | ||
| image: 'mcr.microsoft.com/azuredocs/aci-helloworld' | ||
| ports: [ | ||
| { | ||
| port: '80' | ||
| protocol: 'Tcp' | ||
| } | ||
| { | ||
| port: '443' | ||
| protocol: 'Tcp' | ||
| } | ||
| ] | ||
| resources: { | ||
| requests: { | ||
| cpu: 2 | ||
| memoryInGB: 2 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| { | ||
| name: '<<namePrefix>>-az-aci-x-002' | ||
| properties: { | ||
| command: [] | ||
| environmentVariables: [] | ||
| image: 'mcr.microsoft.com/azuredocs/aci-helloworld' | ||
| ports: [ | ||
| { | ||
| port: '8080' | ||
| protocol: 'Tcp' | ||
| } | ||
| ] | ||
| resources: { | ||
| requests: { | ||
| cpu: 2 | ||
| memoryInGB: 2 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| ipAddressPorts: [ | ||
| { | ||
| protocol: 'Tcp' | ||
| port: 80 | ||
| } | ||
| { | ||
| protocol: 'Tcp' | ||
| port: 443 | ||
| } | ||
| ] | ||
| systemAssignedIdentity: true | ||
| userAssignedIdentities: { | ||
| '${resourceGroupResources.outputs.managedIdentityResourceId}': {} | ||
| } | ||
| cMKKeyName: resourceGroupResources.outputs.keyVaultEncryptionKeyName | ||
| cMKKeyVaultResourceId: resourceGroupResources.outputs.keyVaultResourceId | ||
| } | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.