|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +//============================================================================== |
| 5 | +// Parameters |
| 6 | +//============================================================================== |
| 7 | + |
| 8 | +@description('Required. Name of the publisher-specific Key Vault instance.') |
| 9 | +param vaultName string |
| 10 | + |
| 11 | +@description('Required. Name of the Key Vault secret to create or update.') |
| 12 | +param secretName string |
| 13 | + |
| 14 | +@description('Required. Value of the Key Vault secret.') |
| 15 | +@secure() |
| 16 | +param secretValue string |
| 17 | + |
| 18 | +@description('Optional. Value of the Key Vault secret expiration date (exp) property. This is represented as seconds since Jan 1, 1970.') |
| 19 | +param secretExpirationInSeconds int = -1 |
| 20 | + |
| 21 | +@description('Optional. Value of the Key Vault secret not before date (nbf) property. This is represented as seconds since Jan 1, 1970.') |
| 22 | +param secretNotBeforeInSeconds int = -1 |
| 23 | + |
| 24 | + |
| 25 | +//============================================================================== |
| 26 | +// Resources |
| 27 | +//============================================================================== |
| 28 | + |
| 29 | +resource vault 'Microsoft.KeyVault/vaults@2023-02-01' existing = { |
| 30 | + name: vaultName |
| 31 | + |
| 32 | + resource secret 'secrets' = { |
| 33 | + name: secretName |
| 34 | + properties: { |
| 35 | + attributes: union({ |
| 36 | + enabled: true |
| 37 | + }, secretExpirationInSeconds <= 0 ? {} : { |
| 38 | + exp: secretExpirationInSeconds |
| 39 | + }, secretNotBeforeInSeconds <= 0 ? {} : { |
| 40 | + nbf: secretNotBeforeInSeconds |
| 41 | + }) |
| 42 | + value: secretValue |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +//============================================================================== |
| 49 | +// Outputs |
| 50 | +//============================================================================== |
| 51 | + |
| 52 | +@description('Name of the Key Vault secret.') |
| 53 | +output secretName string = vault::secret.name |
0 commit comments