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 oauth and userpoolclient lambdas with cfn and sdk calls #12935

Merged
merged 34 commits into from
Jul 14, 2023

Conversation

sobolk
Copy link
Member

@sobolk sobolk commented Jul 11, 2023

Description of changes

This PR:

Issue #, if available

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

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

@codecov-commenter
Copy link

codecov-commenter commented Jul 12, 2023

Codecov Report

Merging #12935 (95f0f8b) into dev (ec9a2ba) will increase coverage by 48.48%.
The diff coverage is 65.03%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##              dev   #12935       +/-   ##
===========================================
+ Coverage    0.00%   48.48%   +48.48%     
===========================================
  Files        1296      846      -450     
  Lines      149743    38161   -111582     
  Branches     1296     7793     +6497     
===========================================
+ Hits            0    18501    +18501     
+ Misses     148447    18066   -130381     
- Partials     1296     1594      +298     
Impacted Files Coverage Δ
...rmation/auth-stack-builder/auth-stack-transform.ts 89.22% <ø> (+89.22%) ⬆️
.../src/provider-utils/awscloudformation/constants.ts 100.00% <ø> (+100.00%) ⬆️
...e-walkthrough-types/awsCognito-user-input-types.ts 100.00% <ø> (+100.00%) ⬆️
...vice-walkthrough-types/cognito-user-input-types.ts 100.00% <ø> (+100.00%) ⬆️
...y-category-function/src/commands/function/build.ts 0.00% <0.00%> (ø)
...ify-category-function/src/events/prePushHandler.ts 33.33% <0.00%> (+33.33%) ⬆️
...ider-utils/awscloudformation/utils/layerHelpers.ts 21.80% <0.00%> (+21.80%) ⬆️
...er-utils/awscloudformation/utils/storeResources.ts 30.38% <ø> (+30.38%) ⬆️
...ib/S3AndCloudFront/helpers/configure-CloudFront.js 87.06% <ø> (+87.06%) ⬆️
...lify-category-hosting/lib/S3AndCloudFront/index.js 89.65% <ø> (+89.65%) ⬆️
... and 57 more

... and 1240 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sobolk sobolk marked this pull request as ready for review July 12, 2023 03:55
@sobolk sobolk requested review from a team as code owners July 12, 2023 03:55
Amplifiyer
Amplifiyer previously approved these changes Jul 12, 2023
Comment on lines 5 to 7
"l_api_2b_api_6c_api_9a",
"l_api_5_apigw_api_lambda_auth_1",
"l_api_8_function_8_schema_iterative_update_locking",
"l_api_9b_custom_policies_container_function_9b",
"l_api_connection_migration2_api_4_containers_api_secrets",
"l_api_3_api_6b_api_1",
"l_api_4_containers_api_secrets_storage_4",
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the changes in this file intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is result of yarn split-e2e-tests-codebuild which we're supposed to commit (and other cb changes too).

@@ -610,9 +610,9 @@ export function updateS3AddTriggerNewFunctionWithFunctionExisting(cwd: string, s
});
}

export function addS3StorageWithIdpAuth(projectDir: string): Promise<void> {
export function addS3StorageWithIdpAuth(projectDir: string, testingWithLatestCodebase = false): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the default be true?

Copy link
Member Author

Choose a reason for hiding this comment

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

nah. The patter is "false", see https://github.com/search?q=repo%3Aaws-amplify%2Famplify-cli%20testingWithLatestCodebase&type=code . and then we rely on cci/codebuild to set this up properly ...

};

const oauthSettings = {
signinUrl: 'https://danielle.lol/',
Copy link
Contributor

Choose a reason for hiding this comment

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

🤣

Copy link
Contributor

@danielleadams danielleadams left a comment

Choose a reason for hiding this comment

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

Looks good. I think there's 1 change we need to make, and then I will say it looks like there's future tests that were added, but I think that's okay because if the tests pass now, we can just TDD the future code.

@@ -2158,7 +2166,7 @@ batch:
variables:
compute-type: BUILD_GENERAL1_SMALL
TEST_SUITE: src/__tests__/migration_tests_v10/custom-stack.migration.test.ts
CLI_REGION: us-west-2
CLI_REGION: us-east-2
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need all these changes to the regions?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was outcome from yarn split-e2e-tests-codebuild. We're supposed to run in and commit outcome if test suite changes.

@@ -1987,19 +1614,44 @@ exports.handler = (event, context, callback) => {
},
"UserPoolClient": {
"DependsOn": [
"HostedUIProvidersCustomResourceInputs",
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is here, I think there's a depends on that needs to be removed from the stack transform.

@@ -2206,16 +1716,41 @@ exports.handler = (event, context, callback) => {
},
"UserPoolClientWeb": {
"DependsOn": [
"HostedUIProvidersCustomResourceInputs",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here. I think a dependency needs to be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or is this because the client resources depended on the Oauth custom resource?

userPoolClientRole?: iam.CfnRole;
userPoolClientLambdaPolicy?: iam.CfnPolicy;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this wasn't in the original code but if we are changing the method name, should we change userPoolClientRole to something like userPoolBaseRole?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

What we could do is deprecate old field and add new. But I'm not sure it's worth it.

this.oAuthCustomResourceInputs.node.addDependency(this.oAuthCustomResourceLogPolicy);
// this can be removed when hostedUI Custom resource is removed
this.userPoolClient?.node.addDependency(this.hostedUIProvidersCustomResourceInputs);
this.userPoolClientWeb?.node.addDependency(this.hostedUIProvidersCustomResourceInputs);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think L790-L792 need to be added.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in 74cf0dc .
When I re-recorded snapshots, these e2e tests, so confidence is high. running full e2e on the change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

CREATE_COMPLETE                Thu Jul 13 2023 \u001b[39m\r\n\u001b[K\u001b[32m\tHostedUICustomResourceInputs   Custom::LambdaCallout          CREATE_COMPLETE                Thu Jul 13 2023 \u001b[39m\r\n\u001b[?25h\r\n"]
[214.859,"o","🛑 \u001b[31mThe following resources failed to deploy:\u001b[39m\r\n"]
[214.859,"o","\u001b[31mResource Name:\u001b[39m UserPoolClient (AWS::Cognito::UserPoolClient)\r\n\u001b[31mEvent Type:\u001b[39m create\r\n\u001b[31mReason:\u001b[39m The provider Facebook does not exist for User Pool us-east-2_OVbZj6wvz. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: f28ddb69-9b44-484e-87a8-ba40bb5c3cf6; Proxy: null)\r\n\r\n\r\n\u001b[31mResource Name:\u001b[39m UserPoolClientWeb (AWS::Cognito::UserPoolClient)\r\n\u001b[31mEvent Type:\u001b[39m create\r\n\u001b[31mReason:\u001b[39m The provider Facebook does not exist for User Pool us-east-2_OVbZj6wvz. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: 74dfe154-1c80-4e5f-b050-e20c70633db7; Proxy: null)\r\n\r\n\r\n"]
[214.86,"o","🛑 \u001b[31mResource is not in the state stackUpdateComplete\u001b[39m\r\n"]
[214.86,"o","\u001b[0mName: UserPoolClient (AWS::Cognito::UserPoolClient), Event Type: create, Reason: The provider Facebook does not exist for User Pool us-east-2_OVbZj6wvz. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: f28ddb69-9b44-484e-87a8-ba40bb5c3cf6; Proxy: null), IsCustomResource: false\u001b[0m\r\n\u001b[0m\u001b[0m\r\n\u001b[0mName: UserPoolClientWeb (AWS::Cognito::UserPoolClient), Event Type: create, Reason: The provider Facebook does not exist for User Pool us-east-2_OVbZj6wvz. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: 74dfe154-1c80-4e5f-b050-e20c70633db7; Proxy: null), IsCustomResource: false\u001b[0m\r\n\u001b[0m\u001b[0m\r\n\r\n"]
[214.86,"o","\u001b[0mLearn more at: https://docs.amplify.aws/cli/project/troubleshooting/\u001b[0m\r\n\r\nDeploymentFault: Resource is not in the state stackUpdateComplete\r\n    at Object.run (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:362:11)\r\n    at async /snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:137:16\r\n    at async Promise.all (index 0)\r\n    at async providersPush (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:133:5)\r\n    at async AmplifyToolkit.pushResources (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:107:13)\r\n    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:194:9)\r\n    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)\r\n    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)\r\n    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)\r\n\r\nResource is not in the state stackUpdateComplete\r\n"]
[214.861,"o","ResourceNotReady: Resource is not in the state stackUpdateComplete\r\n    at constructor.setError (/snapshot/repo/build/node_modules/aws-sdk/lib/resource_waiter.js:182:47)\r\n    at Request.CHECK_ACCEPTORS (/snapshot/repo/build/node_modules/aws-sdk/lib/resource_waiter.js:44:12)\r\n    at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:106:20)\r\n    at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:78:10)\r\n    at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:686:14)\r\n    at Request.transition (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:22:10)\r\n    at AcceptorStateMachine.runTo (/snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:14:12)\r\n    at /snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:26:10\r\n    at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:38:9)\r\n    at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:688:12)\r\n    at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:116:18)\r\n    at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:78:10)\r\n    at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:686:14)\r\n    at Request.transition (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:22:10)\r\n    at AcceptorStateMachine.runTo (/snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:14:12)\r\n    at /snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:26:10\r\n    at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:38:9)\r\n    at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:688:12)\r\n    at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:116:18)\r\n    at callNextListener (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:96:12)\r\n    at IncomingMessage.onEnd (/snapshot/repo/build/node_modules/aws-sdk/lib/event_listeners.js:417:13)\r\n    at IncomingMessage.emit (node:events:525:35)\r\n    at IncomingMessage.emit (node:domain:489:12)\r\n    at endReadableNT (node:internal/streams/readable:1359:12)"]
[214.861,"o","\r\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)\r\n"]

@sobolk
Copy link
Member Author

sobolk commented Jul 13, 2023

Looks good. I think there's 1 change we need to make, and then I will say it looks like there's future tests that were added, but I think that's okay because if the tests pass now, we can just TDD the future code.

Yes. Taking these tests eagerly was intentional.

@@ -21,6 +21,7 @@
"migration_v4.28.2_nonmultienv_layers": "yarn setup-profile 4.28.2 && jest src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts --verbose --config=jest.config.js",
"migration_v4.52.0_multienv_layers": "yarn setup-profile 4.52.0 && jest src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts --verbose --config=jest.config.js",
"migration_v10.5.1": "yarn setup-profile 10.5.1 && jest --verbose --config=jest.config.js",
"migration_v12.0.3": "yarn setup-profile 12.0.3 && jest --verbose --config=jest.config.js",
Copy link
Contributor

Choose a reason for hiding this comment

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

should we test migrating from 12.1.1 (current latest)?

Copy link
Member Author

@sobolk sobolk Jul 14, 2023

Choose a reason for hiding this comment

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

Current latest is soon to be replaced by 12.2.0-rc.a3b139fb36.0 . I'd refrain from jumping on moving target.
For this migration purposes 12.0.3 is as good as latest
The diffs (v12.0.3...v12.1.1 and v12.0.3...release_rc/a3b139fb36) don't reveal significant changes (both show 6 changed files in auth category - changelog, versions in package.json, test changes due to yarn migration and the userPoolConsoleUrl change - which isn't significant to this PR.).

If we ship this PR before batch 2 arrives then I'll be inclined to add one more v12 suite to cover version in-between.

@sobolk sobolk merged commit b3ab512 into aws-amplify:dev Jul 14, 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.

5 participants