Azure / ResourceModules

This repository includes a CI platform for and collection of mature and curated Bicep modules. The platform supports both ARM and Bicep and can be leveraged using GitHub actions as well as Azure DevOps pipelines.
https://aka.ms/carml
MIT License
724 stars 460 forks source link

Defaults on certain Azure resources properties can be hard to change once enabled #1113

Open ahmadabdalla opened 2 years ago

ahmadabdalla commented 2 years ago

Description

For example, there are certain properties on resources that if are enabled, cannot be rolled back or changed after. Below is an example for a storage account :

@description('Optional. A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. For security reasons, it is recommended to set it to true.')
param requireInfrastructureEncryption bool = true

Error example:

    ~~~~~~~~~~~~~~~~~~~~
       | 01:35:33 - The deployment
       | 'storageAccounts-20220309T0103294582Z' failed with error(s).
       | Showing 1 out of 1 error(s). Status Message: The property
       | 'requireInfrastructureEncryption' was specified in the input,
       | but it cannot be updated as it is read-only. For more
       | information, see - https://aka.ms/storageaccountupdate
       | (Code:AccountPropertyCannotBeUpdated)  CorrelationId:
       | 80271a0d-6011-444c-ba2d-14fe65af985f

Steps to reproduce

  1. Create a resource without a specific property that is enforced as a parameter default
  2. Enforce this property with a default in the module
  3. redeploy the same module again with the new change
ahmadabdalla commented 2 years ago

This also applies to virtual machines

@description('Optional. This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine. This will enable the encryption for all the disks including Resource/Temp disk at host itself. For security reasons, it is recommended to set encryptionAtHost to True. Restrictions: Cannot be enabled if Azure Disk Encryption (guest-VM encryption using bitlocker/DM-Crypt) is enabled on your VMs.')
param encryptionAtHost bool = true
 VERBOSE: Deployment output: {}
  Exception: /home/runner/work/_temp/25088aa3-c884-466a-99bc-45080b80d61d.ps1:49
  Line |
    49 |    throw $res.exception
       |    ~~~~~~~~~~~~~~~~~~~~
       | 01:33:24 - The deployment
       | 'virtualMachines-20220316T0103517410Z' failed with error(s).
       | Showing 1 out of 1 error(s). Status Message: The property
       | 'securityProfile.encryptionAtHost' is not valid because the
       | 'Microsoft.Compute/EncryptionAtHost' feature is not enabled
       | for this subscription. (Code:InvalidParameter)  CorrelationId:
       | 078cbb40-77f9-4505-8237-101dcde82d2e
rahalan commented 2 years ago

Need to wait for the discussion on how we handle "secure by default"

eriqua commented 1 year ago

Missing clarity on what to do with this issue. Moving back to needs triage and applying the needs further discussion label.

rahalan commented 1 year ago

Need to wait for the discussion on how we handle "secure by default"

DanoThom commented 7 months ago

Any movement on or internal discussions on this issue? It's definitely one that regularly appears for me and doesn't have a clear work around other than hacking at the underlying CARML module and deleting existing storage accounts that have strayed outside of any changes to the defaults...