From e7f3619fdee0b5884c5d6a02a728772a00fd59bd Mon Sep 17 00:00:00 2001 From: Alex Youssefinia Date: Wed, 11 Dec 2024 20:27:04 -0600 Subject: [PATCH] try batch job --- services/admin/serverless.yml | 31 ++++++++++++++++--- .../ui-src/src/containers/UserManagement.js | 13 +------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/services/admin/serverless.yml b/services/admin/serverless.yml index a8c7e042c..b0f36e4cc 100644 --- a/services/admin/serverless.yml +++ b/services/admin/serverless.yml @@ -1,7 +1,3 @@ -service: admin - -frameworkVersion: "3" - useDotenv: true package: @@ -11,10 +7,14 @@ plugins: - serverless-esbuild - serverless-dotenv-plugin - serverless-s3-bucket-helper + custom: stage: ${opt:stage, self:provider.stage} iamPermissionsBoundaryPolicy: ${ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""} oneMacTableName: onemac-${self:custom.stage}-one + userPoolName: ${self:custom.stage}-user-pool + userPoolId: ${cf:${self:service}-${self:custom.stage}.UserPoolId} + provider: name: aws runtime: nodejs20.x @@ -37,14 +37,37 @@ provider: - arn:aws:dynamodb:*:*:table/onemac-develop-one - arn:aws:dynamodb:*:*:table/${self:custom.oneMacTableName} - arn:aws:dynamodb:*:*:table/${self:custom.oneMacTableName}/index/* + - Effect: Allow + Action: + - cognito-idp:ListUsers + - cognito-idp:AdminUpdateUserAttributes + Resource: arn:aws:cognito-idp:${self:provider.region}:*:userpool/${self:custom.userPoolId} environment: NODE_OPTIONS: '--enable-source-maps' oneMacTableName: ${self:custom.oneMacTableName} + USER_POOL_ID: ${self:custom.userPoolId} layers: - ${cf:aws-sdk-v2-layer-${self:custom.stage}.AwsSdkV2LambdaLayerQualifiedArn} +resources: + Resources: + CognitoUserPool: + Type: AWS::Cognito::UserPool + Properties: + UserPoolName: ${self:custom.userPoolName} + + Outputs: + UserPoolId: + Value: !Ref CognitoUserPool + Export: + Name: ${self:service}-${self:custom.stage}-UserPoolId + functions: + batchUpdateCognitoUsers: + handler: ./handlers/addPropertyToJWT.main + timeout: 360 + addPropertyToJWT: handler: ./handlers/addPropertyToJWT.handler timeout: 360 diff --git a/services/ui-src/src/containers/UserManagement.js b/services/ui-src/src/containers/UserManagement.js index 0e9e90eea..ba0c2207d 100644 --- a/services/ui-src/src/containers/UserManagement.js +++ b/services/ui-src/src/containers/UserManagement.js @@ -95,17 +95,6 @@ const UserManagement = () => { [userRole] ); - const setAdminUserContextList = (userList) =>{ - const adminUserList = []; - try { - for (let i = 0; i < userList.length; i++) { - adminUserList.push(userList[i].email) - } - myUserList(adminUserList); - } catch (error) { - console.log("error setting admin user list app context", error) - } - }; const updateList = useCallback(() => { if (userStatus !== USER_STATUS.ACTIVE) return; @@ -115,7 +104,7 @@ const UserManagement = () => { if (userStatus !== USER_STATUS.PENDING) setAlertCode(ul); ul = []; } - setAdminUserContextList(ul) + setUserList(ul); }) .catch((error) => {