hashicorp / vscode-terraform

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

Unexpected attribute error for terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks #1800

Closed jimmyzzxhlh closed 1 month ago

jimmyzzxhlh commented 1 month ago

Extension Version

v2.32.0

VS Code Version

Version: 1.91.1 (Universal) Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 Date: 2024-07-09T22:07:54.982Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0

Operating System

macOS 14.5 (23F79)

Terraform Version

Terraform v1.7.1 on darwin_arm64

Steps to Reproduce

The module terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks is starting to show red lines with all attributes as "Unexpected attributes". This was working before in the past couple of weeks.

I tried to upgrade the module from 5.39.0 to 5.41.0 and the issue still exists.

image

Expected Behavior

Shouldn't show any errors.

Actual Behavior

See aove.

Terraform Configuration

module "broker_service_account_role" {
  source                         = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
  role_name                      = "broker-service-account-role"
  attach_external_secrets_policy = true
  external_secrets_secrets_manager_arns = [
    "arn:aws:secretsmanager:us-west-2:637423350792:secret:production/*",
  ]
  # This is the KMS key ARN for aws/secretsmanager in the production account.
  external_secrets_kms_key_arns                      = ["arn:aws:kms:us-west-2:637423350792:key/..."]
  external_secrets_secrets_manager_create_permission = false

  oidc_providers = {
    ex = {
      provider_arn = module.broker_eks_production.oidc_provider_arn
      namespace_service_accounts = [
        "authbroker:authbroker-service-account",
      ]
    }
  }
}

Project Structure

No response

Gist

No response

Anything Else?

No response

Workarounds

No response

References

No response

Help Wanted

Community Note

jpalcisodeltek commented 1 month ago

The double-slash in the module source address is being treated as a single-line comment symbol, I think. Removing the 'extra' slash clears the syntax highlights but this then makes the source address invalid.

Encountered the same with a another submodule:

source = "terraform-aws-modules/cloudwatch/aws//modules/metric-alarm"

Downgraded my plugin to the previous version for now (v2.31.0).

dbanck commented 1 month ago

Thanks for the report! I'm able to reproduce the problem.

I believe it has the same root cause as https://github.com/hashicorp/terraform-ls/issues/1771: we're using the top-level schema of the registry module instead of the appropriate submodule one.

I'm looking into a fix

dbanck commented 1 month ago

We have just released a new version of vscode-terraform: 2.32.1 that fixes the reported issue. The update should show up automatically in VS Code.

Thanks again for the report @jimmyzzxhlh

github-actions[bot] commented 1 week 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 details necessary to investigate further.