Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create sumologic_content resource using file function #127

Closed
uridium opened this issue Dec 14, 2020 · 1 comment
Closed

Can't create sumologic_content resource using file function #127

uridium opened this issue Dec 14, 2020 · 1 comment

Comments

@uridium
Copy link

uridium commented Dec 14, 2020

When I'm trying to create a content using file() function, I'm getting an error:

$ terraform apply -auto-approve
sumologic_folder.this: Refreshing state... [id=0000000001230571]
sumologic_content.this: Creating...

Error: {"id":"RADAY-7WDCD-QJ601","errors":[{"code":"service.argument.invalid","message":"The request body you've provided is invalid. Could not resolve type 'null' as a subtype of 'ContentSyncDefinition'"}]}

  on main.tf line 9, in resource "sumologic_content" "this":
   9: resource "sumologic_content" "this" {
$ cat main.tf
data "sumologic_personal_folder" "this" {}

resource "sumologic_folder" "this" {
  parent_id   = data.sumologic_personal_folder.this.id
  name        = "JenkinsErrors"
  description = "Jenkins build errors"
}

resource "sumologic_content" "this" {
    parent_id = sumologic_folder.this.id
    config = jsonencode(file("${path.module}/data.json"))
}
$ cat data.json
{
    "type": "SavedSearchWithScheduleSyncDefinition",
    "name": "some-query",
    "search": {
        "queryText": "\"some query\"",
        "defaultTimeRange": "-15m",
        "byReceiptTime": false,
        "viewName": "",
        "viewStartTime": "1970-01-01T00:00:00Z",
        "queryParameters": [],
        "parsingMode": "Manual"
    },
    "searchSchedule": {
        "cronExpression": "17 * * * * ? *",
        "displayableTimeRange": "-5m",
        "parseableTimeRange": {
            "type": "BeginBoundedTimeRange",
            "from": {
                "type": "RelativeTimeRangeBoundary",
                "relativeTime": "-5m"
            },
            "to": null
        },
        "timeZone": "Etc/UTC",
        "threshold": {
            "thresholdType": "group",
            "operator": "gt",
            "count": 0
        },
        "notification": {
            "taskType": "WebhookSearchNotificationSyncDefinition",
            "webhookId": "0000000000015290",
            "payload": null,
            "itemizeAlerts": true,
            "maxItemizedAlerts": 50
        },
        "scheduleType": "RealTime",
        "muteErrorEmails": false,
        "parameters": []
    },
    "description": ""
}

But when I keep the entire json in main.tf file, everything works fine:

$ terraform apply -auto-approve
sumologic_folder.this: Refreshing state... [id=0000000001230571]
sumologic_content.this: Creating...
sumologic_content.this: Creation complete after 4s [id=0000000001226A9B]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
data "sumologic_personal_folder" "this" {}

resource "sumologic_folder" "this" {
  parent_id   = data.sumologic_personal_folder.this.id
  name        = "JenkinsErrors"
  description = "Jenkins build errors"
}

resource "sumologic_content" "this" {
    parent_id = sumologic_folder.this.id
    config = jsonencode(
    {
        "type": "SavedSearchWithScheduleSyncDefinition",
        "name": "some-query",
        "search": {
            "queryText": "\"some query\"",
            "defaultTimeRange": "-15m",
            "byReceiptTime": false,
            "viewName": "",
            "viewStartTime": "1970-01-01T00:00:00Z",
            "queryParameters": [],
            "parsingMode": "Manual"
        },
        "searchSchedule": {
            "cronExpression": "17 * * * * ? *",
            "displayableTimeRange": "-5m",
            "parseableTimeRange": {
                "type": "BeginBoundedTimeRange",
                "from": {
                    "type": "RelativeTimeRangeBoundary",
                    "relativeTime": "-5m"
                },
                "to": null
            },
            "timeZone": "Etc/UTC",
            "threshold": {
                "thresholdType": "group",
                "operator": "gt",
                "count": 0
            },
            "notification": {
                "taskType": "WebhookSearchNotificationSyncDefinition",
                "webhookId": "0000000000015292",
                "payload": null,
                "itemizeAlerts": true,
                "maxItemizedAlerts": 50
            },
            "scheduleType": "RealTime",
            "muteErrorEmails": false,
            "parameters": []
        },
        "description": ""
    }
    )
}

terraform 0.14.2
sumologic 2.6.0

@mccartney
Copy link
Collaborator

Why would you use jsencode with file?
Isn't just file() enough?

@uridium uridium closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants