terraform-provider-sumologic
terraform-provider-sumologic copied to clipboard
Unable to import existing data forwarding rules
Terraform Version
% terraform --version
Terraform v1.9.2
on darwin_arm64
+ provider registry.terraform.io/sumologic/sumologic v2.31.5
Affected Resource(s)
sumologic_data_forwarding_rule
Terraform Configuration Files
import {
to = sumologic_data_forwarding_rule.test_rule
id = "[rule id]"
}
resource "sumologic_data_forwarding_rule" "test_rule" {
index_id = partition.id
destination_id = destination.id
enabled = true
payload_schema = "builtInFields"
format = "csv"
}
I am unable to import my existing configuration. I am able to pull down the ID from the API of this rule.
>>> r = requests.get(f'{base_url}/logsDataForwarding/rules', auth=auth)
>>> for x in r.json()['data']:
... if x['bucket']['destinationName'] == 'MY-DESTINATION-NAME':
... print(x['id'])
...
[rule id]
Debug Output
│ Error: Cannot import non-existent remote object
│
│ While attempting to import an existing object to "sumologic_data_forwarding_rule.test_rule", the
│ provider detected that no object exists with the given id. Only pre-existing objects can be
│ imported; check that the id is correct and that it is associated with the provider's configured
│ region or endpoint, or use "terraform apply" to create a new remote object for this resource.
Expected Behavior
I should be able to import data forwarding rules into terraform
Actual Behavior
Plan fails as its unable to find the id
Steps to Reproduce
- Create a data forwarding rule.
- Attempt to import it into terraform
It looks like you aren't supporting id's for rules? https://github.com/SumoLogic/terraform-provider-sumologic/blob/7e8b376599ba9b23733aa3b0701de0f22fd06491/sumologic/resource_sumologic_data_forwarding_rule.go#L156-L164
This issue was identified in a PR which was not merged here
It looks like it was "resovled" in this review comment https://github.com/SumoLogic/terraform-provider-sumologic/pull/688#discussion_r1766787650 & https://github.com/SumoLogic/terraform-provider-sumologic/pull/688#discussion_r1766796151 but I don't believe this is correct. based on being unable to import a rule.
Internal jira SUMO-250676