hashicorp / terraform-ls

Terraform Language Server
Mozilla Public License 2.0
995 stars 132 forks source link

auto_enable attribute of aws_guardduty_organization_configuration demanded #1471

Closed StorageMatt closed 9 months ago

StorageMatt commented 1 year ago

Language Server Version

I assume the latest

Terraform Version

Terraform v1.5.7 on darwin_arm64

Client Version

VSCode HashiCorp Terraform v2.28.2

Terraform Configuration

resource "aws_guardduty_organization_configuration" "org_guardduty_autoenable_ew2" {
  depends_on = [aws_guardduty_organization_admin_account.org_guardduty_admin_ew2]
  provider   = aws.sec-serv-prod-ew2

  auto_enable_organization_members = "NEW"
  detector_id                      = aws_guardduty_detector.guardduty_detector_ew2.id

  datasources {
    s3_logs {
      auto_enable = true
    }
    kubernetes {
      audit_logs {
        enable = true
      }
    }
  }
}

Steps to Reproduce

Just drop the above in VSCode with the latest version of Hashicorp Terraform and the syntax highlighter gets very grumpy - Required attribute "auto_enable" not specified: An attribute named "auto_enable" is required here

Expected Behavior

That it's completely cool with auto_enable_organization_members

Actual Behavior

It's not at all cool with auto_enable_organization_members and instead wants auto_enable = xxx which according to the docs is the deprecated style.

Gist

No response

Workarounds

Ignore it.

References

No response

Help Wanted

Community Note

radeksimko commented 1 year ago

Hi @StorageMatt The validation (and pretty much all other features) is dependent on the version of Terraform and - especially in this case - versions of providers.

I was not able to reproduce this with the latest version of the AWS provider available (5.22.0).

Screenshot 2023-10-24 at 14 20 52

Therefore - can you please find the relevant required_providers block with the aws version constraint and share it with us? Also, can you check if you ran terraform init to install the AWS provider and what version of the provider is installed based on that constraint (you can run terraform version, it will contain installed provider versions as well).

StorageMatt commented 11 months ago

Apologies for the very delayed response, I've been away from work for a while. Anyway, I've initialized again this morning and had a look and interestingly, VSC is flagging only the files in the .terragrunt-cache directory as being incorrect and when I mouse over, it's showing that it's using AWS provider v4.67.0. So fair enough that it's showing an error maybe, but I have initialized using the latest version of AWS provider (5.23.0) and all cache files confirm this. So any idea why the LS is using 4.67.0 in this context?

radeksimko commented 11 months ago

Thanks for those extra details.

Can you check what versions and constraints are being detected by the LS/extension in the panel? Screenshot 2023-11-14 at 13 51 36

Secondly, can you double check what LS version is being detected in the bottom bar?

Screenshot 2023-11-14 at 13 54 22

Lastly, can you try reloading VS Code via the command palette? Screenshot 2023-11-14 at 13 55 18

Normally, changes in .terraform (which includes installation of providers, as done by terraform init) are detected automatically. If it's not then this would suggest a bug in the detection.

github-actions[bot] commented 10 months ago

Marking this issue as stale due to inactivity over the last 30 days. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

Thank you for understanding.

github-actions[bot] commented 9 months ago

Closing this issue due to its staleness.

If the issue was automatically closed and you feel it should be reopened, we encourage creating a new one linking back to this one for added context.

Thank you!

github-actions[bot] commented 8 months 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.