Skip to content

Instantly share code, notes, and snippets.

View farhanangullia's full-sized avatar

Farhan Angullia farhanangullia

View GitHub Profile
@farhanangullia
farhanangullia / gitlab-codecommit-mirroring.md
Last active July 16, 2021 06:31
Steps for mirroring empty gitlab repository and codecommit

Mirroring an empty Gitlab repository with existing Codecommit repository

Note: Repeat the required steps/checks below for all repositories as needed

Setup the gitlab repository (prerequisite):

  1. Create the GitLab repository if not done yet
@farhanangullia
farhanangullia / export_temp_aws_credentials.sh
Created May 26, 2021 13:36
Bash script for assuming AWS IAM role and exporting its temporary credentials to environment variables
#!/bin/bash
echo "Retrieving session tokens"
tokens=$(aws sts assume-role --role-arn arn:aws:iam::123456789012:role/ExampleRole --role-session-name TempSession)
echo "Exporting credentials to env variables..."
export AWS_ACCESS_KEY_ID=$(echo $tokens | jq -r .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $tokens | jq -r .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $tokens | jq -r .Credentials.SessionToken)
echo "Successfully exported credentials..."
@farhanangullia
farhanangullia / git_auth.sh
Created May 26, 2021 13:02
Script for initializing git credentials in Gitlab runner
#!/bin/sh
echo "Attempting to setup git credentials..."
git config --global credential.helper store
git config --global user.email "$GITLAB_USER_EMAIL"
git config --global user.name "$GITLAB_USER_NAME"
echo "https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com" > ~/.git-credentials
echo "Git credentials set..."