Skip to content

fix: implement proper ImportState for organization membership resource - #7

Open
benc-vorwerk wants to merge 2 commits into
langfuse:mainfrom
benc-vorwerk:fix/membership-import-implementation
Open

fix: implement proper ImportState for organization membership resource#7
benc-vorwerk wants to merge 2 commits into
langfuse:mainfrom
benc-vorwerk:fix/membership-import-implementation

Conversation

@benc-vorwerk

Copy link
Copy Markdown

The previous ImportState implementation used PassthroughID which doesn't work for this resource since it requires organization credentials to authenticate API calls.

Changes:

  • Replace PassthroughID with custom import logic that parses the import ID format: membership_id,organization_public_key,organization_private_key
  • Validate credentials by fetching the membership from the API
  • Set all state attributes using resp.State.Set() for proper state initialization
  • Remove unused path import

Add comprehensive import tests:

  • Successful import with all fields verified
  • Invalid format with missing parts
  • Invalid format with too many parts
  • Invalid format with only two parts
  • API error handling

The previous ImportState implementation used PassthroughID which doesn't
work for this resource since it requires organization credentials to
authenticate API calls.

Changes:
- Replace PassthroughID with custom import logic that parses the import
  ID format: membership_id,organization_public_key,organization_private_key
- Validate credentials by fetching the membership from the API
- Set all state attributes using resp.State.Set() for proper state
  initialization
- Remove unused path import

Add comprehensive import tests:
- Successful import with all fields verified
- Invalid format with missing parts
- Invalid format with too many parts
- Invalid format with only two parts
- API error handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jan 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Steffen911 Steffen911 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you a lot! The overall change seems reasonable. @pkalemba Could you also take a look since the initial PR came from your end?

Comment on lines +381 to +382
orgPublicKey := importParts[1]
orgPrivateKey := importParts[2]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benc-vorwerk Do you know whether this implies that the organization private key gets added into the state in clear text? Ideally, we should consider or keep it a secret.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Steffen911 yes, with the current schema/import implementation the org private key will be persisted in Terraform state (Sensitive only redacts display).

separately, passing it via the CLI import ID is also not ideal due to shell history/logging. I can update docs to recommend import blocks with variables, and we can discuss a bigger refactor (e.g., provider-level org credentials / aliases) if we want to keep secrets out of state entirely.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello @Steffen911, do you want me to add documentation for all resources here or refactor it to support organization as provider? similar to what databricks terraform does with separate provider for account and workspaces.

…ider

- Introduced multi-organization management example with provider aliases.
- Implemented organization-level credentials to reduce redundancy in resource definitions.
- Updated resources to resolve organization credentials using a fallback mechanism.
- Enhanced import functionality to support both new and legacy formats for organization credentials.
- Added comprehensive documentation for usage, best practices, and examples.
- Modified existing resources to utilize organization-level credentials where applicable.
@benc-vorwerk

Copy link
Copy Markdown
Author

@Steffen911 I refactored this to maintain backward compatibility by using the organization as the provider when creating projects and assigning memberships.

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.

3 participants