Skip to content

Commit

Permalink
add script to create string block which contains environment variable…
Browse files Browse the repository at this point in the history
… ENV
  • Loading branch information
m-p-esser committed Oct 16, 2023
1 parent 2725442 commit 2962f50
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/blocks/create_env_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Programmatically Store ENV variable in form of a String as Prefect Block """

from prefect.blocks.system import String
from src.utils import load_env_variables


def create_env_string_block():
"""Store ENV environment variable as String in Prefect Block"""
env_variables = load_env_variables()

ENV = env_variables["ENV"] # dev, test or prod
PREFECT_BLOCK_NAME_ENV_STRING = f"{env_variables['GCP_PROJECT_ID']}-{ENV}"

env_string_block = String(value=ENV).save(
name=PREFECT_BLOCK_NAME_ENV_STRING, overwrite=True
)

return String.load(PREFECT_BLOCK_NAME_ENV_STRING).value


if __name__ == "__main__":
env = create_env_string_block()

0 comments on commit 2962f50

Please sign in to comment.