-
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: DBTP-1137 trigger prod pipeline from non-prod pipeline (#195)
Co-authored-by: Chiara Mapelli <[email protected]> Co-authored-by: Chiara Mapelli <[email protected]> Co-authored-by: Will Gibson <[email protected]>
- Loading branch information
1 parent
afb1829
commit d350039
Showing
13 changed files
with
609 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ | |
*.envrc | ||
*.idea* | ||
*.DS_Store | ||
*.env* | ||
*venv* |
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
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,52 @@ | ||
version: 0.2 | ||
|
||
env: | ||
parameter-store: | ||
SLACK_TOKEN: /codebuild/slack_oauth_token | ||
|
||
phases: | ||
install: | ||
commands: | ||
- export PATH="${CODEBUILD_SRC_DIR}/build-tools/bin:$PATH" | ||
- export PYTHONPATH="${CODEBUILD_SRC_DIR}/build-tools" | ||
- echo -e "\nAssume triggered account role to trigger ${TRIGGERED_PIPELINE_NAME} pipeline" | ||
|
||
- assumed_role=$(aws sts assume-role --role-arn "${TRIGGERED_ACCOUNT_ROLE_ARN}" --role-session-name "trigger-prod-pipeline-$(date +%s)") | ||
|
||
- PROD_AWS_ACCESS_KEY_ID=$(echo $assumed_role | jq -r .Credentials.AccessKeyId) | ||
- PROD_AWS_SECRET_ACCESS_KEY=$(echo $assumed_role | jq -r .Credentials.SecretAccessKey) | ||
- PROD_AWS_SESSION_TOKEN=$(echo $assumed_role | jq -r .Credentials.SessionToken) | ||
|
||
- export PROFILE_NAME="${TRIGGERED_PIPELINE_AWS_PROFILE}" | ||
# Populate the ~/.aws/credentials file.. | ||
- aws configure set aws_access_key_id "${PROD_AWS_ACCESS_KEY_ID}" --profile "${PROFILE_NAME}" | ||
- aws configure set aws_secret_access_key "${PROD_AWS_SECRET_ACCESS_KEY}" --profile "${PROFILE_NAME}" | ||
- aws configure set aws_session_token "${PROD_AWS_SESSION_TOKEN}" --profile "${PROFILE_NAME}" | ||
# Populate the ~/.aws/config file.. | ||
- aws configure set region "eu-west-2" --profile "${PROFILE_NAME}" | ||
- aws configure set output "json" --profile "${PROFILE_NAME}" | ||
|
||
build: | ||
commands: | ||
- set -e | ||
- MESSAGE="Triggering ${TRIGGERED_PIPELINE_NAME} pipeline" | ||
- echo "${MESSAGE}" | ||
- platform-helper notify add-comment "${SLACK_CHANNEL_ID}" "${SLACK_TOKEN}" "${SLACK_REF}" "${MESSAGE}" | ||
|
||
- aws codepipeline start-pipeline-execution --name "${TRIGGERED_PIPELINE_NAME}" --profile "${PROFILE_NAME}" --variables "name=SLACK_THREAD_ID,value=${SLACK_REF}" | ||
|
||
post_build: | ||
commands: | ||
- | | ||
if [ "${CODEBUILD_BUILD_SUCCEEDING}" == "1" ] | ||
then | ||
MESSAGE="SUCCESSFULLY triggered ${TRIGGERED_PIPELINE_NAME}" | ||
ADDITIONAL_OPTIONS="" | ||
else | ||
MESSAGE=":alert: @here FAILED to trigger ${TRIGGERED_PIPELINE_NAME}" | ||
ADDITIONAL_OPTIONS="--send-to-main-channel true" | ||
fi | ||
- platform-helper notify add-comment "${SLACK_CHANNEL_ID}" "${SLACK_TOKEN}" "${SLACK_REF}" "${MESSAGE} in the ${ACCOUNT_NAME} account." "${ADDITIONAL_OPTIONS}" | ||
|
||
artifacts: | ||
files: [] |
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
Oops, something went wrong.