generated from bcgov/bcrs-template-ui
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from pwei1018/main
Update scripts.
- Loading branch information
Showing
5 changed files
with
84 additions
and
70 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 |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
#!/bin/bash | ||
|
||
declare -a environments=("dev" "test" "tools" "prod" "integration" "sandbox") | ||
#declare -a projects=("a083gt" "mvnjri" "gtksf3" "yfjq17" "c4hnrd" "k973yf" "yfthig" "eogruh" "bcrbk9") | ||
declare -a projects=("bcrbk9") | ||
#declare -a projects=("") | ||
declare -a service="cdcloudrun" | ||
|
||
for ev in "${environments[@]}" | ||
|
@@ -22,29 +21,35 @@ do | |
SA_FULL_NAME="${PROJECT_NUMBER}[email protected]" | ||
SA_ROLE="projects/${PROJECT_ID}/roles/$ROLE_NAME" | ||
|
||
# create/update service account | ||
if [[ -z `gcloud iam roles describe $ROLE_NAME --project=${PROJECT_ID} --verbosity=none` ]]; then | ||
gcloud iam roles create $ROLE_NAME --quiet --project=${PROJECT_ID} --file=role-$service.yaml | ||
else | ||
gcloud iam roles update $ROLE_NAME --quiet --project=${PROJECT_ID} --file=role-$service.yaml | ||
fi | ||
|
||
# role binding | ||
gcloud projects add-iam-policy-binding ${PROJECT_ID} \ | ||
--member="serviceAccount:$SA_FULL_NAME" \ | ||
--role="$SA_ROLE" | ||
|
||
# role binding - default cloud run service account | ||
gcloud projects add-iam-policy-binding ${PROJECT_ID} \ | ||
--member="serviceAccount:[email protected]" \ | ||
--role="$SA_ROLE" | ||
|
||
# role binding - default cloud build service account | ||
gcloud projects add-iam-policy-binding ${PROJECT_ID} \ | ||
--member="serviceAccount:[email protected]" \ | ||
--role="$SA_ROLE" | ||
|
||
# role binding - default cloud run robot service account | ||
SA_ROBOT_FULL_NAME="service-${PROJECT_NUMBER}@serverless-robot-prod.iam.gserviceaccount.com" | ||
gcloud projects add-iam-policy-binding ${PROJECT_ID} \ | ||
--member="serviceAccount:$SA_ROBOT_FULL_NAME" \ | ||
--role="$SA_ROLE" | ||
|
||
# role binding - default cloud run robot service account in cloud deploy project | ||
SA_DEPLOY_ROLE="projects/c4hnrd-tools/roles/$ROLE_NAME" | ||
gcloud projects add-iam-policy-binding c4hnrd-tools \ | ||
--member="serviceAccount:$SA_ROBOT_FULL_NAME" \ | ||
|
This file was deleted.
Oops, something went wrong.
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 | ||
|
||
#declare -a users=("b") | ||
|
||
#declare -a projects=("") | ||
|
||
#declare -a environments=("dev" "test" "tools" "prod" "integration" "sandbox") | ||
declare -a roles=("developer") | ||
|
||
for user in "${users[@]}" | ||
do | ||
echo "user: $user" | ||
for ev in "${environments[@]}" | ||
do | ||
for ns in "${projects[@]}" | ||
do | ||
echo "project: $ns-$ev" | ||
PROJECT_ID=$ns-$ev | ||
|
||
if [[ ! -z `gcloud projects describe ${PROJECT_ID} --verbosity=none` ]]; then | ||
gcloud config set project ${PROJECT_ID} | ||
|
||
for ro in "${roles[@]}" | ||
do | ||
ROLE_NAME="projects/${PROJECT_ID}/roles/role$ro" | ||
ROLE_FILE=role-$se.yaml | ||
|
||
if [ $ev = 'dev' ]; then | ||
ROLE_FILE=role-$se-dev.yaml | ||
fi | ||
|
||
echo "role: $ROLE_NAME" | ||
|
||
# create/update developer role | ||
if [[ -z `gcloud iam roles describe $ROLE_NAME --project=${PROJECT_ID} --verbosity=none` ]]; then | ||
gcloud iam roles create $ROLE_NAME --quiet --project=${PROJECT_ID} --file=$ROLE_FILE | ||
else | ||
gcloud iam roles update $ROLE_NAME --quiet --project=${PROJECT_ID} --file=$ROLE_FILE | ||
fi | ||
|
||
gcloud projects add-iam-policy-binding $PROJECT_ID \ | ||
--member user:$user \ | ||
--role=$ROLE_NAME \ | ||
--condition=None --verbosity=none --quiet | ||
done | ||
fi | ||
done | ||
done | ||
done |
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