Skip to content

Missing resource (404) causes Terraform to fail #133

@ithinkisam

Description

@ithinkisam

If you create a resource via the provider, then manually delete that resource via the LogicMonitor portal, the next run of a terraform plan fails due to "unexpected" 404 errors.

What I would expect to happen is that Terraform state is updated to match the state in the tenant (by removing the resource from state). A 404 is not unexpected in this scenario, it is indicative of a change that happened elsewhere that should be reconciled.


In this scenario, I set up the two account device groups incorrectly and opted to delete them manually to have TF recreate them. I had low expectations of the provider being able to handle the conversion from a "Normal" group to an "AWS" group and thought this would be easier. Turns out I was wrong.

logicmonitor_device_group.aws: Refreshing state... [id=1238]
logicmonitor_device_group.aws_test_us: Refreshing state... [id=1239]
logicmonitor_device_group.aws_test_us_accounts["bar"]: Refreshing state... [id=1240]
logicmonitor_device_group.aws_test_us_accounts["foo"]: Refreshing state... [id=1241]


│ Error: unexpected: [GET /device/groups/{id}][404] getDeviceGroupById default  &{ErrorCode:1404 ErrorDetail:<nil> ErrorMessage:The hostgroup ID <1240> is not found.}
│ Error: unexpected: [GET /device/groups/{id}][404] getDeviceGroupById default  &{ErrorCode:1404 ErrorDetail:<nil> ErrorMessage:The hostgroup ID <1241> is not found.}

Error: Terraform exited with code 1.
Error: Process completed with exit code 1.

I'm only experimenting at this point, but I needed to delete the state files completely in order to move forward since the provider was unable to handle the now missing device groups.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions