Hi all, new to the slack channel but have been usi...
# office-hours
a
Hi all, new to the slack channel but have been using cloudposse terraform modules for a bit. I'm looking to start incorporating the context provider (https://github.com/cloudposse/terraform-provider-context?tab=readme-ov-file). I'm trying to do some simple experiments before I build out a PoC and wondering what i'm doing wrong to add additional tags.
Copy code
provider "context" {
  delimiter = "-"
  enabled   = true
  properties = {
    environment = {}
    name        = {}
    org         = {}
    region      = {}
    type        = {}
  }

  property_order = [
    "org",
    "region",
    "environment",
    "type",
    "name",
  ]

  # Default values, can be overridden in the data sources
  values =  {
    "org" = "evh"
    "region" = "ue2"
    "environment" = "prod"
    "type" = "vpc"
    "name" = "main"
  }

}

data "context_tags" "this" {
    values = {
        "managed_by"  = "terraform"
    }
}
this 1
I'm noticing when i do this, it doesn't add the
managed_by
tag
Copy code
> data.context_tags.this.tags
tomap({
  "Environment" = "sand"
  "Name" = "main"
  "Org" = "evh"
  "Region" = "ue2"
  "Type" = "vpc"
})
m
Hey! I don’t use the cloudposse modules that much so I’ve never used the context provider…talk that into consideration with my repsonse. 😅 but having used terraform for a while, my understanding is that
data
resources are read only. I though they were only used to bring data into a workspace. So attempting to update a
data
resource may be allowed (looks like it compiled for you), but I don’t think you can modify it. 🤔 from the TF docs:
Data sources allow Terraform to use information defined outside of Terraform, defined by another separate Terraform configuration, or modified by functions.
do the cloudposse docs say something different? specifically, that the
context_tags
data resource can be modified?
I think this is a better definition from the TF docs:
The
data
block creates a data instance of the given type (first block label) and name (second block label). The combination of the type and name must be unique.
Within the block (the
{ }
) is configuration for the data instance. The configuration is dependent on the type; as with resources, each provider on the Terraform Registry has its own documentation for configuring and using the data types it provides.
Each data instance will export one or more attributes, which can be used in other resources as reference expressions of the form
data.<TYPE>.<NAME>.<ATTRIBUTE>
a
I see your point, the docs on the provider are pretty sparse
it did say this:
Copy code
values (Map of String) Map of values to override or add to the context when creating the label.
but it clearly isn't doing that like you say, it's terraform at the end of the day.
e
cc @Matt Calhoun - let's discuss today
We discussed on office hours today
Checkout the recording