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

fix(build_stac): Use airflow vars instead of env var for build stac role #281

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions dags/veda_data_pipeline/utils/build_stac/utils/stac.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import json

import pystac
import rasterio
from pystac.utils import datetime_to_str
from rasterio.session import AWSSession
from airflow.models.variable import Variable
from rio_stac import stac
from rio_stac.stac import PROJECTION_EXT_VERSION, RASTER_EXT_VERSION

Expand All @@ -12,8 +13,10 @@


def get_sts_session():
if role_arn := os.environ.get("EXTERNAL_ROLE_ARN"):
creds = role.assume_role(role_arn, "veda-data-pipelines_build-stac")
airflow_vars = Variable.get("aws_dags_variables")
airflow_vars_json = json.loads(airflow_vars)
if external_role_arn := airflow_vars_json.get("ASSUME_ROLE_READ_ARN"):
creds = role.assume_role(external_role_arn, "veda-data-pipelines_build-stac")
return AWSSession(
aws_access_key_id=creds["AccessKeyId"],
aws_secret_access_key=creds["SecretAccessKey"],
Expand Down
Loading