Initial commit + bitbucket pipeline

Added steps for snowflake schemachange deployment using definition to be reused depending on the branch name
This commit is contained in:
Umang Mistry
2024-02-06 16:29:58 -06:00
parent ec65796f94
commit 31e76f0c12
4 changed files with 66 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
definitions:
steps:
- step: &terraform_plan_apply
name: "Plan and Apply Terraform"
image: zenika/terraform-aws-cli:latest
script:
- terraform --version
# terraform steps here
# trigger: automatic # uncomment after testing
trigger: manual
caches:
- terraform
- step: &snowflake_deploy
name: "Deploy Snowflake Changes"
image: python:3.7
size: 2x
script:
- python -m pip install --upgrade pip
- pip install snowflake-connector-python
- pip install schemachange --upgrade
# Setting the database name dynamically based on the branch name
- if [ "$BITBUCKET_BRANCH" == "DEV" ]; then export SNOWFLAKE_DATABASE=$DEV_SNOWFLAKE_DATABASE; fi
- if [ "$BITBUCKET_BRANCH" == "UAT" ]; then export SNOWFLAKE_DATABASE=$UAT_SNOWFLAKE_DATABASE; fi
- if [ "$BITBUCKET_BRANCH" == "PROD" ]; then export SNOWFLAKE_DATABASE=$PROD_SNOWFLAKE_DATABASE; fi
- schemachange -a $SNOWFLAKE_ACCOUNT -u $SNOWFLAKE_USER -r $SNOWFLAKE_ROLE -w $SNOWFLAKE_WAREHOUSE -d $SNOWFLAKE_DATABASE -c $SNOWFLAKE_DATABASE.SCHEMACHANGE.CHANGE_HISTORY --create-change-history-table -v
# trigger: automatic # uncomment after testing
trigger: manual
caches:
- pip
pipelines:
branches:
dev:
- step:
<<: *terraform_plan_apply
condition:
changesets:
includePaths:
- terraform/dev/**/*
- step:
<<: *snowflake_deploy
condition:
paths:
- snowflake/**/*.sql
uat:
- step:
<<: *terraform_plan_apply
condition:
paths:
- terraform/uat/**/*
- step:
<<: *snowflake_deploy
condition:
paths:
- snowflake/**/*.sql
prod:
- step:
<<: *terraform_plan_apply
condition:
paths:
- terraform/prod//**/*
- step:
<<: *snowflake_deploy
condition:
paths:
- snowflake/**/*.sql
View File
View File
View File