Skip to content

Commit

Permalink
this re-aligns the template with fixes based on Azure/terraform-azure…
Browse files Browse the repository at this point in the history
  • Loading branch information
kewalaka committed Apr 11, 2024
1 parent 6e6ebd7 commit d902095
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 63 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

avmfix:
if: github.event.repository.name != 'terraform-azurerm-avm-template' && false
if: github.event.repository.name != 'terraform-azurerm-avm-template'
name: avmfix
runs-on: ubuntu-latest
steps:
Expand All @@ -49,3 +49,9 @@ jobs:

- name: avmfix
uses: Azure/terraform-azurerm-avm-template/.github/actions/avmfix@main

lintcomplete:
needs: [docs, terraform, avmfix]
runs-on: ubuntu-latest
steps:
- run: echo "All linting checks passed"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ avmmakefile
README-generated.md
avm.tflint.hcl
avm.tflint_example.hcl
avm.tflint.merged.hcl
avm.tflint_example.merged.hcl
*tfplan*
*.md.tmp
# MacOS
.DS_Store
avm.tflint.merged.hcl
avm.tflint_example.merged.hcl
85 changes: 51 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,44 @@ Things to do:

The following requirements are needed by this module:

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

- <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) (>= 1.9.0, < 2.0)
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)

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

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

## Providers

The following providers are used by this module:

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

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

## Resources

The following resources are used by this module:

- [azurerm_management_lock.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
- [azurerm_private_endpoint.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource)
- [azurerm_private_endpoint.this_managed_dns_zone_groups](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.TODO](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (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.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [random_id.telem](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) (resource)
- [azurerm_resource_group.parent](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source)

<!-- markdownlint-disable MD013 -->
## Required Inputs

The following input variables are required:

### <a name="input_location"></a> [location](#input\_location)

Description: Azure region where the resource should be deployed.

Type: `string`

### <a name="input_name"></a> [name](#input\_name)

Description: The name of the this resource.
Expand All @@ -76,20 +80,27 @@ The following input variables are optional (have default values):

### <a name="input_customer_managed_key"></a> [customer\_managed\_key](#input\_customer\_managed\_key)

Description: Customer managed keys that should be associated with the resource.
Description: A map describing customer-managed keys to associate with the resource. This includes the following properties:
- `key_vault_resource_id` - The resource ID of the Key Vault where the key is stored.
- `key_name` - The name of the key.
- `key_version` - (Optional) The version of the key. If not specified, the latest version is used.
- `user_assigned_identity` - (Optional) An object representing a user-assigned identity with the following properties:
- `resource_id` - The resource ID of the user-assigned identity.

Type:

```hcl
object({
key_vault_resource_id = optional(string)
key_name = optional(string)
key_version = optional(string, null)
user_assigned_identity_resource_id = optional(string, null)
key_vault_resource_id = string
key_name = string
key_version = optional(string, null)
user_assigned_identity = optional(object({
resource_id = string
}), null)
})
```

Default: `{}`
Default: `null`

### <a name="input_diagnostic_settings"></a> [diagnostic\_settings](#input\_diagnostic\_settings)

Expand Down Expand Up @@ -135,32 +146,30 @@ Type: `bool`

Default: `true`

### <a name="input_location"></a> [location](#input\_location)

Description: Azure region where the resource should be deployed. If null, the location will be inferred from the resource group location.

Type: `string`

Default: `null`

### <a name="input_lock"></a> [lock](#input\_lock)

Description: The lock level to apply. Default is `None`. Possible values are `None`, `CanNotDelete`, and `ReadOnly`.
Description: Controls the Resource Lock configuration for this resource. The following properties can be specified:

- `kind` - (Required) The type of lock. Possible values are `\"CanNotDelete\"` and `\"ReadOnly\"`.
- `name` - (Optional) The name of the lock. If not specified, a name will be generated based on the `kind` value. Changing this forces the creation of a new resource.

Type:

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

Default: `{}`
Default: `null`

### <a name="input_managed_identities"></a> [managed\_identities](#input\_managed\_identities)

Description: Managed identities to be created for the resource.
Description: Controls the Managed Identity configuration on this resource. The following properties can be specified:

- `system_assigned` - (Optional) Specifies if the System Assigned Managed Identity should be enabled.
- `user_assigned_resource_ids` - (Optional) Specifies a list of User Assigned Managed Identity resource IDs to be assigned to this resource.

Type:

Expand Down Expand Up @@ -208,10 +217,10 @@ map(object({
delegated_managed_identity_resource_id = 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 @@ -229,6 +238,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_role_assignments"></a> [role\_assignments](#input\_role\_assignments)

Description: A map of role assignments to create on this resource. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.
Expand Down Expand Up @@ -260,19 +277,19 @@ Default: `{}`

### <a name="input_tags"></a> [tags](#input\_tags)

Description: The map of tags to be applied to the resource
Description: (Optional) Tags of the resource.

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

Default: `{}`
Default: `null`

## Outputs

The following outputs are exported:

### <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.
Description: A map of the private endpoints created.

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

Expand Down
29 changes: 15 additions & 14 deletions examples/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ This deploys the module in its simplest form.

```hcl
terraform {
required_version = ">= 1.3.0"
required_version = "~> 1.5"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
version = "~> 3.74"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.0, < 4.0.0"
version = "~> 3.5"
}
}
}
Expand All @@ -27,7 +27,7 @@ provider "azurerm" {
# This allows us to randomize the region for the resource group.
module "regions" {
source = "Azure/regions/azurerm"
version = ">= 0.3.0"
version = "~> 0.3"
}
# This allows us to randomize the region for the resource group.
Expand All @@ -40,7 +40,7 @@ resource "random_integer" "region_index" {
# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
version = ">= 0.3.0"
version = "~> 0.3"
}
# This is required for resource modules
Expand All @@ -57,9 +57,10 @@ module "test" {
source = "../../"
# source = "Azure/avm-<res/ptn>-<name>/azurerm"
# ...
enable_telemetry = var.enable_telemetry # see variables.tf
name = "TODO" # TODO update with module.naming.<RESOURCE_TYPE>.name_unique
location = azurerm_resource_group.this.location
name = "TODO" # TODO update with module.naming.<RESOURCE_TYPE>.name_unique
resource_group_name = azurerm_resource_group.this.name
enable_telemetry = var.enable_telemetry # see variables.tf
}
```

Expand All @@ -68,19 +69,19 @@ module "test" {

The following requirements are needed by this module:

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

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.7.0, < 4.0.0)
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.74)

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

## Providers

The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (>= 3.7.0, < 4.0.0)
- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (~> 3.74)

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

## Resources

Expand Down Expand Up @@ -120,13 +121,13 @@ The following Modules are called:

Source: Azure/naming/azurerm

Version: >= 0.3.0
Version: ~> 0.3

### <a name="module_regions"></a> [regions](#module\_regions)

Source: Azure/regions/azurerm

Version: >= 0.3.0
Version: ~> 0.3

### <a name="module_test"></a> [test](#module\_test)

Expand Down
4 changes: 2 additions & 2 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module "test" {
# source = "Azure/avm-<res/ptn>-<name>/azurerm"
# ...
location = azurerm_resource_group.this.location
name = "TODO" # TODO update with module.naming.<RESOURCE_TYPE>.name_unique
name = "TODO" # TODO update with module.naming.<RESOURCE_TYPE>.name_unique
resource_group_name = azurerm_resource_group.this.name
enable_telemetry = var.enable_telemetry # see variables.tf
enable_telemetry = var.enable_telemetry # see variables.tf
}
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ locals {
user_assigned_resource_ids = var.managed_identities.user_assigned_resource_ids
}
} : {}
}
}

# Private endpoint application security group associations.
# We merge the nested maps from private endpoints and application security group associations into a single map.
Expand Down
4 changes: 2 additions & 2 deletions main.privateendpoint.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TODO remove this code & var.private_endpoints if private link is not support. Note it must be included in this module if it is supported.
resource "azurerm_private_endpoint" "this" {
resource "azurerm_private_endpoint" "this_managed_dns_zone_groups" {
for_each = var.private_endpoints

location = each.value.location != null ? each.value.location : var.location
Expand Down Expand Up @@ -74,5 +74,5 @@ resource "azurerm_private_endpoint_application_security_group_association" "this
for_each = local.private_endpoint_application_security_group_associations

application_security_group_id = each.value.asg_resource_id
private_endpoint_id = azurerm_private_endpoint.this[each.value.pe_key].id
private_endpoint_id = var.private_endpoints_manage_dns_zone_group ? azurerm_private_endpoint.this_managed_dns_zone_groups[each.value.pe_key].id : azurerm_private_endpoint.this_unmanaged_dns_zone_groups[each.value.pe_key].id
}
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resource "azurerm_resource_group" "TODO" {
location = var.location
name = var.name # calling code must supply the name
tags = var.tags
}

# required AVM resources interfaces
Expand All @@ -10,7 +11,7 @@ resource "azurerm_management_lock" "this" {

lock_level = var.lock.kind
name = coalesce(var.lock.name, "lock-${var.lock.kind}")
scope = azurerm_MY_RESOURCE.this.id
scope = azurerm_resource_group.TODO
notes = var.lock.kind == "CanNotDelete" ? "Cannot delete the resource or its child resources." : "Cannot delete or modify the resource or its child resources."
}

Expand Down
4 changes: 0 additions & 4 deletions terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ terraform {
required_version = "~> 1.5"
required_providers {
# TODO: Ensure all required providers are listed here and the version property includes a constraint on the maximum major version.
azapi = {
source = "Azure/azapi"
version = "~> 1.9"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.71"
Expand Down
3 changes: 1 addition & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ Controls the Resource Lock configuration for this resource. The following proper
- `name` - (Optional) The name of the lock. If not specified, a name will be generated based on the `kind` value. Changing this forces the creation of a new resource.
DESCRIPTION


validation {
condition = contains(["CanNotDelete", "ReadOnly", "None"], var.lock.kind)
condition = var.lock != null ? contains(["CanNotDelete", "ReadOnly"], var.lock.kind) : true
error_message = "The lock level must be one of: 'None', 'CanNotDelete', or 'ReadOnly'."
}
}
Expand Down

0 comments on commit d902095

Please sign in to comment.