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

Aws organizations organizationalunit idempotency #92

Conversation

ramsriu
Copy link
Contributor

@ramsriu ramsriu commented Jan 8, 2025

Title: Implement idempotency for OrganizationalUnit creation in CreateHandler

Description:
This pull request implements idempotency for OrganizationalUnit creation in the CreateHandler. The changes ensure that attempting to create an OrganizationalUnit that already exists results in an appropriate error response rather than attempting to create a duplicate OrganizationalUnit.

Key Changes:

Modified CreateHandler to check for existing OrganizationalUnits before attempting creation.
Implemented a new checkIfOrganizationalUnitExists method to perform the existence check.
Updated handleRequest method to return an AlreadyExists error when an OrganizationalUnit with the same name is found under the same parent.
Updated CallbackContext to track the pre-existence check and OrganizationalUnit creation status.
Refactored unit tests to align with the new idempotent behavior.
Specific Updates:

In CreateHandler:

Added checkIfOrganizationalUnitExists method to query existing OrganizationalUnits.
Updated handleRequest to use checkIfOrganizationalUnitExists and handle already existing OrganizationalUnits.
Modified error handling to return appropriate error codes and messages.
In CreateHandlerTest:

Updated existing test cases to account for the new idempotency check.
Added new test cases:
handleRequest_OrganizationalUnitAlreadyExists
handleRequest_OrganizationalUnitDoesNotExist
Modified other affected test cases to align with the new behavior.
In CallbackContext:

Added isPreExistenceCheckComplete and isDidResourceAlreadyExist flags.
Testing:

All existing unit tests have been updated and pass.
New unit tests have been added to cover the idempotency scenarios.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ramsriu ramsriu closed this Jan 8, 2025
@ramsriu ramsriu deleted the aws-organizations-organizationalunit-idempotency branch January 9, 2025 01:18
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.

1 participant