fix(aws-external-id): correct schema, resource ID, and nil safety#131
Open
ryanmat wants to merge 2 commits into
Open
fix(aws-external-id): correct schema, resource ID, and nil safety#131ryanmat wants to merge 2 commits into
ryanmat wants to merge 2 commits into
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
external_idandcreated_atfields fromOptionaltoComputedsince they are read-only API outputs, not user inputsExternalIDUUID as the resource ID instead oftime.Now().Unix()which caused state churn on every readGetPayload()response to prevent nil pointer panic when API returns empty bodyFixes #44
Files Changed
logicmonitor/schemata/aws_external_id_schema.go— schema fields, SetId fix, import cleanuplogicmonitor/resources/data_resource_aws_external_id_resource.go— nil check on API responselogicmonitor/schemata/aws_external_id_schema_test.go— unit tests (5 tests)Testing
go test ./logicmonitor/schemata/ -run Aws -v(5/5 pass)lmryanmatuszewski) using Terraform 1.14.8data.logicmonitor_data_resource_aws_external_idreturns Computed fields (external_id,created_at) correctly6a04d839-5cce-4eef-a38a-8f3b5b2048c9), not a Unix timestampterraform planshows 0 changes after applyNote on upstream API behavior
The LM
GET /aws/externalIdendpoint 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.