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

Consul service resources need ID attribute #8799

Closed
cbarbour opened this issue Sep 12, 2016 · 6 comments
Closed

Consul service resources need ID attribute #8799

cbarbour opened this issue Sep 12, 2016 · 6 comments
Labels
bug provider/consul waiting-response An issue/pull request is waiting for a response from the community

Comments

@cbarbour
Copy link

Terraform Version

0.7.3

Affected Resource(s)

  • consul_service
  • consul_agent_service

Terraform Configuration Files

provider "consul" {
    address = "127.0.0.1:6500"
    datacenter = "local"
}

variable "web_ports" {
  address = "127.0.0.1"
  default = [ 80, 8080 ]
  type = "list"
}

resource "consul_service" "web" {
    name = "web"
    port = ${var.web_ports[count.index]}
}

Expected Behavior

Two services named web should have been registered with Consul.

Actual Behavior

ID collision prevents a single node from registering more than one service with a given name.

Steps to Reproduce

  1. terraform apply
  2. terraform plan
@cbarbour
Copy link
Author

I was able to work around the issue completely by using a consul_catalog_entry resource instead of a consul_service resource.

This would be the resulting code:

provider "consul" {
    address = "127.0.0.1:6500"
    datacenter = "local"
}

variable "web_ports" {
  address = "127.0.0.1"
  default = [ 80, 8080 ]
  type = "list"
}

resource "consul_catalog_entry" "web" {
  count = "${length(web_ports)}"
  address = "${aws_instance.web.private_ip}"
  name = "${element(split(".", aws_instance.web.private_dns"), 0)}"
  service = {
    id = "web${count.index}"
    name = "web"
    port = "${web_ports[count.index]}"
}

@cbarbour
Copy link
Author

I also looked into submitting a PR for the original request, but it seems like it was beyond my level of go knowledge (practically nothing past go template.)

From what I could gather, we would need to add logic to query all services with the appropriate node, name, etc. criteria, and parse through them to find the instance of the service matching the resource in our catalog.

Actually inserting an ID is easy enough, but simply throwing the ID at consul caused terraform plan/execution diff errors when I tried it.

@stack72
Copy link
Contributor

stack72 commented Oct 31, 2016

Hi @cbarbour

I believe this was fixed via #9366

Thoughts?

Paul

@stack72 stack72 added the waiting-response An issue/pull request is waiting for a response from the community label Oct 31, 2016
@cbarbour
Copy link
Author

@stack72

Hi Paul,

From a quick review, it looks like it would completely solve my issue. Unfortunately, I am not able to test; I ran into a lot of problems with the Consul provider and had to implement a solution using .json configured services and a Terraform file provisioner.

Regards,
Chris Barbour

@stack72
Copy link
Contributor

stack72 commented Oct 31, 2016

No worries - I'll close this out and if you come back to it then we can reopen it if it doesn't

Thanks for getting back in touch

Paul

@stack72 stack72 closed this as completed Nov 2, 2016
@ghost
Copy link

ghost commented Apr 20, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug provider/consul waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

No branches or pull requests

3 participants