Skip to content

Commit

Permalink
feat: Adding support for Peer Encryption (#3068)
Browse files Browse the repository at this point in the history
## Description

Adds support for Peer Encryption

Fixes #3063 
Closes #3063 

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |

|[![avm.res.app.managed-environment](https://github.com/hundredacres/bicep-registry-modules/actions/workflows/avm.res.app.managed-environment.yml/badge.svg?branch=feat%2Fissues%2F3063)](https://github.com/hundredacres/bicep-registry-modules/actions/workflows/avm.res.app.managed-environment.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
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.
- [X] 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

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Máté Barabás <[email protected]>
Co-authored-by: Rainer Halanek <[email protected]>
Co-authored-by: JFolberth <[email protected]>
  • Loading branch information
4 people authored Aug 20, 2024
1 parent 9f790d1 commit a0781ab
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 12 deletions.
17 changes: 15 additions & 2 deletions avm/res/app/managed-environment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ This module deploys an App Managed Environment (also known as a Container App En

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.App/managedEnvironments` | [2023-11-02-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.App/2023-11-02-preview/managedEnvironments) |
| `Microsoft.App/managedEnvironments/storages` | [2023-11-02-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.App/2023-11-02-preview/managedEnvironments/storages) |
| `Microsoft.App/managedEnvironments` | [2024-02-02-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.App/2024-02-02-preview/managedEnvironments) |
| `Microsoft.App/managedEnvironments/storages` | [2024-02-02-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.App/2024-02-02-preview/managedEnvironments/storages) |
| `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) |

Expand Down Expand Up @@ -171,6 +171,7 @@ module managedEnvironment 'br/public:avm/res/app/managed-environment:<version>'
]
}
}
peerTrafficEncryption: true
platformReservedCidr: '172.17.17.0/24'
platformReservedDnsIP: '172.17.17.17'
roleAssignments: [
Expand Down Expand Up @@ -288,6 +289,9 @@ module managedEnvironment 'br/public:avm/res/app/managed-environment:<version>'
}
}
},
"peerTrafficEncryption": {
"value": true
},
"platformReservedCidr": {
"value": "172.17.17.0/24"
},
Expand Down Expand Up @@ -542,6 +546,7 @@ module managedEnvironment 'br/public:avm/res/app/managed-environment:<version>'
| [`logsDestination`](#parameter-logsdestination) | string | Logs destination. |
| [`managedIdentities`](#parameter-managedidentities) | object | The managed identity definition for this resource. |
| [`openTelemetryConfiguration`](#parameter-opentelemetryconfiguration) | object | Open Telemetry configuration. |
| [`peerTrafficEncryption`](#parameter-peertrafficencryption) | bool | Whether or not to encrypt peer traffic. |
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
| [`storages`](#parameter-storages) | array | The list of storages to mount on the environment. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
Expand Down Expand Up @@ -761,6 +766,14 @@ Open Telemetry configuration.
- Type: object
- Default: `{}`

### Parameter: `peerTrafficEncryption`

Whether or not to encrypt peer traffic.

- Required: No
- Type: bool
- Default: `True`

### Parameter: `roleAssignments`

Array of role assignments to create.
Expand Down
10 changes: 9 additions & 1 deletion avm/res/app/managed-environment/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ param platformReservedCidr string = ''
@description('Conditional. An IP address from the IP range defined by "platformReservedCidr" that will be reserved for the internal DNS server. It must not be the first address in the range and can only be used when the environment is deployed into a virtual network. If not provided, it will be set with a default value by the platform. Required if zoneRedundant is set to true to make the resource WAF compliant.')
param platformReservedDnsIP string = ''

@description('Optional. Whether or not to encrypt peer traffic.')
param peerTrafficEncryption bool = true

@description('Optional. Whether or not this Managed Environment is zone-redundant.')
param zoneRedundant bool = true

Expand Down Expand Up @@ -146,7 +149,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09
scope: resourceGroup(split(logAnalyticsWorkspaceResourceId, '/')[2], split(logAnalyticsWorkspaceResourceId, '/')[4])
}

resource managedEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-preview' = {
resource managedEnvironment 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
name: name
location: location
tags: tags
Expand All @@ -170,6 +173,11 @@ resource managedEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-previe
dnsSuffix: dnsSuffix
}
openTelemetryConfiguration: !empty(openTelemetryConfiguration) ? openTelemetryConfiguration : null
peerTrafficConfiguration: {
encryption: {
enabled: peerTrafficEncryption
}
}
vnetConfiguration: {
internal: internal
infrastructureSubnetId: !empty(infrastructureSubnetId) ? infrastructureSubnetId : null
Expand Down
22 changes: 17 additions & 5 deletions avm/res/app/managed-environment/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "364014764379639426"
"templateHash": "13961196804563097956"
},
"name": "App ManagedEnvironments",
"description": "This module deploys an App Managed Environment (also known as a Container App Environment).",
Expand Down Expand Up @@ -285,6 +285,13 @@
"description": "Conditional. An IP address from the IP range defined by \"platformReservedCidr\" that will be reserved for the internal DNS server. It must not be the first address in the range and can only be used when the environment is deployed into a virtual network. If not provided, it will be set with a default value by the platform. Required if zoneRedundant is set to true to make the resource WAF compliant."
}
},
"peerTrafficEncryption": {
"type": "bool",
"defaultValue": true,
"metadata": {
"description": "Optional. Whether or not to encrypt peer traffic."
}
},
"zoneRedundant": {
"type": "bool",
"defaultValue": true,
Expand Down Expand Up @@ -372,7 +379,7 @@
"count": "[length(coalesce(parameters('storages'), createArray()))]"
},
"type": "Microsoft.App/managedEnvironments/storages",
"apiVersion": "2023-11-02-preview",
"apiVersion": "2024-02-02-preview",
"name": "[format('{0}/{1}', parameters('name'), coalesce(parameters('storages'), createArray())[copyIndex()].shareName)]",
"properties": {
"nfsAzureFile": "[if(equals(coalesce(parameters('storages'), createArray())[copyIndex()].kind, 'NFS'), createObject('accessMode', coalesce(parameters('storages'), createArray())[copyIndex()].accessMode, 'server', format('{0}.file.{1}', coalesce(parameters('storages'), createArray())[copyIndex()].storageAccountName, environment().suffixes.storage), 'shareName', format('/{0}/{1}', coalesce(parameters('storages'), createArray())[copyIndex()].storageAccountName, coalesce(parameters('storages'), createArray())[copyIndex()].shareName)), null())]",
Expand Down Expand Up @@ -413,7 +420,7 @@
},
"managedEnvironment": {
"type": "Microsoft.App/managedEnvironments",
"apiVersion": "2023-11-02-preview",
"apiVersion": "2024-02-02-preview",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"tags": "[parameters('tags')]",
Expand All @@ -437,6 +444,11 @@
"dnsSuffix": "[parameters('dnsSuffix')]"
},
"openTelemetryConfiguration": "[if(not(empty(parameters('openTelemetryConfiguration'))), parameters('openTelemetryConfiguration'), null())]",
"peerTrafficConfiguration": {
"encryption": {
"enabled": "[parameters('peerTrafficEncryption')]"
}
},
"vnetConfiguration": {
"internal": "[parameters('internal')]",
"infrastructureSubnetId": "[if(not(empty(parameters('infrastructureSubnetId'))), parameters('infrastructureSubnetId'), null())]",
Expand Down Expand Up @@ -502,7 +514,7 @@
"metadata": {
"description": "The location the resource was deployed into."
},
"value": "[reference('managedEnvironment', '2023-11-02-preview', 'full').location]"
"value": "[reference('managedEnvironment', '2024-02-02-preview', 'full').location]"
},
"name": {
"type": "string",
Expand All @@ -523,7 +535,7 @@
"metadata": {
"description": "The principal ID of the system assigned identity."
},
"value": "[coalesce(tryGet(tryGet(reference('managedEnvironment', '2023-11-02-preview', 'full'), 'identity'), 'principalId'), '')]"
"value": "[coalesce(tryGet(tryGet(reference('managedEnvironment', '2024-02-02-preview', 'full'), 'identity'), 'principalId'), '')]"
},
"defaultDomain": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2023-04-01' = {
{
name: 'defaultSubnet'
properties: {
addressPrefix: cidrSubnet(addressPrefix, 16, 0)
addressPrefix: cidrSubnet(addressPrefix, 23, 0)
delegations: [
{
name: 'Microsoft.App.environments'
Expand Down Expand Up @@ -138,4 +138,4 @@ output managedIdentityResourceId string = managedIdentity.id
output appInsightsConnectionString string = appInsightsComponent.properties.ConnectionString

@description('The name of the created Storage Account.')
output storageAccountName string = storageAccount.name
output storageAccountName string = storageAccount.name
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module testDeployment '../../../main.bicep' = [
]
internal: true
dockerBridgeCidr: '172.16.0.1/28'
peerTrafficEncryption: true
platformReservedCidr: '172.17.17.0/24'
platformReservedDnsIP: '172.17.17.17'
infrastructureSubnetId: nestedDependencies.outputs.subnetResourceId
Expand Down
4 changes: 2 additions & 2 deletions avm/res/app/managed-environment/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.6",
"version": "0.7",
"pathFilters": [
"./main.json"
]
}
}

0 comments on commit a0781ab

Please sign in to comment.