Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data lookup by ID #11457

Open
2 tasks done
Tbohunek opened this issue Apr 24, 2021 · 0 comments
Open
2 tasks done

Data lookup by ID #11457

Tbohunek opened this issue Apr 24, 2021 · 0 comments

Comments

@Tbohunek
Copy link
Contributor

Tbohunek commented Apr 24, 2021

Community Note

  • Better click 👍 than comment +1

Description

Allow to look up data by id to:

  • reduce the number of variables explicitly passed into a module like name, location, tags,..
  • solve dependency issues when the resource used for data doesn't exist yet.

New or Affected Resource(s)

  • All data resources for azurerm and azuread
  • Potentially all of Terraform data providers

Potential Terraform Configuration

# ROOT MODULE
resource "azurerm_policy_set_definition" "policy" {
  name = "my_policy"
  ...
}

module "child_1_module"{
  source    = "./child"
  policy_id = azurerm_policy_set_definition.policy.id
}
# CHILD MODULE
variable "policy_id" {}
data "azurerm_policy_set_definition" "policy" {
  id = var.policy_id
}
resource "azurerm_policy_assignment" "policy_scope" {
  name                 = "${data.azurerm_policy_set_definition.policy.name}_scope"
  display_name         = "${data.azurerm_policy_set_definition.policy.display_name} Scope"
  scope                = var.scope
  policy_definition_id = data.azurerm_policy_set_definition.policy.id
  ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants