Skip to content

Unable to import existing data forwarding rules #701

@eambrosyupgrade

Description

@eambrosyupgrade

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?

func resourceToDataForwardingRule(d *schema.ResourceData) DataForwardingRule {
return DataForwardingRule{
IndexId: d.Get("index_id").(string),
DestinationId: d.Get("destination_id").(string),
Enabled: d.Get("enabled").(bool),
FileFormat: d.Get("file_format").(string),
PayloadSchema: d.Get("payload_schema").(string),
Format: d.Get("format").(string),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions