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

Read client secret at runtime #4

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions common/dataplatform.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import logging
from functools import cache

from okdata.aws.ssm import get_secret
from okdata.sdk.config import Config
from okdata.sdk.data.dataset import Dataset
from okdata.sdk.data.upload import Upload
from requests.exceptions import HTTPError

logger = logging.getLogger()


@cache
def _sdk_config():
sdk_config = Config()
sdk_config.config["client_secret"] = get_secret(
"/dataplatform/okdata-data-collectors/keycloak-client-secret"
)
return sdk_config


def upload_dataset(dataset_id, filename):
logger.info(f"Uploading dataset, id={dataset_id}, file={filename}")

dataset = Dataset()
upload = Upload()
sdk_config = _sdk_config()
dataset = Dataset(sdk_config)
upload = Upload(sdk_config)

try:
version = dataset.get_latest_version(dataset_id)["version"]
Expand Down
1 change: 0 additions & 1 deletion serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ provider:
SERVICE_NAME: ${self:service}
OKDATA_ENVIRONMENT: ${self:custom.okdataEnvironment.${self:provider.stage}, self:custom.okdataEnvironment.dev}
OKDATA_CLIENT_ID: ${self:service}
OKDATA_CLIENT_SECRET: ${ssm:/dataplatform/okdata-data-collectors/keycloak-client-secret}

package:
patterns:
Expand Down
Loading