Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Interpolation fails for computed lists on mailgun_domain #1

Closed
3 tasks done
hashibot opened this issue Jun 13, 2017 · 0 comments
Closed
3 tasks done

Interpolation fails for computed lists on mailgun_domain #1

hashibot opened this issue Jun 13, 2017 · 0 comments
Labels

Comments

@hashibot
Copy link

This issue was originally opened by @steve-jansen as hashicorp/terraform#5367. It was migrated here as part of the provider split. The original body of the issue is below.


Possibly related to hashicorp/terraform#2157.

The maingun_domain receiving_records and sending_records TypeLists cannot be used with interpolation functions like length().

Steps to reproduce:

variable "mailgun_api_key" {
    type = "string"
}

provider "aws" {
    region = "us-east-1"
}

provider "mailgun" {
    api_key = "${var.mailgun_api_key}"
}

resource "mailgun_domain" "main" {
    name = "test.example.com"
    spam_action = "disabled"
    smtp_password = "foobar"
}

resource "aws_route53_zone" "main" {
   name = "example.com"
}

resource "aws_route53_record" "main" {
     zone_id = "${aws_route53_zone.main.zone_id}"
     name = "${mailgun_domain.main.name}"
     type = "${element(mailgun_domain.main.receiving_records.*.record_type, count.index)}"
     ttl = "300"
     count = "${length(mailgun_domain.main.receiving_records)}"
     records = [
         "${element(mailgun_domain.main.receiving_records.*.priority, count.index)} ${element(mailgun_domain.main.receiving_records.*.value, count.index)}"
    ]
}

Results in a plan error:

$ terraform -version
Terraform v0.6.12
$ terraform plan -var mailgun_api_key=${MAILGUN_API_KEY}
There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Errors:

  * 1 error(s) occurred:

* module root: 1 error(s) occurred:

* aws_route53_record.main: resource count can't reference resource variable: mailgun_domain.main.receiving_records

The Hashicorp blog article "Deploying Discourse with Terraform" by @pearkes notably does not use length(), but, instead assumes mailgun will reply with 2 receiving domains and 3 sending domains. Admittedly, this approach could be due to the age of the article (Terraform 0.2 days), or it could be due to this limitation with interpolation against a list of maps.

  • Test against latest release
  • Search for possible duplicate reports
  • Include steps to reproduce
@hashibot hashibot added the bug label Jun 13, 2017
@wgebis wgebis closed this as completed Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants