Skip to content

Commit

Permalink
duplicate user pools
Browse files Browse the repository at this point in the history
  • Loading branch information
anyoussefinia committed Dec 12, 2024
1 parent fd4b0dd commit 943f46f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
5 changes: 3 additions & 2 deletions services/admin/handlers/batchUpdateCognitoUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function updateUserAttribute(userPoolId, username, roles) {

await cognito.adminUpdateUserAttributes(params).promise();
}

async function processCognitoUsers() {
const userPoolId = process.env.USER_POOL_ID;
console.log("user pool id: ", userPoolId)
Expand Down Expand Up @@ -53,6 +53,7 @@ async function processCognitoUsers() {


export const main = async () => {
processCognitoUsers().catch(console.error);
await processCognitoUsers().catch(console.error);
console.log("function complete")
}

19 changes: 4 additions & 15 deletions services/admin/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ custom:
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: ${ssm:/configuration/${self:custom.stage}/cognito/userPoolId, ''}

provider:
name: aws
Expand Down Expand Up @@ -46,30 +47,18 @@ provider:
Action:
- cognito-idp:ListUsers
- cognito-idp:AdminUpdateUserAttributes
Resource: !GetAtt CognitoUserPool.Arn
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: !Ref CognitoUserPool
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:provider.stage}-UserPoolId

functions:
batchUpdateCognitoUsers:
batchUpdateCognitoUsers:
handler: ./handlers/batchUpdateCognitoUsers.main
timeout: 360

Expand Down

0 comments on commit 943f46f

Please sign in to comment.