-
Notifications
You must be signed in to change notification settings - Fork 57
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
INVS-2397-cse-log-mapping-import-fix #675
Conversation
@@ -351,11 +352,17 @@ func resourceToCSELogMappingField(data interface{}) CSELogMappingField { | |||
field.SkippedValues = resourceStringArrayToStringArray(fieldObj["skipped_values"].([]interface{})) | |||
field.DefaultValue = fieldObj["default_value"].(string) | |||
field.Format = fieldObj["format"].(string) | |||
field.CaseInsensitive = fieldObj["case_insensitive"].(bool) | |||
caseInsensitive := fieldObj["case_insensitive"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also safeguarding here for bool
|
||
splitIndex, err := strconv.Atoi(t.SplitIndex) | ||
if err == nil { | ||
mapping["split_index"] = splitIndex | ||
} | ||
|
||
f = append(f, mapping) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what fixed the import functionality
tested using pointing to cse-stag-alpha
generated_resources.tf
|
Addresses: https://sumologic.atlassian.net/browse/INVS-2397
slack conv: https://sumologic.slack.com/archives/CAU3N0Y92/p1721397319790159
when using
terraform plan -generate-config-out="main.tf"
produced cse_log_mappings resources are missing required fieldfields
was able to reproduce in local test:
was a little hard to find the root cause since there was no error or exception in log.
TLDR:
there is a discrepancy in field
splitIndex
type definition between API(string
) and resource in terraform provider(int
), sosetFields
function inresource_sumologic_cse_log_mappings.go
was silently failing for log mappings having splitIndex as null ( was expecting there a more evident error ¯_(ツ)_/¯ )while tackling this, spot also couple discrepancies on "required" fields in
sumologic_cse_log_mapping.go
vs CSE API (https://api.sumologic.com/docs/sec/#operation/GetLogMapping), so also taking care of them.