Skip to content

Commit

Permalink
fix!: latest avm standards (#113)
Browse files Browse the repository at this point in the history
* fix!: latest avm standards

* docs: make docs

* broke: cycle

* feat: refactor into submodules

* fix: lint (most)

* feat: add private endpoint DNS zone group management

* fix: up http provider version to v3

* fix: pe idempotent check

* docs: docs
  • Loading branch information
matt-FFFFFF committed Jun 10, 2024
1 parent 313c4ce commit 6b8396a
Show file tree
Hide file tree
Showing 42 changed files with 1,379 additions and 215 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
outputs:
examples: ${{ steps.getexamples.outputs.examples }}
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6
- name: get examples
id: getexamples
uses: Azure/terraform-azurerm-avm-template/.github/actions/e2e-getexamples@main
Expand All @@ -38,7 +38,7 @@ jobs:
example: ${{ fromJson(needs.getexamples.outputs.examples) }}
fail-fast: false
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6

- name: Test example
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6

- name: check docs
uses: Azure/terraform-azurerm-avm-template/.github/actions/docs-check@main
Expand All @@ -32,7 +32,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6

- name: lint terraform
uses: Azure/terraform-azurerm-avm-template/.github/actions/linting@main
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6

- name: avmfix
uses: Azure/terraform-azurerm-avm-template/.github/actions/avmfix@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: github.event.repository.name != 'terraform-azurerm-avm-template'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b #v4.1.5
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6
- name: Check version
uses: Azure/terraform-azurerm-avm-template/.github/actions/version-check@main
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ avm.tflint.merged.hcl
avm.tflint_example.merged.hcl
*.md.tmp
.DS_Store
avm.tflint_module.hcl
avm.tflint_module.merged.hcl
93 changes: 67 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,39 @@ Module to deploy key vaults, keys and secrets in Azure.

The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (>= 1.6.0)
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.6)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.71.0)
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)

- <a name="requirement_random"></a> [random](#requirement\_random) (>= 3.5.0)
- <a name="requirement_random"></a> [random](#requirement\_random) (~> 3.5)

- <a name="requirement_time"></a> [time](#requirement\_time) (>= 0.9.1)
- <a name="requirement_time"></a> [time](#requirement\_time) (~> 0.9)

## Providers

The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (>= 3.71.0)
- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (~> 3.71)

- <a name="provider_random"></a> [random](#provider\_random) (>= 3.5.0)
- <a name="provider_random"></a> [random](#provider\_random) (~> 3.5)

- <a name="provider_time"></a> [time](#provider\_time) (>= 0.9.1)
- <a name="provider_time"></a> [time](#provider\_time) (~> 0.9)

## Resources

The following resources are used by this module:

- [azurerm_key_vault.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault) (resource)
- [azurerm_key_vault_key.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_key) (resource)
- [azurerm_key_vault_secret.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource)
- [azurerm_key_vault_certificate_contacts.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_certificate_contacts) (resource)
- [azurerm_management_lock.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
- [azurerm_monitor_diagnostic_setting.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) (resource)
- [azurerm_private_endpoint.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource)
- [azurerm_private_endpoint.this_unmanaged_dns_zone_groups](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource)
- [azurerm_private_endpoint_application_security_group_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint_application_security_group_association) (resource)
- [azurerm_resource_group_template_deployment.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group_template_deployment) (resource)
- [azurerm_role_assignment.keys](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [azurerm_role_assignment.secrets](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [random_id.telemetry](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) (resource)
- [time_sleep.wait_for_rbac_before_contact_operations](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) (resource)
- [time_sleep.wait_for_rbac_before_key_operations](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) (resource)
- [time_sleep.wait_for_rbac_before_secret_operations](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) (resource)

Expand Down Expand Up @@ -205,6 +204,7 @@ map(object({
condition = optional(string, null)
condition_version = optional(string, null)
delegated_managed_identity_resource_id = optional(string, null)
principal_type = optional(string, null)
})), {})
rotation_policy = optional(object({
Expand All @@ -228,12 +228,12 @@ Type:

```hcl
object({
kind = string
name = optional(string, null)
kind = optional(string, "None")
})
```

Default: `{}`
Default: `null`

### <a name="input_network_acls"></a> [network\_acls](#input\_network\_acls)

Expand Down Expand Up @@ -292,12 +292,13 @@ map(object({
condition = optional(string, null)
condition_version = optional(string, null)
delegated_managed_identity_resource_id = optional(string, null)
principal_type = optional(string, null)
})), {})
lock = optional(object({
kind = string
name = optional(string, null)
kind = optional(string, "None")
}), {})
tags = optional(map(any), null)
}), null)
tags = optional(map(string), null)
subnet_resource_id = string
private_dns_zone_group_name = optional(string, "default")
private_dns_zone_resource_ids = optional(set(string), [])
Expand All @@ -315,6 +316,14 @@ map(object({

Default: `{}`

### <a name="input_private_endpoints_manage_dns_zone_group"></a> [private\_endpoints\_manage\_dns\_zone\_group](#input\_private\_endpoints\_manage\_dns\_zone\_group)

Description: Whether to manage private DNS zone groups with this module. If set to false, you must manage private DNS zone groups externally, e.g. using Azure Policy.

Type: `bool`

Default: `true`

### <a name="input_public_network_access_enabled"></a> [public\_network\_access\_enabled](#input\_public\_network\_access\_enabled)

Description: Specifies whether public access is permitted.
Expand Down Expand Up @@ -355,6 +364,7 @@ map(object({
condition = optional(string, null)
condition_version = optional(string, null)
delegated_managed_identity_resource_id = optional(string, null)
principal_type = optional(string, null)
}))
```

Expand Down Expand Up @@ -392,6 +402,7 @@ map(object({
condition = optional(string, null)
condition_version = optional(string, null)
delegated_managed_identity_resource_id = optional(string, null)
principal_type = optional(string, null)
})), {})
}))
```
Expand All @@ -412,7 +423,7 @@ Default: `null`

### <a name="input_sku_name"></a> [sku\_name](#input\_sku\_name)

Description: The SKU name of the Key Vault. Default is `premium`. `Possible values are `standard` and `premium`.`
Description: The SKU name of the Key Vault. Default is `premium`. Possible values are `standard` and `premium`.

Type: `string`

Expand All @@ -430,10 +441,28 @@ Default: `null`

Description: Map of tags to assign to the Key Vault resource.

Type: `map(any)`
Type: `map(string)`

Default: `null`

### <a name="input_wait_for_rbac_before_contact_operations"></a> [wait\_for\_rbac\_before\_contact\_operations](#input\_wait\_for\_rbac\_before\_contact\_operations)

Description: This variable controls the amount of time to wait before performing contact operations.
It only applies when `var.role_assignments` and `var.contacts` are both set.
This is useful when you are creating role assignments on the key vault and immediately creating keys in it.
The default is 30 seconds for create and 0 seconds for destroy.

Type:

```hcl
object({
create = optional(string, "30s")
destroy = optional(string, "0s")
})
```

Default: `{}`

### <a name="input_wait_for_rbac_before_key_operations"></a> [wait\_for\_rbac\_before\_key\_operations](#input\_wait\_for\_rbac\_before\_key\_operations)

Description: This variable controls the amount of time to wait before performing key operations.
Expand Down Expand Up @@ -474,25 +503,37 @@ Default: `{}`

The following outputs are exported:

### <a name="output_keys_resource_ids"></a> [keys\_resource\_ids](#output\_keys\_resource\_ids)

Description: A map of key keys to resource ids.

### <a name="output_private_endpoints"></a> [private\_endpoints](#output\_private\_endpoints)

Description: A map of private endpoints. The map key is the supplied input to var.private\_endpoints. The map value is the entire azurerm\_private\_endpoint resource.

### <a name="output_resource"></a> [resource](#output\_resource)
### <a name="output_resource_id"></a> [resource\_id](#output\_resource\_id)

Description: The Key Vault resource.
Description: The Azure resource id of the key vault.

### <a name="output_resource_keys"></a> [resource\_keys](#output\_resource\_keys)
### <a name="output_secrets_resource_ids"></a> [secrets\_resource\_ids](#output\_secrets\_resource\_ids)

Description: A map of key objects. The map key is the supplied input to var.keys. The map value is the entire azurerm\_key\_vault\_key resource.
Description: A map of secret keys to resource ids.

### <a name="output_resource_secrets"></a> [resource\_secrets](#output\_resource\_secrets)
## Modules

Description: A map of secret objects. The map key is the supplied input to var.secrets. The map value is the entire azurerm\_key\_vault\_secret resource.
The following Modules are called:

## Modules
### <a name="module_keys"></a> [keys](#module\_keys)

Source: ./modules/key

Version:

### <a name="module_secrets"></a> [secrets](#module\_secrets)

Source: ./modules/secret

No modules.
Version:

<!-- markdownlint-disable-next-line MD041 -->
## Data Collection
Expand Down
35 changes: 28 additions & 7 deletions examples/create-key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@
This example shows how to deploy the module and create a key using Azure RBAC.

```hcl
provider "azurerm" {
features {}
}
terraform {
required_version = "~> 1.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.71"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
http = {
source = "hashicorp/http"
version = "~> 3.4"
}
}
}
module "regions" {
source = "Azure/regions/azurerm"
version = "0.4.0"
Expand Down Expand Up @@ -57,10 +79,9 @@ module "key_vault" {
"verify",
"wrapKey"
]
key_type = "RSA"
key_vault_id = module.key_vault.resource.id
name = "cmk-for-storage-account"
key_size = 2048
key_type = "RSA"
name = "cmk-for-storage-account"
key_size = 2048
}
}
role_assignments = {
Expand All @@ -69,7 +90,7 @@ module "key_vault" {
principal_id = data.azurerm_client_config.current.object_id
}
}
wait_for_rbac_before_secret_operations = {
wait_for_rbac_before_key_operations = {
create = "60s"
}
network_acls = {
Expand All @@ -86,7 +107,7 @@ The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.6)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.7)
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)

- <a name="requirement_http"></a> [http](#requirement\_http) (~> 3.4)

Expand All @@ -96,7 +117,7 @@ The following requirements are needed by this module:

The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (~> 3.7)
- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (~> 3.71)

- <a name="provider_http"></a> [http](#provider\_http) (~> 3.4)

Expand Down
31 changes: 26 additions & 5 deletions examples/create-key/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
provider "azurerm" {
features {}
}

terraform {
required_version = "~> 1.6"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.71"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
http = {
source = "hashicorp/http"
version = "~> 3.4"
}
}
}

module "regions" {
source = "Azure/regions/azurerm"
version = "0.4.0"
Expand Down Expand Up @@ -51,10 +73,9 @@ module "key_vault" {
"verify",
"wrapKey"
]
key_type = "RSA"
key_vault_id = module.key_vault.resource.id
name = "cmk-for-storage-account"
key_size = 2048
key_type = "RSA"
name = "cmk-for-storage-account"
key_size = 2048
}
}
role_assignments = {
Expand All @@ -63,7 +84,7 @@ module "key_vault" {
principal_id = data.azurerm_client_config.current.object_id
}
}
wait_for_rbac_before_secret_operations = {
wait_for_rbac_before_key_operations = {
create = "60s"
}
network_acls = {
Expand Down
Loading

0 comments on commit 6b8396a

Please sign in to comment.