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

Ramsriu aws organizations policy #88

Conversation

ramsriu
Copy link
Contributor

@ramsriu ramsriu commented Jan 1, 2025

Title: Implement idempotency for policy creation in CreateHandler

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

Key Changes:

  1. Modified CreateHandler to check for existing policies before attempting creation.
  2. Updated handleRequest method to return an AlreadyExists error when a policy with the same name is found.
  3. Implemented a new checkIfPolicyExists method to perform the existence check.
  4. Updated CallbackContext to track the pre-existence check and policy creation status.
  5. Refactored unit tests to align with the new idempotent behavior.

Specific Updates:

  • In CreateHandler:

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

    • Updated test cases to verify idempotent behavior.
    • Added new test case for policy already exists scenario.
    • Modified existing test cases to account for the new flow.
  • In CallbackContext:

    • Added isPreExistenceCheckComplete and isDidResourceAlreadyExist flags.

These changes improve the robustness of the CreateHandler by preventing duplicate policy creation and providing clear feedback when a policy already exists. The implementation maintains backwards compatibility while enhancing the overall functionality of the resource provider.

Testing:

  • All existing unit tests have been updated and pass.
  • New unit tests have been added to cover the idempotency scenarios.
  • Manual testing has been performed to ensure correct behavior in various scenarios.

@ramsriu ramsriu closed this Jan 2, 2025
@ramsriu ramsriu deleted the ramsriu_aws-organizations-policy 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