cloudamqp / terraform-provider-cloudamqp

Terraform Provider for CloudAMQP
https://registry.terraform.io/providers/cloudamqp/cloudamqp
Mozilla Public License 2.0
35 stars 39 forks source link

Unable to connect new instances to the existing VPC peerlinked vpcs #89

Closed jmturwy closed 3 years ago

jmturwy commented 3 years ago

I have created a terraform-vpc-accepter rabbitmq instnace that has peerlinked enabled.

I am able to successfully dig and telnet to that instance from my VPC

When i create a new rabbitmq cluster via terraform, i need to be able to referance the VPC that already has peerlinking enabled. Entering the same CIDR results in a new VPC being created and not using the original peerlinked vpc

data "cloudamqp_vpc_info" "vpc_info" {
  instance_id = "111111"  #this is the instance id of the VPC that is already peered.
}

resource "cloudamqp_instance" "instance" {
  name          = var.name
  plan          = var.plan
  region        = var.amqp_region
  nodes         = var.nodes
  tags          = var.tags
  rmq_version   = var.rabbit_version
  vpc_subnet    = data.cloudamqp_vpc_info.vpc_info.vpc_subnet
}
andreykaipov commented 3 years ago

It seems like it works from the UI because it uses a different endpoint which accepts an extra providerid argument in the request, presumably corresponding to the VPC. Namely, something like:

curl -sL https://customer.cloudamqp.com/instance/create \
    -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:86.0) Gecko/20100101 Firefox/86.0' \
    -H 'Cookie: rack.session=redacted' \
    -d authenticity_token=redacted \
    -d name=bobby2 \
    -d plan=squirrel-1 \
    -d region=google-compute-engine::us-east4 \
    -d vpc=on \
    -d providerid=6451617f-d5d3-43bf-b14d-0a907d071b4b \
    -d subnet=10.210.64.0

Will reuse an existing VPC, and not create a new one.

This providerid argument isn't supported by the equivalent API endpoint POST https://customer.cloudamqp.com/api/instances as documented at https://docs.cloudamqp.com/, so until the API changes, it doesn't seem like any changes to this Terraform provider will help. :(

dentarg commented 3 years ago

The backend API do support this, albeit is not documented yet. I've created https://github.com/cloudamqp/terraform-provider-cloudamqp/pull/123 to add the functionality to our provider. Please take a look and let me know if you have any feedback.

dentarg commented 3 years ago

Released in https://github.com/cloudamqp/terraform-provider-cloudamqp/releases/tag/v1.12.0