dnsimple / terraform-provider-dnsimple

Terraform DNSimple provider.
https://www.terraform.io/docs/providers/dnsimple/
Mozilla Public License 2.0
21 stars 20 forks source link

Cannot set account in .tf #17

Closed jamesarosen closed 5 years ago

jamesarosen commented 5 years ago

Terraform Version

v0.12.6

Affected Resource(s)

Terraform Configuration Files

I use a module for DNS entries so I can provide the same values to multiple name servers:

# dns.tf
provider "dnsimple" {
  account "MyCompany"
  version = "~> 0.2.0"
}

module "dns_foo" {
  name = "foo.mycompany.com"
  type = "CNAME"
  value = "foo.origins.mycompany.com"
  source = "./modules/dns-entry"
}

# modules/dns-entry/variables.tf
variable "name" {}

variable "type" {
  type = string
}

variable "value" {
  type = string
}

# modules/dns-entry/main.tf
resource "dnsimple_record" "this" {
  domain = var.name
  name = var.name
  ttl = 60
  type = var.type
  value = var.value
}

resource "another_nameserver_record" "this" {
  …
}

Expected Behavior

The account attribute of the top-level dnsimple provider should carry through to the module.

Actual Behavior

Terraform emits this error:

Error: Missing required attribute

  on <input-prompt> line 1:
  (source code not available)

The attribute "account" is required, but no definition was found.

Steps to Reproduce

  1. declare a dnsimple provider at the top-level; include the account attribute
  2. declare a dnsimple_record resource in a module
  3. run terraform plan

Important Factoids

I don't experience this problem with provider.aws.region. I also use AWS resources in modules and declare the provider and some default attributes at the top-level.

If I remove account = "My Company" from the provider block, then terraform plan prompts me for it and it works.

The problem also goes away if I set the DNSIMPLE_ACCOUNT environment variable.

References

The modules docs describe how

jamesarosen commented 5 years ago

This was because I was setting account = "MyCompany" instead of account = 12345.