Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FIR-35165): Optional external id for arn auth #130

Merged
merged 16 commits into from
Jul 30, 2024
3 changes: 3 additions & 0 deletions .changes/unreleased/Changed-20240729-145310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Changed
body: External table authentication to inlcude optional role external id.
time: 2024-07-29T14:53:10.992711+01:00
2 changes: 1 addition & 1 deletion .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ".[dev]"
python -m pip install ".[dev]"

- name: Run pre-commit checks
uses: pre-commit/[email protected]
3 changes: 2 additions & 1 deletion .github/workflows/jaffle-shop-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "dbt-firebolt/.[dev]"
python -m pip install "dbt-firebolt/.[dev]"

- name: Setup database and engine
id: setup
Expand All @@ -53,6 +53,7 @@ jobs:
SECURE_BUCKET_PATH: ${{ vars.SECURE_BUCKET_PATH }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_ACCESS_SECRET_KEY: ${{ secrets.AWS_ACCESS_SECRET_KEY }}
AWS_ACCESS_ROLE_ARN: ${{ secrets.AWS_ACCESS_ROLE_ARN }}
DBT_PROFILES_DIR: "../dbt-firebolt/.github/workflows/jaffle_shop"
working-directory: jaffle-shop
run:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/jaffle_shop/run_test_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ dbt compile
dbt run-operation stage_external_sources
cp ../dbt-firebolt/.github/workflows/jaffle_shop/sources_external_tables_id_secret.yml models/staging/sources_external_tables.yml
dbt run-operation stage_external_sources --vars "ext_full_refresh: true"
if [[ -n "$AWS_ACCESS_ROLE_ARN" ]]; then
# Can't test this on FB 1.0
cp ../dbt-firebolt/.github/workflows/jaffle_shop/sources_external_tables_iam.yml models/staging/sources_external_tables.yml
dbt run-operation stage_external_sources --vars "ext_full_refresh: true"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already run this operation before this if block. Can we just execute it once after the if block?

Copy link
Collaborator Author

@ptiurin ptiurin Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's intentional - we're changing the table configuration by doing cp into sources_external_tables.yml. First time we're testing no auth, then auth with id and secret and finally (conditional, on fb2.0) IAM role auth. Each one of them to trigger needs dbt run-operation

fi
dbt seed
dbt seed --full-refresh
dbt run
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/jaffle_shop/sources_external_tables_iam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2

sources:
- name: s3
tables:
- name: raw_customers
external:
url: "{{ env_var('SECURE_BUCKET_PATH') }}"
object_pattern: '*raw_customers.csv'
credentials:
internal_role_arn: "{{ env_var('AWS_ACCESS_ROLE_ARN') }}"
type: '(CSV SKIP_HEADER_ROWS=true)'
columns:
- name: id
data_type: int
- name: first_name
data_type: TEXT
- name: last_name
data_type: TEXT
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
SECURE_BUCKET_PATH: ${{ vars.SECURE_BUCKET_PATH }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_ACCESS_SECRET_KEY: ${{ secrets.AWS_ACCESS_SECRET_KEY }}
AWS_ACCESS_ROLE_ARN: ${{ secrets.AWS_ACCESS_ROLE_ARN }}
working-directory: jaffle-shop
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
{% if external.url %} URL = '{{external.url}}' {%- endif %}
{%- if credentials and credentials.internal_role_arn %}
CREDENTIALS = (AWS_ROLE_ARN = '{{credentials.internal_role_arn}}'
AWS_ROLE_EXTERNAL_ID = '{{credentials.external_role_id}}')
{%- if credentials.external_role_id %}
AWS_ROLE_EXTERNAL_ID = '{{credentials.external_role_id}}'
{%- endif -%}
)
{% elif credentials and credentials.aws_key_id %}
CREDENTIALS = (AWS_KEY_ID = '{{credentials.aws_key_id}}'
AWS_SECRET_KEY = '{{credentials.aws_secret_key}}')
Expand Down
Loading