Skip to content

Commit

Permalink
fix: support for azurerm v4.x, FC1 sku_name, updates to regex v…
Browse files Browse the repository at this point in the history
…alidation for `name` (#70)

* modifications to variables, fixing avm scripts, aligning default example

* more modifications

* removing zone mapping from output

* removing commented sections, new logic for worker_count

* initial commit

* updating regex validation
  • Loading branch information
donovm4 authored Nov 21, 2024
1 parent 97e2e0b commit 4cb7d64
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
run-e2e-tests:
if: github.event.repository.name != 'terraform-azurerm-avm-template' && github.event.pull_request.head.repo.fork == false
if: github.event.pull_request.head.repo.fork == false
uses: Azure/terraform-azurerm-avm-template/.github/workflows/test-examples-template.yml@main
name: end to end
secrets: inherit
Expand Down
8 changes: 4 additions & 4 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@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2

- 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@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2

- 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@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2

- name: avmfix
uses: Azure/terraform-azurerm-avm-template/.github/actions/avmfix@main
Expand All @@ -54,4 +54,4 @@ jobs:
needs: [docs, terraform, avmfix]
runs-on: ubuntu-latest
steps:
- run: echo "All linting checks passed"
- run: echo "All linting checks passed"
4 changes: 2 additions & 2 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
if: github.event.repository.name != 'terraform-azurerm-avm-template'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- name: Check version
uses: Azure/terraform-azurerm-avm-template/.github/actions/version-check@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The following requirements are needed by this module:

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

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

- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)

Expand Down
4 changes: 2 additions & 2 deletions avm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fi
# Check if we are running in a container
# If we are then just run make directly
if [ -z "$AVM_IN_CONTAINER" ]; then
$CONTAINER_RUNTIME run --pull always --user "$(id -u):$(id -g)" --rm $AZURE_VOLUME -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group -v "$(pwd)":/src -w /src -e GITHUB_REPOSITORY -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make "$1"
$CONTAINER_RUNTIME run --pull always --user "$(id -u):$(id -g)" --rm $AZURE_VOLUME -v "$(pwd)":/src -w /src -e GITHUB_REPOSITORY -e ARM_SUBSCRIPTION_ID -e GITHUB_REPOSITORY_OWNER mcr.microsoft.com/azterraform make "$1"
else
make "$1"
fi
fi
15 changes: 6 additions & 9 deletions examples/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This deploys the module in its simplest form.

```hcl
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.5.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
version = ">= 3.71.0, < 4.0.0"
}
random = {
source = "hashicorp/random"
Expand Down Expand Up @@ -46,12 +46,9 @@ resource "azurerm_resource_group" "this" {
}
# 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" {
#source = "Azure/avm-res-web-serverfarm/azurerm"
# version = 0.1.0 # Update the version as needed
# source = "Azure/avm-res-web-serverfarm/azurerm"
# version = 0.2.1
source = "../.."
Expand All @@ -69,9 +66,9 @@ 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.0)

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

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

Expand Down
11 changes: 4 additions & 7 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
terraform {
required_version = ">= 1.3.0"
required_version = ">= 1.5.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
version = ">= 3.71.0, < 4.0.0"
}
random = {
source = "hashicorp/random"
Expand Down Expand Up @@ -40,12 +40,9 @@ resource "azurerm_resource_group" "this" {
}

# 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" {
#source = "Azure/avm-res-web-serverfarm/azurerm"
# version = 0.1.0 # Update the version as needed
# source = "Azure/avm-res-web-serverfarm/azurerm"
# version = 0.2.1

source = "../.."

Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data "azurerm_location" "region" {

resource "azurerm_service_plan" "this" {
location = var.location
name = var.name # calling code must supply the name
name = var.name
os_type = var.os_type
resource_group_name = var.resource_group_name
sku_name = var.sku_name
Expand Down
2 changes: 1 addition & 1 deletion terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.71"
version = ">= 3.71.0, < 5.0.0"
}
modtm = {
source = "azure/modtm"
Expand Down
6 changes: 3 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variable "name" {
description = "The name of the this resource."

validation {
condition = can(regex("^[a-z0-9-]{1,60}$", var.name))
condition = can(regex("^[a-zA-Z0-9-]{1,60}$", var.name))
error_message = "The name must be between 1 and 60 characters long and can only contain letters, numbers, hyphens and Unicode characters."
}
}
Expand Down Expand Up @@ -114,8 +114,8 @@ variable "sku_name" {
description = "The SKU name of the service plan. Defaults to `P1v2`."

validation {
condition = can(regex("B1|B2|B3|D1|F1|I1|I2|I3|I1v2|I2v2|I3v2|I4v2|I5v2|I6v2|P1v2|P2v2|P3v2|P0v3|P1v3|P2v3|P3v3|P1mv3|P2mv3|P3mv3|P4mv3|P5mv3|S1|S2|S3|SHARED|EP1|EP2|EP3|WS1|WS2|WS3|Y1", var.sku_name))
error_message = "The SKU name must be B1, B2, B3, D1, F1, I1, I2, I3, I1v2, I2v2, I3v2, I4v2, I5v2, I6v2, P1v2, P2v2, P3v2, P0v3, P1v3, P2v3, P3v3, P1mv3, P2mv3, P3mv3, P4mv3, P5mv3, S1, S2, S3, SHARED, EP1, EP2, EP3, WS1, WS2, WS3, and Y1."
condition = can(regex("B1|B2|B3|D1|F1|I1|I2|I3|I1v2|I2v2|I3v2|I4v2|I5v2|I6v2|P1v2|P2v2|P3v2|P0v3|P1v3|P2v3|P3v3|P1mv3|P2mv3|P3mv3|P4mv3|P5mv3|S1|S2|S3|SHARED|EP1|EP2|EP3|FC1|WS1|WS2|WS3|Y1", var.sku_name))
error_message = "The SKU name must be B1, B2, B3, D1, F1, I1, I2, I3, I1v2, I2v2, I3v2, I4v2, I5v2, I6v2, P1v2, P2v2, P3v2, P0v3, P1v3, P2v3, P3v3, P1mv3, P2mv3, P3mv3, P4mv3, P5mv3, S1, S2, S3, SHARED, EP1, EP2, EP3, FC1, WS1, WS2, WS3, and Y1."
}
}

Expand Down

0 comments on commit 4cb7d64

Please sign in to comment.