Skip to content

Commit

Permalink
add user to admin group
Browse files Browse the repository at this point in the history
  • Loading branch information
ELiuHub committed Jul 30, 2022
1 parent 4bc181a commit f0f0607
Show file tree
Hide file tree
Showing 21 changed files with 3,359 additions and 574 deletions.
17 changes: 17 additions & 0 deletions amplify/backend/api/AdminQueries/cli-inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"paths": {
"/{proxy+}": {
"lambdaFunction": "AdminQueries4a61d8cc",
"permissions": {
"setting": "private",
"auth": [
"create",
"read",
"update",
"delete"
]
}
}
}
}
21 changes: 19 additions & 2 deletions amplify/backend/auth/basics4health41656259/cli-inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@
"resourceName": "basics4health41656259",
"authSelections": "identityPoolAndUserPool",
"useDefault": "default",
"userPoolGroupList": [],
"userPoolGroupList": [
"Admins"
],
"serviceName": "Cognito",
"usernameCaseSensitive": false,
"useEnabledMfas": true
"useEnabledMfas": true,
"authRoleArn": {
"Fn::GetAtt": [
"AuthRole",
"Arn"
]
},
"unauthRoleArn": {
"Fn::GetAtt": [
"UnauthRole",
"Arn"
]
},
"breakCircularDependency": true,
"dependsOn": [],
"adminQueryGroup": "Admins"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"groupName": "Admins",
"precedence": 1
}
]
56 changes: 56 additions & 0 deletions amplify/backend/backend-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,62 @@
"EMAIL"
]
}
},
"userPoolGroups": {
"service": "Cognito-UserPool-Groups",
"providerPlugin": "awscloudformation",
"dependsOn": [
{
"category": "auth",
"resourceName": "basics4health41656259",
"attributes": [
"UserPoolId",
"AppClientIDWeb",
"AppClientID",
"IdentityPoolId"
]
}
]
}
},
"function": {
"AdminQueries4a61d8cc": {
"service": "Lambda",
"providerPlugin": "awscloudformation",
"build": true,
"dependsOn": [
{
"category": "auth",
"resourceName": "basics4health41656259",
"attributes": [
"UserPoolId"
]
}
]
}
},
"api": {
"AdminQueries": {
"service": "API Gateway",
"providerPlugin": "awscloudformation",
"authorizationType": "AMAZON_COGNITO_USER_POOLS",
"dependsOn": [
{
"category": "auth",
"resourceName": "basics4health41656259",
"attributes": [
"UserPoolId"
]
},
{
"category": "function",
"resourceName": "AdminQueries4a61d8cc",
"attributes": [
"Arn",
"Name"
]
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "{\"createdOn\":\"Windows\",\"createdBy\":\"Amplify\",\"createdWith\":\"9.1.0\",\"stackType\":\"function-Lambda\",\"metadata\":{}}",
"Parameters": {
"env": {
"Type": "String"
},
"authbasics4health41656259UserPoolId": {
"Type": "String",
"Default": "authbasics4health41656259UserPoolId"
},
"deploymentBucketName": {
"Type": "String"
},
"s3Key": {
"Type": "String"
}
},
"Conditions": {
"ShouldNotCreateEnvResources": {
"Fn::Equals": [
{
"Ref": "env"
},
"NONE"
]
}
},
"Resources": {
"LambdaFunction": {
"Type": "AWS::Lambda::Function",
"Metadata": {
"aws:asset:path": "./src",
"aws:asset:property": "Code"
},
"Properties": {
"Handler": "index.handler",
"FunctionName": {
"Fn::If": [
"ShouldNotCreateEnvResources",
"AdminQueries4a61d8cc",
{
"Fn::Join": [
"",
[
"AdminQueries4a61d8cc",
"-",
{
"Ref": "env"
}
]
]
}
]
},
"Environment": {
"Variables": {
"ENV": {
"Ref": "env"
},
"GROUP": "Admins",
"USERPOOL": {
"Ref": "authbasics4health41656259UserPoolId"
}
}
},
"Role": {
"Fn::GetAtt": [
"LambdaExecutionRole",
"Arn"
]
},
"Runtime": "nodejs14.x",
"Timeout": 25,
"Code": {
"S3Bucket": {
"Ref": "deploymentBucketName"
},
"S3Key": {
"Ref": "s3Key"
}
}
}
},
"LambdaExecutionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": {
"Fn::If": [
"ShouldNotCreateEnvResources",
"AdminQueries4a61d8ccLambdaRole",
{
"Fn::Join": [
"",
[
"AdminQueries4a61d8ccLambdaRole",
"-",
{
"Ref": "env"
}
]
]
}
]
},
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
}
}
},
"lambdaexecutionpolicy": {
"DependsOn": [
"LambdaExecutionRole"
],
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "lambda-execution-policy",
"Roles": [
{
"Ref": "LambdaExecutionRole"
}
],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": {
"Fn::Sub": [
"arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*",
{
"region": {
"Ref": "AWS::Region"
},
"account": {
"Ref": "AWS::AccountId"
},
"lambda": {
"Ref": "LambdaFunction"
}
}
]
}
},
{
"Effect": "Allow",
"Action": [
"cognito-idp:ListUsersInGroup",
"cognito-idp:AdminUserGlobalSignOut",
"cognito-idp:AdminEnableUser",
"cognito-idp:AdminDisableUser",
"cognito-idp:AdminRemoveUserFromGroup",
"cognito-idp:AdminAddUserToGroup",
"cognito-idp:AdminListGroupsForUser",
"cognito-idp:AdminGetUser",
"cognito-idp:AdminConfirmSignUp",
"cognito-idp:ListUsers",
"cognito-idp:ListGroups"
],
"Resource": {
"Fn::Join": [
"",
[
"arn:aws:cognito-idp:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":userpool/",
{
"Ref": "authbasics4health41656259UserPoolId"
}
]
]
}
}
]
}
}
}
},
"Outputs": {
"Name": {
"Value": {
"Ref": "LambdaFunction"
}
},
"Arn": {
"Value": {
"Fn::GetAtt": [
"LambdaFunction",
"Arn"
]
}
},
"Region": {
"Value": {
"Ref": "AWS::Region"
}
},
"LambdaExecutionRole": {
"Value": {
"Ref": "LambdaExecutionRole"
}
}
}
}
6 changes: 6 additions & 0 deletions amplify/backend/function/AdminQueries4a61d8cc/amplify.state
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pluginId": "amplify-nodejs-function-runtime-provider",
"functionRuntime": "nodejs",
"defaultEditorFile": "src/index.js",
"useLegacyBuild": true
}
Loading

0 comments on commit f0f0607

Please sign in to comment.