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

Prepare for CI #71

Merged
merged 3 commits into from
Oct 11, 2022
Merged

Prepare for CI #71

merged 3 commits into from
Oct 11, 2022

Conversation

lonegunmanb
Copy link
Member

This pull request will add a new CI pipeline to this module, refactor test and example code.

@lonegunmanb lonegunmanb temporarily deployed to acctests October 9, 2022 10:01 Inactive
@lonegunmanb lonegunmanb temporarily deployed to acctests October 9, 2022 10:08 Inactive
@zioproto
Copy link

How I tested this PR:

git fetch origin pull/71/head:pr71
git checkout pr71
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest make pre-commit
docker run --rm -v $(pwd):/src -w /src mcr.microsoft.com/azterraform:latest make pr-check

I am getting this error:

==> Checking terraform codes are formatted...
==> Checking documentation terraform blocks are formatted...
==> Checking test go code against linters...
run golangci-lint ...
==> Checking that code complies with tflint requirements...
Installing `basic-ext` plugin...
Installed `basic-ext` (source: github.com/Azure/tflint-ruleset-basic-ext, version: 0.1.0)
Installing `azurerm-ext` plugin...
Installed `azurerm-ext` (source: github.com/Azure/tflint-ruleset-azurerm-ext, version: 0.1.1)
Installing `azurerm` plugin...
Installed `azurerm` (source: github.com/terraform-linters/tflint-ruleset-azurerm, version: 0.18.0)
Failed to initialize plugins; TFLint is not compatible with this version of the "azurerm" plugin. A newer TFLint or plugin version may be required. Plugin version: 11, Client versions: [10]
Failed to initialize plugins; TFLint is not compatible with this version of the "azurerm" plugin. A newer TFLint or plugin version may be required. Plugin version: 11, Client versions: [10]
Failed to initialize plugins; TFLint is not compatible with this version of the "azurerm" plugin. A newer TFLint or plugin version may be required. Plugin version: 11, Client versions: [10]
Failed to initialize plugins; TFLint is not compatible with this version of the "azurerm" plugin. A newer TFLint or plugin version may be required. Plugin version: 11, Client versions: [10]
------------------------------------------------

The preceding files contain terraform blocks that does not complies with tflint requirements.

make: *** [tfmod-scaffold/GNUmakefile:43: tflint] Error 1

@zioproto
Copy link

I was working on a old Docker image. docker pull of the latest latest metatag fixed the tflink version error. Now I have another problem. This module has some warnings that are handled like errors:

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
true
==> Checking terraform codes are formatted...
==> Checking documentation terraform blocks are formatted...
==> Checking test go code against linters...
run golangci-lint ...
==> Checking that code complies with tflint requirements...
Plugin `azurerm` is already installed
Plugin `basic-ext` is already installed
Plugin `azurerm-ext` is already installed
6 issue(s) found:

Warning: `count.index` is not recommended to be used as the subscript of list/map, use for_each instead (terraform_count_index_usage)

  on main.tf line 27:
  27:   address_prefixes                               = [var.subnet_prefixes[count.index]]

Warning: `count.index` is not recommended to be used as the subscript of list/map, use for_each instead (terraform_count_index_usage)

  on main.tf line 28:
  29:   resource_group_name                            = data.azurerm_resource_group.vnet.name

Warning: `count.index` is not recommended to be used as the subscript of list/map, use for_each instead (terraform_count_index_usage)

  on main.tf line 31:
  31:   enforce_private_link_endpoint_network_policies = lookup(var.subnet_enforce_private_link_endpoint_network_policies, var.subnet_names[count.index], false)

Warning: `count.index` is not recommended to be used as the subscript of list/map, use for_each instead (terraform_count_index_usage)

  on main.tf line 32:
  32:   enforce_private_link_service_network_policies  = lookup(var.subnet_enforce_private_link_service_network_policies, var.subnet_names[count.index], false)

Warning: `count.index` is not recommended to be used as the subscript of list/map, use for_each instead (terraform_count_index_usage)

  on main.tf line 33:
  33:   service_endpoints                              = lookup(var.subnet_service_endpoints, var.subnet_names[count.index], null)

Warning: `count.index` is not recommended to be used as the subscript of list/map, use for_each instead (terraform_count_index_usage)

  on main.tf line 36:
  36:     for_each = lookup(var.subnet_delegation, var.subnet_names[count.index], {})

------------------------------------------------

The preceding files contain terraform blocks that does not complies with tflint requirements.

make: *** [tfmod-scaffold/GNUmakefile:43: tflint] Error 1

@lonegunmanb lonegunmanb temporarily deployed to acctests October 11, 2022 09:22 Inactive
@zioproto
Copy link

I confirm everything works testing this way:

docker pull mcr.microsoft.com/azterraform:latest # my image id was a8b915d48566
TFLINT_CONFIG=.tflint_alt.hcl docker run --rm -v $(pwd):/src -w /src -e TFLINT_CONFIG mcr.microsoft.com/azterraform:latest make pre-commit
TFLINT_CONFIG=.tflint_alt.hcl docker run --rm -v $(pwd):/src -w /src -e TFLINT_CONFIG mcr.microsoft.com/azterraform:latest make pr-check
export ARM_CLIENT_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
export ARM_CLIENT_SECRET="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
export ARM_SUBSCRIPTION_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
export ARM_TENANT_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
docker run --rm -v $(pwd):/src -w /src -e ARM_SUBSCRIPTION_ID -e ARM_TENANT_ID -e ARM_CLIENT_ID -e ARM_CLIENT_SECRET mcr.microsoft.com/azterraform:latest make e2e-test

All tests are passing:

--- PASS: TestExamples (1762.75s)
    --- PASS: TestExamples/examples/complete (361.12s)
    --- PASS: TestExamples/examples/new_route (369.36s)
    --- PASS: TestExamples/examples/new_security_rule (376.91s)
    --- PASS: TestExamples/examples/private_link_endpoint (326.69s)
    --- PASS: TestExamples/examples/private_link_service (328.65s)
PASS

LGTM, okay to merge

@zioproto
Copy link

@lonegunmanb I also tested that:

docker run --rm -v $(pwd):/src -w /src -e TFLINT_CONFIG=.tflint_alt.hcl mcr.microsoft.com/azterraform:latest make pr-check

is equivalent to:

TFLINT_CONFIG=.tflint_alt.hcl docker run --rm -v $(pwd):/src -w /src -e TFLINT_CONFIG mcr.microsoft.com/azterraform:latest make pr-check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants