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: replace role map lambda with cfn code #12231

Conversation

danielleadams
Copy link
Contributor

@danielleadams danielleadams commented Mar 15, 2023

Description of changes

This removes the Lambda callout custom resource that creates the role mapping for the identity pool, and adds it to the CFN code for the identity pool role attachments. The Lambda callout only runs when a user pool group is created, so the role attachment is only added to the CFN code with a user pool group.

Description of how you validated changes

  • updated snapshots for unit tests
  • added an e2e test to check that the identity pool has the expected role mappings
  • added a migration e2e test to confirm the role mappings stay the same after migration

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@danielleadams danielleadams changed the title Feat/replace role map lambda feat: replace role map lambda with cfn code Mar 15, 2023
@danielleadams danielleadams force-pushed the feat/replace-role-map-lambda branch from a1d707f to 0de6726 Compare March 15, 2023 16:59
@danielleadams danielleadams marked this pull request as ready for review March 16, 2023 23:17
@danielleadams danielleadams requested a review from a team as a code owner March 16, 2023 23:17
@danielleadams danielleadams force-pushed the feat/replace-role-map-lambda branch 2 times, most recently from 91be801 to 0d17642 Compare March 17, 2023 15:58
Copy link
Contributor

@jhockett jhockett left a comment

Choose a reason for hiding this comment

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

1 nit, but not a blocker. LGTM!

packages/amplify-e2e-core/src/categories/auth.ts Outdated Show resolved Hide resolved
@codecov-commenter

This comment was marked as off-topic.

@danielleadams danielleadams force-pushed the feat/replace-role-map-lambda branch from aa5f3c0 to 0df0656 Compare March 20, 2023 21:37
@danielleadams danielleadams requested a review from srquinn21 March 27, 2023 23:37
@danielleadams danielleadams added the do-not-merge PRs that are approved and green, but should not be merged yet label Mar 29, 2023
Copy link
Member

@sobolk sobolk left a comment

Choose a reason for hiding this comment

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

LGTM. One commend wrt error handling.

Comment on lines +155 to +157
} catch (e) {
console.log(e);
}
Copy link
Member

Choose a reason for hiding this comment

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

I noticed this is a pattern in this file. But is this a good practice?
What happens at the caller in this case? Does it handle undefined response gracefully?
What does undef response mean for the caller ? If it's handled gracefully does this mean CLI would produce different outcomes if transient error happen?

I think we should either have retry loop with exponential backoff OR such behavior should be configured when we spin up CongnitoIdentity client. In either case transient errors. if they persist, should propagate and stop user's command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed this is a pattern in this file. But is this a good practice?

I don't think this is a good pattern because it swallows the error and does not surface errors that arise from SDK, including on errors from the caller payload. I also don't want this pattern to leak into the production code where it's called from the CLI.

What does undef response mean for the caller ?

Since these are test helpers, I imagine the desired/expected behavior would be that the test fails, but again, we aren't surfacing the error, so there isn't a good understanding of why the test failed which can cause more pain.

If it's handled gracefully does this mean CLI would produce different outcomes if transient error happen?

I don't know if this is relevant because this is just the test calling straight to the SDK (or at least that's how I am using it) and not going through CLI.

I think we should either have retry loop with exponential backoff OR such behavior should be configured when we spin up CongnitoIdentity client. In either case transient errors. if they persist, should propagate and stop user's command.

I think we can do this, but I think this is out of scope for this PR. I also am not sure if failed calls to SDK are a huge pain point in tests. I would think that the issues with incorrect payloads and/or failing to match SDK responses cause test failures, which wouldn't be solved by retries.

Copy link
Member

Choose a reason for hiding this comment

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

woah, I didn't notice this is tests. nvm me.

Copy link
Member

Choose a reason for hiding this comment

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

But fwiw. I'd just remove try catch and let tests fail fast.

@srquinn21
Copy link
Contributor

I didn't see any indication that we've tested creating/migrating these resources in headless mode which is important for Studio's integration. Can we add a test for this?

@danielleadams
Copy link
Contributor Author

There's been follow up tasks to write e2e headless tests

@danielleadams danielleadams merged commit 0bd9dd1 into aws-amplify:feat/replace-lambda-callouts Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge PRs that are approved and green, but should not be merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants