hashicorp / vscode-terraform

HashiCorp Terraform VSCode extension
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Mozilla Public License 2.0
922 stars 179 forks source link

`count` is marked as undefined variable #220

Closed zerkms closed 4 years ago

zerkms commented 5 years ago
resource "aws_vpc" "vpc" {
  cidr_block = "10.10.0.0/16"
}

resource "aws_subnet" "subnet" {
  count = 3

  vpc_id = aws_vpc.vpc.id
  cidr_block = "10.10.${count.index + 1}.0/24"
  availability_zone_id = "apse2-az${count.index + 1}"
}

In the following HCL count (both instances) is marked as There is no variable named "count".

Vermyndax commented 4 years ago

Having this issue on language server 0.9 too.

zachovich commented 4 years ago

Same here on HCL2 and language server v0.0.9:

resource "aws_iam_role_policy_attachment" "this" { count = length(var.policy_arns)

role = aws_iam_role.this.name policy_arn = var.policy_arns[count.index] }

VSCode problems console shows: There is no variable names "count"

As if it doesn't treat 'count' as special word and looks for a variable definition

audricganser commented 4 years ago

@zachovich Not sure if this is your issue but from reading the Terraform docs it looks like count is not a supported argument for aws_iam_role_policy_attachment. https://www.terraform.io/docs/providers/aws/r/iam_role_policy_attachment.html#argument-reference

zerkms commented 4 years ago

@audricganser https://www.terraform.io/docs/configuration/resources.html#count-multiple-resource-instances-by-count

audricganser commented 4 years ago

I was just reading about meta-arguments and yes I suppose it should be able to handle count. It's my first time helping out on a project like this 😄 . Thanks for the link.

borikoss commented 4 years ago

having the same issue after tf upgrade to the version 12. Any progress here for a solution? Thanks!

DJAlPee commented 4 years ago

There is already a Pull Request pending, which will fix this issue in the language server: https://github.com/juliosueiras/terraform-lsp/pull/43

borikoss commented 4 years ago

@DJAlPee great, thx :) It seems as the PR has been merged yesterday

johnnyplaydrums commented 4 years ago

Just wondering are folks still experiencing this issue? I am still getting the count error. Do I need to update something or is the fix still pending? Thanks for the help 🙂

wcamarao commented 4 years ago

@mauve any chance you could release a new version including this change from lsp? 🙏

paultyng commented 4 years ago

We just released v2.0.0-rc.1 of the extension. The main features include:

You can find additional information and specifics in the release notes and CHANGELOG.

With this release we expect that many of the prior issues and PRs are no longer relevant or have been addressed, and are therefore being closed. If you feel the action taken on an issue or PR is in error, please comment as such and we can figure out the appropriate way to address it.

We plan to add the final 2.0.0 release to the marketplace soon, but are actively seeking your feedback now on the release candidates. You can download the .vsix from the releases page and manually install it in VS Code to try it out.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.