VSCode: Flagging azuread_service_principal resource as missing required attribute application_id

In my main.tf:

azuread = {
  source  = "hashicorp/azuread"
  version = "~> 2.45"

resource “azuread_service_principal” “this” {
client_id = azuread_application.this.application_id
preferred_single_sign_on_mode = “saml”
notification_email_addresses = var.application.notification_email_addresses
owners = [var.azuread_client_config.object_id]
feature_tags {
custom_single_sign_on = true
enterprise = true
saml_single_sign_on {}

It gets flagged in the editor with
“Required attribute “application_id” not specified: An attribute named “application_id” is required here”

application_id is not a required argument in the azuread_service_principal in v2.45 and I don’t get an error if I run terraform validate.

Is this an extension issue or environment? I made sure the extension and terraform are up to date.

Hi @jdholbrook!

Thanks for the report. The language server bundles ~250 provider schemas to provide a helpful out-of-the-box experience. The bundled azuread schema in the current terraform-ls release is v2.43.0, which still contains the application_id. This would explain the discrepancy.

However, when we detect a local provider installation, we use this schema to be more accurate. So, if you run terraform init in your configuration, the editor should use the latest local schema.

Let me know if that works for you.

1 Like

Thank you! I primarily run terraform commands in a workflow as opposed to locally so this was helpful. I did need to provide the optional “-upgrade” flag to terraform to use v2.45. After doing so my editor is clear of errors.

For reference:

│ Error: Failed to query available provider packages

│ Could not retrieve the list of available versions for provider hashicorp/azuread: locked provider Terraform Registry 2.44.1 does not match configured version constraint ~> 2.45; must use
│ terraform init -upgrade to allow selection of new versions