Raúl Mansilla
07/12/2021, 9:47 PM[context.secrets]
Failed to load and execute Flow's environment: ValueError('Local Secret "RZFXuBfesc_XXXXXXXXX" was not found.')
Prefect and Gitlab are two ec2 instances and the sg of gitlab one allow ssh and https from prefect’ s ip.import prefect
from prefect import task, Flow, Parameter
from prefect.executors import LocalExecutor
from prefect.run_configs import LocalRun
from prefect.storage import GitLab
import requests, os
from prefect.client.secrets import Secret
s = Secret("PREFECT__CONTEXT__SECRETS__GITLAB_ACCESS_TOKEN")
@task()
def overon_get_missing(days):
url = "<https://XXXXXXXXX.execute-api.eu-west-1.amazonaws.com/prod/api/v1/getMissing/>"+ str(days)
response = <http://requests.post|requests.post>(url)
return response
with Flow("overon_get_missing",run_config=LocalRun(),executor=LocalExecutor()) as flow:
days = Parameter('days')
result = overon_get_missing(days)
print(result)
flow.storage = GitLab(
repo="dmed/soa/prefect/overon_get_missing_test", # name of repo
path="overon_get_missing_gitlab.py", # location of flow file in repo
access_token_secret=s.get(), # name of personal access token secret
host="<https://gitlab.test.net>",
ref = "master"
)
overon_get_missing.run(days=30)
nicholas
07/12/2021, 10:12 PMconfig.toml
file located from which you're trying to pull the secret?Raúl Mansilla
07/12/2021, 10:17 PM./prefect/config.toml
I mean, home directory of the main user…then the path I wrote…nicholas
07/12/2021, 10:19 PMGITLAB_ACCESS_TOKEN
Raúl Mansilla
07/12/2021, 10:27 PMcodingtacos
07/12/2021, 10:28 PMimport boto3
security_client = boto3.client('secretsmanager')
security_responese = security_client.get_secret_value(SecretId='name_of_my_secret_in_aws')
security_dict = json.loads(security_responese['SecretString'])
print(security_dict['username'])
Raúl Mansilla
07/12/2021, 10:30 PMcodingtacos
07/12/2021, 10:32 PMnicholas
07/12/2021, 10:40 PMflow.storage = GitLab(
# ...
access_token_secret='GITLAB_ACCESS_TOKEN',
# ...
)
Raúl Mansilla
07/12/2021, 10:49 PM