Skip to content

Commit

Permalink
try batch job
Browse files Browse the repository at this point in the history
  • Loading branch information
anyoussefinia committed Dec 12, 2024
1 parent 4bb4252 commit e7f3619
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
31 changes: 27 additions & 4 deletions services/admin/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
service: admin

frameworkVersion: "3"

useDotenv: true

package:
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 1 addition & 12 deletions services/ui-src/src/containers/UserManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -115,7 +104,7 @@ const UserManagement = () => {
if (userStatus !== USER_STATUS.PENDING) setAlertCode(ul);
ul = [];
}
setAdminUserContextList(ul)

setUserList(ul);
})
.catch((error) => {
Expand Down

0 comments on commit e7f3619

Please sign in to comment.