diff --git a/Makefile b/Makefile index 82c5eae..69bffcd 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ SHELL := /bin/bash # set default target DBT_TARGET ?= sbx +AWS_LAMBDA_ROLE ?= aws_lambda_flow_api_sbx dbt-console: docker-compose run dbt_console @@ -19,4 +20,13 @@ udfs: --vars '{"UPDATE_UDFS_AND_SPS":True}' \ --profile flow \ --target $(DBT_TARGET) \ - --profiles-dir ~/.dbt/ \ No newline at end of file + --profiles-dir ~/.dbt/ + +grant-streamline-privileges: + dbt run-operation grant_streamline_privileges \ + --profile flow \ + --target $(DBT_TARGET) \ + --profiles-dir ~/.dbt/ \ + --args '{role: $(AWS_LAMBDA_ROLE)}' + +undo_clone_purge: sl-flow-api udfs grant-streamline-privileges \ No newline at end of file diff --git a/macros/utils.sql b/macros/utils.sql index dca82a7..355ea34 100644 --- a/macros/utils.sql +++ b/macros/utils.sql @@ -94,10 +94,11 @@ {{ result_var }} {% endmacro %} --- macro used to select priveleges on all views/tables in a target chema to a role -{% macro grant_select(role) %} +-- macro used to grant streamline priveleges to a role +{% macro grant_streamline_privileges(role) %} {{ log("Granting privileges to role: " ~ role, info=True) }} {% set sql %} + grant usage on database {{ target.database }} to role {{ role }}; grant usage on schema {{ target.schema }} to role {{ role }}; grant select on all tables in schema {{ target.schema }} to role {{ role }}; grant select on all views in schema {{ target.schema }} to role {{ role }}; diff --git a/models/silver/streamline/core/history/streamline__get_blocks_history.sql b/models/silver/streamline/core/history/streamline__get_blocks_history.sql index 246cd36..a56905d 100644 --- a/models/silver/streamline/core/history/streamline__get_blocks_history.sql +++ b/models/silver/streamline/core/history/streamline__get_blocks_history.sql @@ -22,7 +22,7 @@ SELECT PARSE_JSON( CONCAT( '{"grpc": "proto3",', - '"method": "get_block_by_height', + '"method": "get_block_by_height",', '"block_height":"', block_height :: INTEGER, '"}'