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

feat(site launch): Allow for ops to remove timed out domain associations #720

Conversation

kishore03109
Copy link
Contributor

@kishore03109 kishore03109 commented Apr 20, 2023

Problem

If we try to associate the same domain twice, Amplify will generally throw a BadRequestException: One or more domains requested are already associated with another Amplify app, which can inform the user to delete + retry.

However, this did not hold true if the domain association process timed out, in which case Amplify did not throw an error, and neither did it create a new Domain Association during the CreateDomainAssociation call.

To replicate the bug, this sequence of errors would need to happen:

  1. Submit the form for blah.gov.sg for blah-test app.
  2. Receive an email for the DNS Results
  3. Wait for 24 hours for domain association to time out
  4. Retry step 1
  5. Receive an email with the exact same DNS results as step 2.
    One would think that the email received in step 5 is the most recent values, but it is in fact a lingering DomainAssociation that has yet to be deleted.

Closes IS93

Solution

Before calling a CreateDomainAssociation, delete any failed domain associations for the application.

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible

Testing

While I have tested it manually on the kishore-test app, it is a bit hard to easily replicate this test this as it requires the existence of an App timeout over 24 hours. :/

@kishore03109 kishore03109 changed the title Is 93 ensure site launch form can handle failures or it requires manual deletes from amplify db feat(site launch): Allow for ops to remove timed out domain associations Apr 20, 2023
) {
if (!this.mockDomainAssociations.has(input.domainName)) {
throw new AmplifyError(
`NotFoundException: Domain association ${input.domainName} not found.`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This mocks the behaviour of the real amplify client and throws an exception if domain hasnt been created yet

getDomainAssociationCommandInput
)
const hasDomainAssociationFailed =
getDomainAssociationResult?.domainAssociation?.domainStatus === "FAILED"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refer here for types of domain association result

@@ -159,6 +161,41 @@ export class LaunchesService {
throw siteIdResult.error
}

try {
Copy link
Contributor Author

@kishore03109 kishore03109 Apr 20, 2023

Choose a reason for hiding this comment

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

Wrapped in a try catch since AmplifySDK will throw an (expected) not found error, which is still the happy path

@kishore03109 kishore03109 requested a review from a team April 20, 2023 01:08
@kishore03109 kishore03109 marked this pull request as ready for review April 20, 2023 01:15
@kishore03109 kishore03109 merged commit bd577d7 into develop Apr 20, 2023
@mergify mergify bot deleted the IS-93-Ensure-site-launch-form-can-handle-failures-or-it-requires-manual-deletes-from-amplify-db branch April 20, 2023 06:07
@alexanderleegs alexanderleegs mentioned this pull request Apr 20, 2023
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.

2 participants