Matthew Wiseman
03/04/2025, 1:06 AMdeploy
script from my local machine, with a worker running locally that then launches task in AWS hosted ECS infrastructure. All of this is working, however I'm trying to improve the way I provide my credentials.
from prefect import flow
from prefect.runner.storage import GitRepository
import os
from prefect_gitlab import GitLabCredentials
gitlab_credentials_block = GitLabCredentials.load("gitlab-creds")
# WORKS, however I would like my token to be sourced from the gitlab-creds block
source = GitRepository(
url="<https://myname>:{}@gitlab.com/myorg/myproject/myrepo.git".format(os.getenv("GITLAB_TOKEN")),
branch="mybranch",
)
# DOES NOT WORK - get 128 errors running this deploy script as URL is missing credentials I believe.
source = GitRepository(
url="<https://gitlab.com/myorg/myproject/myrepo.git>",
branch="mybranch",
credentials=GitLabCredentials.load("gitlab-creds")
)
if __name__ == "__main__":
flow.from_source(
source=source,
entrypoint="demo/prefect/flows.py:my_flow"
).deploy(
name="private-gitlab-deploy",
work_pool_name="ecs-hybrid-micro-dev",
)
Bianca Hoch
03/04/2025, 8:23 PMfrom prefect import flow
from prefect.runner.storage import GitRepository
from prefect.blocks.system import Secret
if __name__ == "__main__":
gitlab_repo = GitRepository(
url="<https://gitlab.com/org/my-private-repo.git>",
credentials={
"access_token": Secret.load("my-secret-block-with-my-gl-credentials")
},
)
flow.from_source(
source=gitlab_repo,
entrypoint="gl_secret_block.py:my_flow",
).deploy(
name="private-gitlab-deploy",
work_pool_name="my_pool",
)
Matthew Wiseman
03/05/2025, 12:13 AMBianca Hoch
03/05/2025, 5:12 PMBianca Hoch
03/05/2025, 5:13 PM