terraform.azure.best-practice.azure-storage-account-enables-secure-transfer.azure-storage-account-enables-secure-transfer

profile photo of semgrepsemgrep
Author
unknown
Download Count*

Ensure that storage account enables secure transfer

Run Locally

Run in CI

Defintion

rules:
  - id: azure-storage-account-enables-secure-transfer
    message: Ensure that storage account enables secure transfer
    patterns:
      - pattern: resource
      - pattern-inside: |
          resource "azurerm_storage_account" "..." {
          ...
          enable_https_traffic_only = false
          ...
          }
    metadata:
      category: best-practice
      technology:
        - terraform
        - azure
      license: Commons Clause License Condition v1.0[LGPL-2.1-only]
    languages:
      - hcl
    severity: WARNING

Examples

azure-storage-account-enables-secure-transfer.tf

# fail
# ruleid: azure-storage-account-enables-secure-transfer
resource "azurerm_storage_account" "example" {
    name                     = "storageaccountname"
    resource_group_name      = azurerm_resource_group.example.name
    location                 = azurerm_resource_group.example.location
    account_tier             = "Standard"
    account_replication_type = "GRS"
    enable_https_traffic_only = false

    tags = {
    environment = "staging"
    }
}

# pass
resource "azurerm_storage_account" "example" {
    name                     = "storageaccountname"
    resource_group_name      = azurerm_resource_group.example.name
    location                 = azurerm_resource_group.example.location
    account_tier             = "Standard"
    account_replication_type = "GRS"
    enable_https_traffic_only = true

    tags = {
    environment = "staging"
    }
}

# pass
resource "azurerm_storage_account" "example" {
    name                     = "storageaccountname"
    resource_group_name      = azurerm_resource_group.example.name
    location                 = azurerm_resource_group.example.location
    account_tier             = "Standard"
    account_replication_type = "GRS"
    tags = {
    environment = "staging"
    }
}