Joseph Loss
06/21/2021, 6:54 PMZach Angell
CodeCommit
flow storage should look for a secret named AWS_CREDENTIALS
to get boto3 authentication
A secret named "AWS_CREDENTIALS" should be a json string that looks something like
{
"ACCESS_KEY": XXX,
"SECRET_ACCESS_KEY": XXX,
"SESSION_TOKEN": XXX (I think this is optional)
}
Zach Angell
CodeCommit
storage, you'll need to specify the secret being used, and you can pass the aws region
storage = CodeCommit(
... # other stuff
secrets = ["AWS_CREDENTIALS"],
client_options={"region_name": "us-east-1"}
)
Joseph Loss
06/21/2021, 7:14 PMJoseph Loss
06/21/2021, 7:14 PMZach Angell
Joseph Loss
06/21/2021, 7:28 PMFailed to load and execute Flow's environment: PartialCredentialsError('Partial credentials found in explicit, missing: aws_secret_access_key')
Joseph Loss
06/21/2021, 7:30 PM{
"aws_access_key_id": "XXX",
"aws_secret_access_key": "XXX"
}
and resulted in another error:
Failed to load and execute Flow's environment: NoCredentialsError('Unable to locate credentials')
Zach Angell
Zach Angell
Joseph Loss
06/21/2021, 7:36 PMZach Angell
CodeCommit
storage definition look like now?Joseph Loss
06/21/2021, 7:40 PMwith Flow('Intraday Strategy Greeks',
run_config = LocalRun(
labels=['sradev68']
),
storage = CodeCommit(
repo='repo_name',
path='path_to_flow.py',
commit='branch_name',
secrets=["AWS_CREDENTIALS"],
client_options = {"region_name":"us-east-2"})
) as flow:
Joseph Loss
06/21/2021, 7:42 PMZach Angell
Joseph Loss
06/25/2021, 2:20 PMwith Flow('Load AWS Secret') as flow:
cred = PrefectSecret("AWS_CREDENTIALS")
secret_value = AWSSecretsManager(secret="AWS_SECRET").run(credentials=cred)
The above works, but I'm wondering if there is a better way, like using a task decorator and passing in the PrefectSecret as an argument....would that work?Zach Angell
.run()
here is because AWSSecretsManager
is itself a Task
.
Something like this would also work
secret_manger_task = AWSSecretsManager() # initialize a task
with Flow('load secret') as flow:
cred = PrefectSecret("AWS_CREDENTIALS")
secret_value = secret_manager_task(secret="MY_SECRET", credentials=cred) # calling the task will run it in the flow