-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update api to include standard cognito group policy * feat: add group creation and email attribute * feat: changed name for variable placeholder * feat: add temporary deployment file * fix: handle s3 region endpoint bug * fix: correct new style pipeline formatting * feat: doc updates to reflect setup improvements Co-authored-by: Karl Wallbom <[email protected]>
- Loading branch information
Showing
7 changed files
with
109 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo -e "Checking if the platform has been setup..\n" | ||
|
||
## Retreive Cognito Details | ||
USER_POOL_ID=$(aws cognito-idp list-user-pools --max-results 20 | jq -r '.UserPools[] | select(.Name == "gurum_users") | .Id') | ||
if [ -z $USER_POOL_ID ]; then | ||
echo "No user pool found. Ensure the platform has been setup first." | ||
exit 1 | ||
fi | ||
|
||
##App client id | ||
IDENTITY_POOL_ID=$(aws cognito-identity list-identity-pools --max-results 20 | jq -r '.IdentityPools[] | select(.IdentityPoolName == "gurum_idp") | .IdentityPoolId') | ||
if [ -z $IDENTITY_POOL_ID ]; then | ||
echo "No identity pool found. Ensure the platform has been setup first." | ||
exit 1 | ||
fi | ||
|
||
# MODIFY TRUST POLICY JSON | ||
MYDIR="$(dirname "$(which "$0")")" | ||
sed "s/###RESERVED_FOR_QUICK_GROUP_SCRIPT###/$IDENTITY_POOL_ID/g" $MYDIR/group_trust_policy.json > $MYDIR/group_trust_policy.deploy | ||
|
||
# USER CREATION | ||
echo "Enter a group name:" | ||
read GROUP_NAME | ||
|
||
## Create the IAM Role | ||
ROLE_NAME="gurum-$GROUP_NAME-role" | ||
ROLE_ARN=$(aws iam create-role \ | ||
--path '/gurum/groups/' \ | ||
--role-name $ROLE_NAME \ | ||
--assume-role-policy-document file://$MYDIR/group_trust_policy.deploy \ | ||
--description "Gurum Cognito Group Assume Role for $GROUP_NAME" \ | ||
--tags Key=gurum-groups,Value=$GROUP_NAME | jq -r '.Role.Arn') | ||
rm $MYDIR/group_trust_policy.deploy # clean up temporary deploy file | ||
|
||
## Attach IAM role policy | ||
ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account') | ||
aws iam attach-role-policy \ | ||
--role-name $ROLE_NAME \ | ||
--policy-arn "arn:aws:iam::$ACCOUNT_ID:policy/gurum/gurum-group-policy" | ||
|
||
## Create the Cognito Group | ||
aws cognito-idp create-group \ | ||
--group-name $GROUP_NAME \ | ||
--user-pool-id $USER_POOL_ID \ | ||
--role-arn $ROLE_ARN > /dev/null | ||
|
||
echo -e "\n\nSuccess! Group created and mapped to an IAM role." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Federated": "cognito-identity.amazonaws.com" | ||
}, | ||
"Action": "sts:AssumeRoleWithWebIdentity", | ||
"Condition": { | ||
"StringEquals": { | ||
"cognito-identity.amazonaws.com:aud": "###RESERVED_FOR_QUICK_GROUP_SCRIPT###" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters