Terraform “set of string required.” error fix : Thomas Thornton

Terraform “set of string required.” error fix
by: Thomas Thornton
blow post content copied from  Thomas Thornton – Microsoft Azure MVP – HashiCorp Ambassador
click here to view original post


Quick blog post on how to fix Terraform error “set of string required.” error. If you’re working with Terraform, you may encounter an error message that says “set of string required.” This error occurs when you’re trying to pass a variable that is not in the correct format.

Here’s an example of what the error message might look like:

resource "azuread_application" "azuread_application" {
  display_name = "tamops"

  group_membership_claims = "All"

  owners = [var.app_service_object_id]
}

Snippet of error regarding the above:

Error: Incorrect attribute value type

  on ../../modules/service_principal/service_principal.tf line 9, in resource "azuread_application" "azuread_application":
   9:   group_membership_claims = "All"

Inappropriate value for attribute "group_membership_claims": set of string
required.
Error: Process completed with exit code 1.

This error message is telling us that the "all" value we’re passing to group_membership_claims is not in the correct format. In this case, group_membership_claims is expecting a set of strings, but we’re passing it a single string value.

To fix this error, we need to make sure that group_membership_claims is in the correct format. Here’s an example of how to define a set of strings in Terraform:

resource "azuread_application" "azuread_application" {
  display_name = "tamops"

  group_membership_claims = ["All"]

  owners = [var.app_service_object_id]
}

Notice the change to the above? Highlight is now being passed in as [“All”], this is now passing the value in as a set of strings.

A quick blog post, hopefully this will assist you.


July 26, 2023 at 07:14PM
Click here for more details...

=============================
The original post is available in Thomas Thornton – Microsoft Azure MVP – HashiCorp Ambassador by Thomas Thornton
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce