If you have ever changed a dbt model only to find out later that it broke a downstream table or dashboard, Atlan provides a GitLab CI/CD pipeline to help you out.
This pipeline places Atlan's impact analysis right into your merge request. So, you can view the potential downstream impact of your changes before merging the request.
Prerequisites
- Before running the action, you will need to create an Atlan API token.
- Assign a persona to the API token and add a metadata policy that provides requisite permissions on assets for the Atlan dbt action to work. For example, you can add the following permissions:
- dbt — Read and Update
- Materialized layer, such as Snowflake — Read and Update
- Any downstream connections, such as Microsoft Power BI — Read only
- When a merge request with changes to one or more dbt models is merged, the Atlan dbt action will link the merge request as a resource to the assets in Atlan. To ensure that the merge request is linked as a resource, you will need to assign the right persona with requisite permissions to the API token.
Configure the action
To set up the Atlan dbt action in GitLab:
- Define CI/CD variables in your repository:
ATLAN_INSTANCE_URL
with the URL of your Atlan instance.ATLAN_API_TOKEN
with the value of the API token.GITLAB_TOKEN
with the value of the project access token.
- Click the checkboxes for Mask variable and Expand variable only. Leave the Protect variable checkbox unchecked — merge request pipelines do not have access to protected variables.
- Add the GitLab pipeline to your workflow:
- Create a workflow file in the root directory of your repository —
.gitlab-ci.yml
. - Add the following code to your workflow file:
stages: - get-downstream-impact get-downstream-impact-open: stage: get-downstream-impact image: node:20 script: - git clone https://github.com/atlanhq/dbt-action.git - cd dbt-action - npm install - npm run build - node ./adapters/index.js environment: name: get-downstream-impact rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS' when: never - if: '$CI_COMMIT_BRANCH'
- Create a workflow file in the root directory of your repository —
Test the action
After you've completed the configuration above, create a merge request with a changed dbt model file to test the action. You should see the Atlan GitLab CI/CD pipeline running and adding comments in your merge request:
- The GitLab CI/CD pipeline will add and update a single comment for every file change.
- The impacted assets in the comment will be displayed in a collapsible section and grouped by source and asset type.
- The comment will include some metadata for your impacted assets — such as descriptions, owners, and linked glossary terms.
- View the impacted assets in Atlan or open the source URL — for example, view an impacted Looker dashboard directly in Looker.
- Once you have merged the merge request, it will be added as a resource to the dbt model and its materialized assets. You can view the linked merge request from the Resources tab of the asset sidebar. For example:
Inputs
Name | Description | Required |
---|---|---|
GITLAB_TOKEN |
For writing comments on PRs to print downstream assets | true |
ATLAN_INSTANCE_URL |
For making API requests to the user's tenant | true |
ATLAN_API_TOKEN |
For authenticating API requests to the user's tenant | true |
DBT_ENVIRONMENT_BRANCH_MAP |
For mapping the GitLab branch with a specific dbt environment | false |
IGNORE_MODEL_ALIAS_MATCHING |
For turning off matching aliases using this variable | false |
Troubleshooting the action
Why does the action fetch a model from an incorrect environment?
If there are multiple dbt models with the same name but across different environments in your Atlan instance, the action may fetch an incorrect model. In order to ensure that the action fetches a model from the right environment, you can map the GitLab branch with a specific dbt environment. This will allow the Atlan GitLab CI/CD pipeline to parse lineage for that specific environment.
For example, you can provide the mapping in this format — branch name
: dbt environment name
stages:
- get-downstream-impact
get-downstream-impact-open:
stage: get-downstream-impact
image: node:20
variables:
+ DBT_ENVIRONMENT_BRANCH_MAP: |
+ main: [Enter Your Branch name]
script:
- git clone https://github.com/atlanhq/dbt-action.git
- cd dbt-action
- npm install
- npm run build
- node ./adapters/index.js
environment:
name: get-downstream-impact
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
Why does the action fetch a model by its alias and not model name?
By default, the action checks if there is an alias defined for a dbt model in the code and looks for the relevant asset in Atlan using that alias. To turn off matching aliases for your dbt models, you can set the IGNORE_MODEL_ALIAS_MATCHING
input to true.
For example:
stages:
- get-downstream-impact
get-downstream-impact-open:
stage: get-downstream-impact
image: node:20
variables:
+ IGNORE_MODEL_ALIAS_MATCHING: "true"
script:
- git clone https://github.com/atlanhq/dbt-action.git
- cd dbt-action
- npm install
- npm run build
- node ./adapters/index.js
environment:
name: get-downstream-impact
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'