Skip to content

fix(aws-external-id): correct schema, resource ID, and nil safety#131

Open
ryanmat wants to merge 2 commits into
logicmonitor:masterfrom
ryanmat:fix/aws-external-id-data-source
Open

fix(aws-external-id): correct schema, resource ID, and nil safety#131
ryanmat wants to merge 2 commits into
logicmonitor:masterfrom
ryanmat:fix/aws-external-id-data-source

Conversation

@ryanmat
Copy link
Copy Markdown

@ryanmat ryanmat commented Apr 2, 2026

Summary

  • Change external_id and created_at fields from Optional to Computed since they are read-only API outputs, not user inputs
  • Use the API-returned ExternalID UUID as the resource ID instead of time.Now().Unix() which caused state churn on every read
  • Add nil check on GetPayload() response to prevent nil pointer panic when API returns empty body

Fixes #44

Files Changed

  • logicmonitor/schemata/aws_external_id_schema.go — schema fields, SetId fix, import cleanup
  • logicmonitor/resources/data_resource_aws_external_id_resource.go — nil check on API response
  • logicmonitor/schemata/aws_external_id_schema_test.go — unit tests (5 tests)

Testing

  • Unit tests: go test ./logicmonitor/schemata/ -run Aws -v (5/5 pass)
  • Live portal validation: tested against a live LogicMonitor portal (lmryanmatuszewski) using Terraform 1.14.8
    • data.logicmonitor_data_resource_aws_external_id returns Computed fields (external_id, created_at) correctly
    • Resource ID is now the ExternalID UUID (e.g., 6a04d839-5cce-4eef-a38a-8f3b5b2048c9), not a Unix timestamp
    • terraform plan shows 0 changes after apply

Note on upstream API behavior

The LM GET /aws/externalId endpoint is generative — each call creates a new UUID. This is an API-side issue, not fixable in the provider. The provider-side fix eliminates the state churn caused by timestamp-based IDs and makes the data source usable for single-apply workflows.

ryanmat added 2 commits April 2, 2026 01:10
- Change external_id and created_at fields from Optional to Computed
  since they are read-only API outputs, not user inputs
- Use the API-returned ExternalID as the resource ID instead of
  time.Now().Unix() which caused state churn on every read
- Add nil check on GetPayload() response to prevent nil pointer
  panic when API returns empty body (fixes logicmonitor#44)
- Verify schema fields are Computed (not Optional)
- Verify SetId uses ExternalID UUID (not timestamp)
- Verify resource ID is stable across repeated calls
- Verify SubResourceData handles nil input gracefully
- Verify SubResourceData populates fields correctly
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

Successfully merging this pull request may close these issues.

Plugin Crashes

1 participant