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

Support namespace and meta in consul_config_entry #246

Closed
brucec5 opened this issue Mar 17, 2021 · 3 comments · Fixed by #256
Closed

Support namespace and meta in consul_config_entry #246

brucec5 opened this issue Mar 17, 2021 · 3 comments · Fixed by #256

Comments

@brucec5
Copy link

brucec5 commented Mar 17, 2021

Terraform Version

Terraform v0.14.8
+ provider registry.terraform.io/hashicorp/consul v2.11.0
+ provider registry.terraform.io/hashicorp/external v2.1.0

Affected Resource(s)

  • consul_config_entry

Terraform Configuration Files

terraform {
  required_providers {
    consul = {
      source = "hashicorp/consul"
      version = "2.11.0"
    }
  }
}

provider "consul" {}

resource "consul_namespace" "example_namespace" {
  name = "example"
  description = "Example namespace"
}

resource "consul_config_entry" "test_intentions" {
  kind = "service-intentions"
  name = "destination-service"
  namespace = consul_namespace.example_namespace.name

  config_json = jsonencode({
    Sources = [
      {
        Action = "allow"
        Name = "source-service"
      }
    ]
  })
}

Expected Behavior

Per the docs, it appears that all config entry kinds should support a namespace param. In my use-case, it is especially important for service-intentions to support this, but other config entries should support it too.

Relatedly, it looks like meta isn't supported either, despite being a parameter for all config entry kinds.

I'm able to write the same service intention directly via consul config write:

Kind = "service-intentions"
Name = "destination-service"
Namespace = "example"

Sources = [
  {
    Action = "allow"
    Name = "source-service"
  }
]

Actual Behavior

Error: Unsupported argument

  on main.tf line 20, in resource "consul_config_entry" "test_intentions":
  20:   namespace = "example"

An argument named "namespace" is not expected here.

Steps to Reproduce

  1. Boot up a consul enterprise agent locally via consul agent -dev (consul version 1.9.4+ent)
  2. terraform apply

Important Factoids

As mentioned above, I'm using consul 1.9.4+ent

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@fabio-grassi-gbs
Copy link

We are feeling this as a serious gap and hope it is easy as it looks to fix it as we would badly need to create config entry into namespaces.

remilapeyre added a commit to remilapeyre/terraform-provider-consul that referenced this issue May 9, 2021
@remilapeyre
Copy link
Collaborator

Hi @brucec5 and @fabio-grassi-gbs, sorry for the time it took me to take care of this issue, #256 should do what you are looking for. I will make a new release of the provider shortly.

Here's how you should be able to set a namespace and use the meta parameter:

resource "consul_namespace" "example_namespace" {
  name = "example"
  description = "Example namespace"
}

resource "consul_config_entry" "test_intentions" {
  kind = "service-intentions"
  name = "destination-service"
  namespace = consul_namespace.example_namespace.name

  config_json = jsonencode({
    Sources = [
      {
        Action = "allow"
        Name = "source-service"
      }
    ]
    Meta = {
        foo = "bar"
    }
  })
}

The consul_config_entry resource is a bit weird as the schema cannot be expressed nicely with the Terraform SDK v1. I will finally remove the support for Terraform 0.11 and should be able to improve it then.

@fabio-grassi-gbs
Copy link

fabio-grassi-gbs commented May 9, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants