-
Notifications
You must be signed in to change notification settings - Fork 387
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
feat: Update avm/res/event-hubs/namespace
-Add support for AKV secrets export
#4288
base: main
Are you sure you want to change the base?
Conversation
Important The "Needs: Triage 🔍" label must be removed once the triage process is complete! Tip For additional guidance on how to triage this issue/PR, see the BRM Issue Triage documentation. |
Important If this is a module-related PR, being submitted by the sole owner of the module, the AVM core team must review and approve it (as module owners can't approve their own PRs). To indicate this PR needs the core team''s attention, apply the "Needs: Core Team 🧞" label! The core team will only review and approve PRs that have this label applied! |
) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add the secrets output to the bottom of the list of current outputs:
import { secretsOutputType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
@description('A hashtable of references to the secrets exported to the provided Key Vault. The key of each reference is each secret\'s name.')
output exportedSecrets secretsOutputType = (secretsExportConfiguration != null)
? toObject(secretsExport.outputs.secretsSet, secret => last(split(secret.secretResourceId, '/')), secret => secret)
: {}
rootPrimaryConnectionString: string? | ||
|
||
@description('Optional. The rootSecondaryConnectionString secret name to create.') | ||
rootSecondaryConnectionString: string? | ||
|
||
@description('Optional. The rootPrimaryKey secret name to create.') | ||
rootPrimaryKey: string? | ||
|
||
@description('Optional. The rootSecondaryKey secret name to create.') | ||
rootSecondaryKey: string? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rootPrimaryConnectionString: string? | |
@description('Optional. The rootSecondaryConnectionString secret name to create.') | |
rootSecondaryConnectionString: string? | |
@description('Optional. The rootPrimaryKey secret name to create.') | |
rootPrimaryKey: string? | |
@description('Optional. The rootSecondaryKey secret name to create.') | |
rootSecondaryKey: string? | |
rootPrimaryConnectionStringName: string? | |
@description('Optional. The rootSecondaryConnectionString secret name to create.') | |
rootSecondaryConnectionStringName: string? | |
@description('Optional. The rootPrimaryKey secret name to create.') | |
rootPrimaryKeyName: string? | |
@description('Optional. The rootSecondaryKey secret name to create.') | |
rootSecondaryKeyName: string? |
contains(secretsExportConfiguration!, 'rootPrimaryConnectionString') | ||
? [ | ||
{ | ||
name: secretsExportConfiguration!.rootPrimaryConnectionString | ||
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryConnectionString | ||
} | ||
] | ||
: [], | ||
contains(secretsExportConfiguration!, 'rootSecondaryConnectionString') | ||
? [ | ||
{ | ||
name: secretsExportConfiguration!.rootSecondaryConnectionString | ||
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').secondaryConnectionString | ||
} | ||
] | ||
: [], | ||
contains(secretsExportConfiguration!, 'rootPrimaryKey') | ||
? [ | ||
{ | ||
name: secretsExportConfiguration!.rootPrimaryKey | ||
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryKey | ||
} | ||
] | ||
: [], | ||
contains(secretsExportConfiguration!, 'rootSecondaryKey') | ||
? [ | ||
{ | ||
name: secretsExportConfiguration!.rootSecondaryKey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contains(secretsExportConfiguration!, 'rootPrimaryConnectionString') | |
? [ | |
{ | |
name: secretsExportConfiguration!.rootPrimaryConnectionString | |
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryConnectionString | |
} | |
] | |
: [], | |
contains(secretsExportConfiguration!, 'rootSecondaryConnectionString') | |
? [ | |
{ | |
name: secretsExportConfiguration!.rootSecondaryConnectionString | |
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').secondaryConnectionString | |
} | |
] | |
: [], | |
contains(secretsExportConfiguration!, 'rootPrimaryKey') | |
? [ | |
{ | |
name: secretsExportConfiguration!.rootPrimaryKey | |
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryKey | |
} | |
] | |
: [], | |
contains(secretsExportConfiguration!, 'rootSecondaryKey') | |
? [ | |
{ | |
name: secretsExportConfiguration!.rootSecondaryKey | |
contains(secretsExportConfiguration!, 'rootPrimaryConnectionStringName') | |
? [ | |
{ | |
name: secretsExportConfiguration!.?rootPrimaryConnectionStringName | |
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryConnectionString | |
} | |
] | |
: [], | |
contains(secretsExportConfiguration!, 'rootSecondaryConnectionStringName') | |
? [ | |
{ | |
name: secretsExportConfiguration!.?rootSecondaryConnectionStringName | |
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').secondaryConnectionString | |
} | |
] | |
: [], | |
contains(secretsExportConfiguration!, 'rootPrimaryKeyName') | |
? [ | |
{ | |
name: secretsExportConfiguration!.?rootPrimaryKeyName | |
value: listkeys('${eventHubNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', '2024-01-01').primaryKey | |
} | |
] | |
: [], | |
contains(secretsExportConfiguration!, 'rootSecondaryKeyName') | |
? [ | |
{ | |
name: secretsExportConfiguration!.?rootSecondaryKeyName |
... to address a new Bicep warning (even try get technically should not be needed here)...
rootPrimaryKey: 'primaryKey-name' | ||
rootSecondaryKey: 'secondaryKey-name' | ||
rootPrimaryConnectionString: 'primaryConnectionString-name' | ||
rootSecondaryConnectionString: 'secondaryConnectionString-name' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rootPrimaryKey: 'primaryKey-name' | |
rootSecondaryKey: 'secondaryKey-name' | |
rootPrimaryConnectionString: 'primaryConnectionString-name' | |
rootSecondaryConnectionString: 'secondaryConnectionString-name' | |
rootPrimaryKeyName: 'primaryKey-name' | |
rootSecondaryKeyName: 'secondaryKey-name' | |
rootPrimaryConnectionStringName: 'primaryConnectionString-name' | |
rootSecondaryConnectionStringName: 'secondaryConnectionString-name' |
// ============== // | ||
// Parameters // | ||
// ============== // | ||
@description('Required. The name of the Key Vault to set the secrets in.') | ||
param keyVaultName string | ||
import { secretToSetType } from 'br/public:avm/utl/types/avm-common-types:0.4.1' | ||
@description('Required. The secrets to set in the Key Vault.') | ||
param secretsToSet secretToSetType[] | ||
// ============= // | ||
// Resources // | ||
// ============= // | ||
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | ||
name: keyVaultName | ||
} | ||
resource secrets 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = [ | ||
for secret in secretsToSet: { | ||
name: secret.name | ||
parent: keyVault | ||
properties: { | ||
value: secret.value | ||
} | ||
} | ||
] | ||
// =========== // | ||
// Outputs // | ||
// =========== // | ||
import { secretSetOutputType } from 'br/public:avm/utl/types/avm-common-types:0.4.1' | ||
@description('The references to the secrets exported to the provided Key Vault.') | ||
output secretsSet secretSetOutputType[] = [ | ||
#disable-next-line outputs-should-not-contain-secrets // Only returning the references, not a secret value | ||
for index in range(0, length(secretsToSet ?? [])): { | ||
secretResourceId: secrets[index].id | ||
secretUri: secrets[index].properties.secretUri | ||
secretUriWithVersion: secrets[index].properties.secretUriWithVersion | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ============== // | |
// Parameters // | |
// ============== // | |
@description('Required. The name of the Key Vault to set the secrets in.') | |
param keyVaultName string | |
import { secretToSetType } from 'br/public:avm/utl/types/avm-common-types:0.4.1' | |
@description('Required. The secrets to set in the Key Vault.') | |
param secretsToSet secretToSetType[] | |
// ============= // | |
// Resources // | |
// ============= // | |
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | |
name: keyVaultName | |
} | |
resource secrets 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = [ | |
for secret in secretsToSet: { | |
name: secret.name | |
parent: keyVault | |
properties: { | |
value: secret.value | |
} | |
} | |
] | |
// =========== // | |
// Outputs // | |
// =========== // | |
import { secretSetOutputType } from 'br/public:avm/utl/types/avm-common-types:0.4.1' | |
@description('The references to the secrets exported to the provided Key Vault.') | |
output secretsSet secretSetOutputType[] = [ | |
#disable-next-line outputs-should-not-contain-secrets // Only returning the references, not a secret value | |
for index in range(0, length(secretsToSet ?? [])): { | |
secretResourceId: secrets[index].id | |
secretUri: secrets[index].properties.secretUri | |
secretUriWithVersion: secrets[index].properties.secretUriWithVersion | |
} | |
] | |
@description('Required. The name of the Key Vault to set the secrets in.') | |
param keyVaultName string | |
import { secretToSetType } from 'br/public:avm/utl/types/avm-common-types:0.5.1' | |
@description('Required. The secrets to set in the Key Vault.') | |
param secretsToSet secretToSetType[] | |
resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { | |
name: keyVaultName | |
} | |
resource secrets 'Microsoft.KeyVault/vaults/secrets@2023-07-01' = [ | |
for secret in secretsToSet: { | |
name: secret.name | |
parent: keyVault | |
properties: { | |
value: secret.value | |
} | |
} | |
] | |
import { secretSetOutputType } from 'br/public:avm/utl/types/avm-common-types:0.5.1' | |
@description('The references to the secrets exported to the provided Key Vault.') | |
output secretsSet secretSetOutputType[] = [ | |
#disable-next-line outputs-should-not-contain-secrets // Only returning the references, not a secret value | |
for index in range(0, length(secretsToSet ?? [])): { | |
secretResourceId: secrets[index].id | |
secretUri: secrets[index].properties.secretUri | |
secretUriWithVersion: secrets[index].properties.secretUriWithVersion | |
} | |
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @weikanglim - content-wise nothing to complain about at all. The suggestions I added were all just minor details to align with the spec, address a very new bicep warning & format the export file 💪
Please note: After commiting the changes (which you can do via the GitHub UI) you'll have to re-run the Set-AVMModule --Path '(...)' Recurse
function to regenerate the readme & json files. Thank you
avm/res/event-hubs/namespace
-Add support for AKV secrets export
Description
Closes #3638
Pipeline Reference
Verified locally:
Type of Change
version.json
:version.json
.version.json
.Checklist
Set-AVMModule
locally to generate the supporting module files.