Open a7i opened 4 years ago
I have found this myself. I imported a bare metal server and found that, on my next terraform plan
terraform wanted to recreate the resource, which I do not want. Here's a gist of the diff: https://gist.github.com/scrossan/a64f4b5a437b6239fe11a1605901d608
So I added the lifecycle
block to ignore these attributes:
lifecycle {
ignore_changes = [
"extended_hardware_testing",
"ipv6_static_enabled",
"restricted_network"
]
}
My next plan didn't want to recreate the resource but did want to make some changes. Again, here's a gist of the diff: https://gist.github.com/scrossan/6a4aef13ce25e0a94b0df2eb6342602a
As @a7i shows it seems that the IBM provider did not import all of the attributes of my ibm_compute_bare_metal.server
:
$ tf state show ibm_compute_bare_metal.server
id = <redacted>
datacenter = tor01
domain = <redacted>
global_identifier = <redacted>
hostname = <redacted>
hourly_billing = false
ipv6_enabled = false
memory = 64
network_speed = 1000
notes =
os_reference_code = UBUNTU_16_64
private_ipv4_address = <redacted>
private_ipv4_address_id = <redacted>
private_network_only = false
private_vlan_id = <redacted>
public_ipv4_address = <redacted>
public_ipv4_address_id = <redacted>
public_vlan_id = <redacted>
redundant_network = true
redundant_power_supply = true
secondary_ip_addresses.# = 0
unbonded_network = false
I'm not certain if terraform would attempt to make changes to the resource if I were to run a terraform apply
, or would it simply add the attributes in my second diff to my state?
Note I am using v0.19.0 of the IBM provider.
Hit this today using 1.2.2 of the provider, terraform 0.12.20.
For the baremetal server I had in question, I just needed the default and saw that replacing null with the default values was going to recreate the resource. I managed to be fine pulling the state down, setting those null values to false and pushing up. Hopefully those attributes could just be pulled from SoftLayer APIs and added to the import list but I haven't gotten around to reading up on SL things yet.
Terraform Version
Terraform v0.11.14
Affected Resource(s)
Terraform Configuration Files
terraform import ibm_compute_bare_metal.server 792369
Debug Output
Expected Behavior
Terraform state should contain the following require properties:
Actual Behavior
Please note that I have redacted some sensitive information in form of
<redacted>
.Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform import ibm_compute_bare_metal.server 792369
)