Skip to content

Extension intellisense incorrect for AWS GuardDuty resources with region specification, maybe Language Server is using the wrong provider version #2069

@clalexander

Description

@clalexander

Extension Version

2.34.2025012311

VS Code Version

Version: 1.102.0 (user setup)
Commit: cb0c47c0cfaad0757385834bd89d410c78a856c0
Date: 2025-07-09T22:10:34.600Z
Electron: 35.6.0
ElectronBuildId: 11847422
Chromium: 134.0.6998.205
Node.js: 22.15.1
V8: 13.4.114.21-electron.0
OS: Windows_NT x64 10.0.26100

Operating System

Windows 11 Pro (24H2, 26100.4652)

Terraform Version

Terraform v1.12.2 on windows_amd64

Steps to Reproduce

  1. Specify an aws >= 6.0 provider
  2. Create an AWS GuardDuty resource (e.g. aws_guardduty_detector )
  3. Specify the region attribute
  4. Observe Unexpected attribute: An attribute named "region" is not expected here intellisense error

Example repo: https://github.com/clalexander/vscode-hashicorp-terraform-extension-error-aws-guardduty

Expected Behavior

No intellisense error on the region attribute

Actual Behavior

Intellisense error on the region attribute

Terraform Configuration

# versions.tf
terraform {
  required_version = ">= 1.5"

  required_providers {
    aws = {
      source                = "hashicorp/aws"
      version               = ">= 6.0"
      configuration_aliases = [aws.management_account]
    }
  }
}

# variables.tf
variable "region" {
  description = "The region to enable GuardDuty in"
  type        = string
  default     = null
}

variable "enable_guardduty_detector" {
  description = "Whether to enable the GuardDuty detector"
  type        = bool
  default     = true
}

variable "publishing_frequency" {
  description = "GuardDuty findings publishing frequency."
  type        = string
  default     = "SIX_HOURS"
}

variable "accounts" {
  description = "List of accounts to enable GuardDuty in"
  type = list(object({
    id    = string
    email = string
  }))
  default = []
}

variable "tags" {
  description = "Tags to apply to resources"
  type        = map(string)
  default     = {}
}

# main.tf
data "aws_caller_identity" "current" {}

resource "aws_guardduty_detector" "this" {
  enable = var.enable_guardduty_detector
  region = var.region

  finding_publishing_frequency = var.publishing_frequency

  tags = var.tags
}

resource "aws_guardduty_organization_admin_account" "this" {
  admin_account_id = data.aws_caller_identity.current.account_id
  region           = var.region

  depends_on = [aws_guardduty_detector.this]

  provider = aws.management_account
}

resource "aws_guardduty_organization_configuration" "this" {
  detector_id = aws_guardduty_detector.this.id
  region      = var.region

  auto_enable_organization_members = "ALL"

  depends_on = [aws_guardduty_organization_admin_account.this]
}

resource "aws_guardduty_member" "this" {
  for_each = { for account in var.accounts : account.id => account }

  detector_id = aws_guardduty_detector.this.id
  region      = var.region
  account_id  = each.value.id
  email       = each.value.email

  # disable_email_notification = true

  depends_on = [aws_guardduty_organization_configuration.this]
}

Project Structure

+---.terraform
    +---providers
        +---registry.terraform.io
            +---hashicorp
                +---aws
                    +---6.3.0
                        +---windows_amd64
+---.gitignore
+---main.tf
+---outputs.tf
+---README.md
+---variables.tf
+---versions.tf

Gist

https://github.com/clalexander/vscode-hashicorp-terraform-extension-error-aws-guardduty

Anything Else?

The configuration initializes and deploys without issue.

Workarounds

No response

References

#1701

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions