0

I am building terrform.tfstate files from Terraform managed Fortigate devices. After producing output JSON files using Terraform output and a custom script to produce tf.address.tf.json, I wish to import the objects using the attribute name as outputted if possible.

With a tf.address.tf.json file structured like this

{
    "resource": {
        "fortios_firewall_address": {
            "11.0.0.0/8": {
                ...
            }
        }
    }
}

I perform the following

$ terraform import fortios_firewall_address.11_0_0_0/8 "11.0.0.0/8"

which produces the error

Error: Attribute name required
│
│   on <import-address> line 1:
│    1: fortios_firewall_address.11_0_0_0/8
│
│ Dot must be followed by attribute name.

I suppose I need to alter the attribute name to something like "ADDRESS-11_0_0_0M8" but want to ask if there is another way to use the name as "fortios_firewall_address.11_0_0_0/8" in terrform import.

1

The problem you've encountered here is not specific to terraform import but rather a general Terraform language rule: the name of a resource must be a valid identifier, and valid identifiers can start only with letters and underscores, not with digits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.