Skip to content

Commit

Permalink
feat: Automation account credentials - New feature (Azure#2183)
Browse files Browse the repository at this point in the history
## Description

Fixes Azure#1443
## Pipeline Reference
| Pipeline |
| -------- |
|
[![avm.res.automation.automation-account](https://github.com/elanzel/bicep-registry-modules/actions/workflows/avm.res.automation.automation-account.yml/badge.svg?branch=feature%2Faut_credentials)](https://github.com/elanzel/bicep-registry-modules/actions/workflows/avm.res.automation.automation-account.yml)
|

## Type of Change

- [ ] Update to CI Environment or utlities (Non-module effecting
changes)
- [x] Azure Verified Module updates:
- [ ] Bugfix containing backwards compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [x] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings
  • Loading branch information
elanzel authored Jun 7, 2024
1 parent c798066 commit 3c5d867
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 91 deletions.
80 changes: 80 additions & 0 deletions avm/res/automation/automation-account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This module deploys an Azure Automation Account.
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |
| `Microsoft.Automation/automationAccounts` | [2022-08-08](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Automation/2022-08-08/automationAccounts) |
| `Microsoft.Automation/automationAccounts/credentials` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Automation/2023-11-01/automationAccounts/credentials) |
| `Microsoft.Automation/automationAccounts/jobSchedules` | [2022-08-08](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Automation/2022-08-08/automationAccounts/jobSchedules) |
| `Microsoft.Automation/automationAccounts/modules` | [2022-08-08](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Automation/2022-08-08/automationAccounts/modules) |
| `Microsoft.Automation/automationAccounts/runbooks` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Automation/2023-11-01/automationAccounts/runbooks) |
Expand Down Expand Up @@ -179,6 +180,19 @@ module automationAccount 'br/public:avm/res/automation/automation-account:<versi
// Required parameters
name: 'aamax001'
// Non-required parameters
credentials: [
{
description: 'Description of Credential01'
name: 'Credential01'
password: '<password>'
userName: 'userName01'
}
{
name: 'Credential02'
password: '<password>'
userName: 'username02'
}
]
diagnosticSettings: [
{
eventHubAuthorizationRuleResourceId: '<eventHubAuthorizationRuleResourceId>'
Expand Down Expand Up @@ -406,6 +420,21 @@ module automationAccount 'br/public:avm/res/automation/automation-account:<versi
"value": "aamax001"
},
// Non-required parameters
"credentials": {
"value": [
{
"description": "Description of Credential01",
"name": "Credential01",
"password": "<password>",
"userName": "userName01"
},
{
"name": "Credential02",
"password": "<password>",
"userName": "username02"
}
]
},
"diagnosticSettings": {
"value": [
{
Expand Down Expand Up @@ -1090,6 +1119,7 @@ module automationAccount 'br/public:avm/res/automation/automation-account:<versi

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`credentials`](#parameter-credentials) | array | List of credentials to be created in the automation account. |
| [`customerManagedKey`](#parameter-customermanagedkey) | object | The customer managed key definition. |
| [`diagnosticSettings`](#parameter-diagnosticsettings) | array | The diagnostic settings of the service. |
| [`disableLocalAuth`](#parameter-disablelocalauth) | bool | Disable local authentication profile used within the resource. |
Expand Down Expand Up @@ -1118,6 +1148,56 @@ Name of the Automation Account.
- Required: Yes
- Type: string

### Parameter: `credentials`

List of credentials to be created in the automation account.

- Required: No
- Type: array
- Default: `[]`

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-credentialsname) | string | Name of the Automation Account credential. |
| [`password`](#parameter-credentialspassword) | securestring | Password of the credential. |
| [`userName`](#parameter-credentialsusername) | string | The user name associated to the credential. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`description`](#parameter-credentialsdescription) | string | Description of the credential. |

### Parameter: `credentials.name`

Name of the Automation Account credential.

- Required: Yes
- Type: string

### Parameter: `credentials.password`

Password of the credential.

- Required: Yes
- Type: securestring

### Parameter: `credentials.userName`

The user name associated to the credential.

- Required: Yes
- Type: string

### Parameter: `credentials.description`

Description of the credential.

- Required: No
- Type: string

### Parameter: `customerManagedKey`

The customer managed key definition.
Expand Down
104 changes: 104 additions & 0 deletions avm/res/automation/automation-account/credential/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Automation Account Credential `[Microsoft.Automation/automationAccounts/credentials]`

This module deploys Azure Automation Account Credential.

## Navigation

- [Resource Types](#Resource-Types)
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)
- [Data Collection](#Data-Collection)

## Resource Types

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Automation/automationAccounts/credentials` | [2023-11-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Automation/2023-11-01/automationAccounts/credentials) |

## Parameters

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`credentials`](#parameter-credentials) | array | The credential definition. |

**Conditional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`automationAccountName`](#parameter-automationaccountname) | string | The name of the parent Automation Account. Required if the template is used in a standalone deployment. |

### Parameter: `credentials`

The credential definition.

- Required: Yes
- Type: array

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-credentialsname) | string | Name of the Automation Account credential. |
| [`password`](#parameter-credentialspassword) | securestring | Password of the credential. |
| [`userName`](#parameter-credentialsusername) | string | The user name associated to the credential. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`description`](#parameter-credentialsdescription) | string | Description of the credential. |

### Parameter: `credentials.name`

Name of the Automation Account credential.

- Required: Yes
- Type: string

### Parameter: `credentials.password`

Password of the credential.

- Required: Yes
- Type: securestring

### Parameter: `credentials.userName`

The user name associated to the credential.

- Required: Yes
- Type: string

### Parameter: `credentials.description`

Description of the credential.

- Required: No
- Type: string

### Parameter: `automationAccountName`

The name of the parent Automation Account. Required if the template is used in a standalone deployment.

- Required: Yes
- Type: string


## Outputs

| Output | Type | Description |
| :-- | :-- | :-- |
| `name` | array | The names of the credentials associated to the automation account. |
| `resourceGroupName` | string | The resource group of the deployed credential. |
| `resourceId` | array | The resource IDs of the credentials associated to the automation account. |

## Cross-referenced modules

_None_

## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the [repository](https://aka.ms/avm/telemetry). There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
56 changes: 56 additions & 0 deletions avm/res/automation/automation-account/credential/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
metadata name = 'Automation Account Credential'
metadata description = 'This module deploys Azure Automation Account Credential.'
metadata owner = 'Azure/module-maintainers'

@description('Conditional. The name of the parent Automation Account. Required if the template is used in a standalone deployment.')
param automationAccountName string

@description('Required. The credential definition.')
param credentials credentialType

resource automationAccount 'Microsoft.Automation/automationAccounts@2022-08-08' existing = {
name: automationAccountName
}

resource automationAccount_credential 'Microsoft.Automation/automationAccounts/credentials@2023-11-01' = [
for credential in credentials: {
name: credential.name
parent: automationAccount
properties: {
password: credential.password
userName: credential.userName
description: credential.?description ?? ''
}
}
]

@description('The resource IDs of the credentials associated to the automation account.')
#disable-next-line outputs-should-not-contain-secrets // Does not return the secret, but just the ID
output resourceId array = [for index in range(0, length(credentials)): automationAccount_credential[index].id]

@description('The names of the credentials associated to the automation account.')
#disable-next-line outputs-should-not-contain-secrets // Does not return the secret, but just the name
output name array = [for index in range(0, length(credentials)): automationAccount_credential[index].name]

@description('The resource group of the deployed credential.')
output resourceGroupName string = resourceGroup().name

// ================ //
// Definitions //
// ================ //

@export()
type credentialType = {
@description('Required. Name of the Automation Account credential.')
name: string

@description('Required. The user name associated to the credential.')
userName: string

@description('Required. Password of the credential.')
@secure()
password: string

@description('Optional. Description of the credential.')
description: string?
}[]
121 changes: 121 additions & 0 deletions avm/res/automation/automation-account/credential/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"languageVersion": "2.0",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "17311442241252857733"
},
"name": "Automation Account Credential",
"description": "This module deploys Azure Automation Account Credential.",
"owner": "Azure/module-maintainers"
},
"definitions": {
"credentialType": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"metadata": {
"description": "Required. Name of the Automation Account credential."
}
},
"userName": {
"type": "string",
"metadata": {
"description": "Required. The user name associated to the credential."
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "Required. Password of the credential."
}
},
"description": {
"type": "string",
"nullable": true,
"metadata": {
"description": "Optional. Description of the credential."
}
}
}
},
"metadata": {
"__bicep_export!": true
}
}
},
"parameters": {
"automationAccountName": {
"type": "string",
"metadata": {
"description": "Conditional. The name of the parent Automation Account. Required if the template is used in a standalone deployment."
}
},
"credentials": {
"$ref": "#/definitions/credentialType",
"metadata": {
"description": "Required. The credential definition."
}
}
},
"resources": {
"automationAccount": {
"existing": true,
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "2022-08-08",
"name": "[parameters('automationAccountName')]"
},
"automationAccount_credential": {
"copy": {
"name": "automationAccount_credential",
"count": "[length(parameters('credentials'))]"
},
"type": "Microsoft.Automation/automationAccounts/credentials",
"apiVersion": "2023-11-01",
"name": "[format('{0}/{1}', parameters('automationAccountName'), parameters('credentials')[copyIndex()].name)]",
"properties": {
"password": "[parameters('credentials')[copyIndex()].password]",
"userName": "[parameters('credentials')[copyIndex()].userName]",
"description": "[coalesce(tryGet(parameters('credentials')[copyIndex()], 'description'), '')]"
},
"dependsOn": [
"automationAccount"
]
}
},
"outputs": {
"resourceId": {
"type": "array",
"metadata": {
"description": "The resource IDs of the credentials associated to the automation account."
},
"copy": {
"count": "[length(range(0, length(parameters('credentials'))))]",
"input": "[resourceId('Microsoft.Automation/automationAccounts/credentials', parameters('automationAccountName'), parameters('credentials')[range(0, length(parameters('credentials')))[copyIndex()]].name)]"
}
},
"name": {
"type": "array",
"metadata": {
"description": "The names of the credentials associated to the automation account."
},
"copy": {
"count": "[length(range(0, length(parameters('credentials'))))]",
"input": "[parameters('credentials')[range(0, length(parameters('credentials')))[copyIndex()]].name]"
}
},
"resourceGroupName": {
"type": "string",
"metadata": {
"description": "The resource group of the deployed credential."
},
"value": "[resourceGroup().name]"
}
}
}
Loading

0 comments on commit 3c5d867

Please sign in to comment.