From dbb023ab5fc9e3fce6ef294221860f51ebff5718 Mon Sep 17 00:00:00 2001 From: Matt Romano <42412983+mattromano@users.noreply.github.com> Date: Mon, 5 May 2025 11:45:25 -0700 Subject: [PATCH] dev-refresh-streamline-url-fix (#115) --- .github/workflows/dbt_run_dev_refresh.yml | 24 ++++++++++++++++++++--- macros/sp_create_prod_clone.sql | 4 +++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dbt_run_dev_refresh.yml b/.github/workflows/dbt_run_dev_refresh.yml index 4fdcddb..b5cc6ed 100644 --- a/.github/workflows/dbt_run_dev_refresh.yml +++ b/.github/workflows/dbt_run_dev_refresh.yml @@ -25,9 +25,9 @@ concurrency: jobs: - run_dbt_jobs: + run_dbt_jobs_refresh: runs-on: ubuntu-latest - environment: + environment: name: workflow_prod steps: @@ -42,10 +42,28 @@ jobs: run: | pip install -r requirements.txt dbt deps - - name: Run DBT Jobs + - name: Run Dev Refresh run: | dbt run-operation run_sp_create_prod_clone + run_dbt_jobs_udfs: + runs-on: ubuntu-latest + needs: run_dbt_jobs_refresh + environment: + name: workflow_dev + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "pip" + + - name: install dependencies + run: | + pip install -r requirements.txt + dbt deps - name: Run Recreate UDFs run: | dbt run-operation fsc_utils.create_streamline_udfs --vars '{"UPDATE_UDFS_AND_SPS":True}' -t dev diff --git a/macros/sp_create_prod_clone.sql b/macros/sp_create_prod_clone.sql index 20ee897..2d1cadc 100644 --- a/macros/sp_create_prod_clone.sql +++ b/macros/sp_create_prod_clone.sql @@ -10,6 +10,7 @@ $$ try { snowflake.execute({sqlText: `CREATE OR REPLACE DATABASE ${DESTINATION_DB_NAME} CLONE ${SOURCE_DB_NAME}`}); snowflake.execute({sqlText: `DROP SCHEMA IF EXISTS ${DESTINATION_DB_NAME}._INTERNAL`}); /* this only needs to be in prod */ + snowflake.execute({sqlText: `GRANT USAGE ON DATABASE ${DESTINATION_DB_NAME} TO AWS_LAMBDA_EXTERNAL_API`}); snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL SCHEMAS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); snowflake.execute({sqlText: `GRANT OWNERSHIP ON ALL FUNCTIONS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`}); @@ -21,7 +22,8 @@ $$ snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE PROCEDURES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE VIEWS IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); - snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); + snowflake.execute({sqlText: `GRANT OWNERSHIP ON FUTURE TABLES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME};`}); + snowflake.execute({sqlText: `GRANT USAGE ON ALL STAGES IN DATABASE ${DESTINATION_DB_NAME} TO ROLE AWS_LAMBDA_EXTERNAL_API;`}); snowflake.execute({sqlText: `GRANT OWNERSHIP ON DATABASE ${DESTINATION_DB_NAME} TO ROLE ${ROLE_NAME} COPY CURRENT GRANTS;`})