Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Fixes #12

Closed
wants to merge 14 commits into from
331 changes: 285 additions & 46 deletions README.md

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions _header.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# terraform-azurerm-avm-template

This is a template repo for Terraform Azure Verified Modules.

Things to do:

1. Set up a GitHub repo environment called `test`.
1. Configure environment protection rule to ensure that approval is required before deploying to this environment.
1. Create a user-assigned managed identity in your test subscription.
1. Create a role assignment for the managed identity on your test subscription, use the minimum required role.
1. Configure federated identity credentials on the user assigned managed identity. Use the GitHub environment.
1. Search and update TODOs within the code and remove the TODO comments once complete.

> [!IMPORTANT]
> As the overall AVM framework is not GA (generally available) yet - the CI framework and test automation is not fully functional and implemented across all supported languages yet - breaking changes are expected, and additional customer feedback is yet to be gathered and incorporated. Hence, modules **MUST NOT** be published at version `1.0.0` or higher at this time.
>
Expand Down
81 changes: 47 additions & 34 deletions examples/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@
This deploys the module in its simplest form.

```hcl
terraform {
required_version = "~> 1.5"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.74"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}

provider "azurerm" {
features {}
}


## Section to provide a random Azure region for the resource group
# This allows us to randomize the region for the resource group.
module "regions" {
Expand All @@ -47,21 +28,40 @@ module "naming" {
resource "azurerm_resource_group" "this" {
location = module.regions.regions[random_integer.region_index.result].name
name = module.naming.resource_group.name_unique
tags = local.tags
}

data "azurerm_client_config" "current" {}

# This is the module call
# Do not specify location here due to the randomization above.
# Leaving location as `null` will cause the module to use the resource group location
# with a data source.
module "test" {
module "disk" {
source = "../../"
# source = "Azure/avm-<res/ptn>-<name>/azurerm"
# source = "Azure/avm-res-compute-disk/azurerm"
# ...
location = azurerm_resource_group.this.location
name = "TODO" # TODO update with module.naming.<RESOURCE_TYPE>.name_unique
name = module.naming.managed_disk.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
create_option = "Empty"
storage_account_type = "PremiumV2_LRS"
disk_size_gb = 1024
tags = local.tags

# Uncomment the code below to implement a VMSS Lock
#lock = {
# name = "VMSSNoDelete"
# kind = "CanNotDelete"
#}

// Example role assignment
role_assignments = {
role_assignment = {
principal_id = data.azurerm_client_config.current.object_id
role_definition_id_or_name = "Reader"
description = "Assign the Reader role to the deployment user on this disk resource scope."
}
}
}
```

Expand All @@ -70,7 +70,7 @@ module "test" {

The following requirements are needed by this module:

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

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

Expand All @@ -90,6 +90,7 @@ The following resources are used by this module:

- [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)
- [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source)

<!-- markdownlint-disable MD013 -->
## Required Inputs
Expand All @@ -112,12 +113,30 @@ Default: `true`

## Outputs

No outputs.
The following outputs are exported:

### <a name="output_location"></a> [location](#output\_location)

Description: The deployment region.

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

Description: This is the full output for the resource.

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

Description: The name of the Resource Group.

## Modules

The following Modules are called:

### <a name="module_disk"></a> [disk](#module\_disk)

Source: ../../

Version:

### <a name="module_naming"></a> [naming](#module\_naming)

Source: Azure/naming/azurerm
Expand All @@ -130,12 +149,6 @@ Source: Azure/regions/azurerm

Version: ~> 0.3

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

Source: ../../

Version:

<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

Expand Down
5 changes: 5 additions & 0 deletions examples/default/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
locals {
tags = {
scenario = "Disk Default AVM Sample"
}
}
52 changes: 26 additions & 26 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
terraform {
required_version = "~> 1.5"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.74"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}

provider "azurerm" {
features {}
}


## Section to provide a random Azure region for the resource group
# This allows us to randomize the region for the resource group.
module "regions" {
Expand All @@ -41,19 +22,38 @@ module "naming" {
resource "azurerm_resource_group" "this" {
location = module.regions.regions[random_integer.region_index.result].name
name = module.naming.resource_group.name_unique
tags = local.tags
}

data "azurerm_client_config" "current" {}

# This is the module call
# Do not specify location here due to the randomization above.
# Leaving location as `null` will cause the module to use the resource group location
# with a data source.
module "test" {
module "disk" {
source = "../../"
# source = "Azure/avm-<res/ptn>-<name>/azurerm"
# source = "Azure/avm-res-compute-disk/azurerm"
# ...
location = azurerm_resource_group.this.location
name = "TODO" # TODO update with module.naming.<RESOURCE_TYPE>.name_unique
name = module.naming.managed_disk.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
create_option = "Empty"
storage_account_type = "PremiumV2_LRS"
disk_size_gb = 1024
tags = local.tags

# Uncomment the code below to implement a VMSS Lock
#lock = {
# name = "VMSSNoDelete"
# kind = "CanNotDelete"
#}

// Example role assignment
role_assignments = {
role_assignment = {
principal_id = data.azurerm_client_config.current.object_id
role_definition_id_or_name = "Reader"
description = "Assign the Reader role to the deployment user on this disk resource scope."
}
}
}
14 changes: 14 additions & 0 deletions examples/default/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
output "location" {
description = "The deployment region."
value = module.disk.location
}

output "resource" {
description = "This is the full output for the resource."
value = module.disk.resource
}

output "resource_group_name" {
description = "The name of the Resource Group."
value = module.disk.resource_group_name
}
19 changes: 19 additions & 0 deletions examples/default/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
terraform {
required_version = "~> 1.7"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.74"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}

provider "azurerm" {
features {}
}


Loading
Loading