question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow for customized PrefectSecret for AWS/GCP/Azure/etc. Result providers

See original GitHub issue

Current behavior

In order to use the new Results (such as S3Result) it requires that you have your credentials preserved in a PrefectSecret with a specific PrefectSecret name. https://docs.prefect.io/core/concepts/secrets.html#default-secrets

This prevents the ability to customize which credentials you want a particular Flow to run as. In our situation, we have multiple Agents running in multiple environments. The On-Prem Agent is configured to write their Results to an On-Prem MinIO server; while the AWS Agent is configured to write their results to an AWS S3 instance. The networks of each environment is locked down such that one cannot talk to the other.

The credentials between the On-Prem MinIO and AWS S3 are different, but as it is currently, we’re only allowed to configure one of those credentials into the AWS_CREDENTIALS PrefectSecret.

Proposed behavior

Expose the ability to specify which PrefectSecret the credentials are located in. This would be similar to the way the old S3ResultHandler worked with the aws_credentials_secret kwarg. Where you could specify the default of this parameter to AWS_CREDENTIALS if none is provided: https://github.com/PrefectHQ/prefect/blob/master/src/prefect/utilities/aws.py#L37

Example

In this example, we’re introducing the aws_credentials_secret parameter, which would need to be passed on to get_boto_client, where it would attempt to get the prefect.context.secrets:

with Flow(
    name="custom AWS creds",
    result=S3Result(
        bucket='prefect-flow-results',
        aws_credentials_secret='MINO_CREDENTIALS',
        boto3_kwargs=dict(
            region_name='us-east-1',
            endpoint_url='https://minio.local',
        )
    )

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
szelenkacommented, Jul 31, 2020

Took a slightly different approach, but it’s functioning.

For Pods that launch in a given cluster, I’m injecting that EnvVar when it spawns through a PodPreset, matching on the label for prefect.io/identifier:

---
apiVersion: redhatcop.redhat.io/v1alpha1
kind: PodPreset
metadata:
  name: prefect-aws-s3
  namespace: podpreset-webhook
spec:
  selector:
    matchExpressions:
      - key: prefect.io/identifier
        operator: Exists
  env:
    - name: PREFECT__CONTEXT__SECRETS__AWS_CREDENTIALS
      value: "{\"ACCESS_KEY\": \"value\", \"SECRET_ACCESS_KEY\": \"/value\"}"

This way, when the Flow Run Pod starts up, it’ll get the EnvVar with the local secret context set and it’s easier to rotate the token in the PodPreset manifest. The PodPresets also give us the flexibility to leverage the job_spec_yaml and other K8 labels to refine what context is set to which Flow Runs at run-time.

0reactions
cicdwcommented, Jul 2, 2020

Yup that’s correct

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Protect Your Application Secrets in AWS, Azure, and ...
GCP Secret Manager is used for the centralized storage and retrieval of passwords, API Keys, certificates, and other sensitive information.
Read more >
Kubernetes ("K8s"): AKS vs. EKS vs. GKE | Toptal
GCP vs. Azure. Kubernetes (“K8s”) won the battle of container orchestration tools. Now AWS, Azure, and Google Cloud each offer a managed ...
Read more >
Why I think GCP is better than AWS | by Fernando Villalba
Let's just compare what you have to do in order to use GCP cli compared to AWS provided we are using 2FA and...
Read more >
Compare AWS and Azure services to Google Cloud
Service category Service type Google Cloud product App modernization CI/CD Cloud Build App modernization CI/CD Google Cloud Deploy App modernization Execution Control Cloud Tasks
Read more >
The Ultimate Guide to AWS, Google Cloud, and Microsoft Azure
AWS, Azure, and GCP Emerge ... In 2006, Amazon Web Services (AWS) became the first major cloud computing provider. AWS offered a pay-as-you-go...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found