Skip to content

Commit

Permalink
qualify snowflake deployment for staging/main
Browse files Browse the repository at this point in the history
  • Loading branch information
philerooski committed Jul 12, 2024
1 parent 139a863 commit a29e952
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/upload-and-deploy-to-prod-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,56 @@ jobs:
Payload: '{"RequestType": "Create"}'
LogType: Tail

deploy-snowflake-main:
name: Deploy Snowflake resources
needs: sceptre-deploy-main
runs-on: ubuntu-latest
env:
PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }}
steps:
- uses: actions/checkout@v3

- name: Configure Snowflake connection
run: |
# Create temporary files for config.toml and our private key
config_file=$(mktemp)
private_key_file=$(mktemp)
# Write to the private key file
echo "${{ secrets.SNOWFLAKE_PRIVATE_KEY }}" > $private_key_file
# Write to config.toml file
echo 'default_connection_name = "recover"' >> $config_file
echo '[connections.recover]' >> $config_file
echo "account = \"${{ vars.SNOWFLAKE_ACCOUNT }}\"" >> $config_file
echo "user = \"${{ vars.SNOWFLAKE_USER }}\"" >> $config_file
echo "role = \"${{ vars.SNOWFLAKE_ROLE }}\"" >> $config_file
echo 'authenticator = "SNOWFLAKE_JWT"' >> $config_file
echo "private_key_path = \"$private_key_file\"" >> $config_file
# Write config.toml path to global environment
echo "SNOWFLAKE_CONFIG_PATH=$config_file" >> $GITHUB_ENV
- name: Configuration file information
run: |
echo "Snowflake configuration is located at $SNOWFLAKE_CONFIG_PATH"
cat $SNOWFLAKE_CONFIG_PATH
- name: Install Snowflake CLI
uses: Snowflake-Labs/snowflake-cli-action@v1
with:
default-config-file-path: ${{ env.SNOWFLAKE_CONFIG_PATH }}

- name: Test Snowflake connection
run: |
snow --version
snow connection test
- name: Deploy Snowflake objects
run: |
snow sql \
-D "environment=main" \
-f snowflake/objects/deploy.sql
sts-access-test:
name: Runs STS access tests on prod synapse folders
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/upload-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ jobs:
runs-on: ubuntu-latest
env:
PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }}
SNOWFLAKE_ENVIRONMENT: ${{ github.ref_name == 'main' && 'staging' || github.ref_name }}
steps:
- uses: actions/checkout@v3

- name: Configure Snowflake connection
run: |
# Create temporary files for config.toml and our private key
#mkdir ~/.snowflake
#config_file="~/.snowflake/config.toml"
config_file=$(mktemp)
private_key_file=$(mktemp)
Expand Down Expand Up @@ -76,7 +75,7 @@ jobs:
- name: Deploy Snowflake objects
run: |
snow sql \
-D "environment=$(git rev-parse --abbrev-ref HEAD)" \
-D "environment=$SNOWFLAKE_ENVIRONMENT" \
-f snowflake/objects/deploy.sql
upload-files:
Expand Down Expand Up @@ -153,7 +152,6 @@ jobs:
--test-sts-permission read_write
-v
pytest-docker:
name: Build and push testing docker images to the pytest ECR repository.
needs: pre-commit
Expand Down Expand Up @@ -209,7 +207,6 @@ jobs:
ecr-username: ${{ steps.login-ecr.outputs[steps.ecr.outputs.username-key] }}
ecr-password: ${{ steps.login-ecr.outputs[steps.ecr.outputs.password-key] }}


glue-unit-tests:
name: Run Pytest unit tests for AWS glue
needs: pytest-docker
Expand Down Expand Up @@ -260,7 +257,6 @@ jobs:
su - glue_user --command "cd $GITHUB_WORKSPACE &&
python3 -m pytest tests/test_json_to_parquet.py --namespace $NAMESPACE -v"
sceptre-deploy-develop:
name: Deploys branch using sceptre
runs-on: ubuntu-latest
Expand Down Expand Up @@ -344,7 +340,6 @@ jobs:
--bucket $DEV_INTERMEDIATE_BUCKET
--bucket_prefix "${{ env.NAMESPACE }}/json/"
integration-test-develop:
name: Triggers ETL workflow with S3 test files
runs-on: ubuntu-latest
Expand Down

0 comments on commit a29e952

Please sign in to comment.