Answers: <p>The problem you've encountered here is not specific to <code>terraform import</code> 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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-07-13T20:31:46.247Z
Answers: 2021-07-13T20:31:46.247Z
Answers: Martin Atkins
Body: <p>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.</p>
  <p>With a tf.address.tf.json file structured like this</p>
  <pre><code>{
      &quot;resource&quot;: {
          &quot;fortios_firewall_address&quot;: {
              &quot;11.0.0.0/8&quot;: {
                  ...
              }
          }
      }
  }
  </code></pre>
  <p>I perform the following</p>
  <p><code>$ terraform import fortios_firewall_address.11_0_0_0/8 &quot;11.0.0.0/8&quot;</code></p>
  <p>which produces the error</p>
  <pre><code>Error: Attribute name required
  │
  │   on &lt;import-address&gt; line 1:
  │    1: fortios_firewall_address.11_0_0_0/8
  │
  │ Dot must be followed by attribute name.
  </code></pre>
  <p>I suppose I need to alter the attribute name to something like &quot;ADDRESS-11_0_0_0M8&quot; but want to ask if there is another way to use the name as &quot;fortios_firewall_address.11_0_0_0/8&quot; in terrform import.</p>
  
Tags: <terraform>
Title: Terraform import and using ip address as attribute name
UserDisplayName: Chrisbot
ThreadText: # Terraform import and using ip address as attribute name
  
  (Asked by: username_0 on 2021-07-13)
  
  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.
  
  **Tags:** terraform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-13. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  