James
05/15/2024, 12:19 AMNate
05/15/2024, 12:32 AMMarvin
05/15/2024, 12:33 AMNate
05/15/2024, 12:33 AMMarvin
05/15/2024, 12:33 AMJames
05/15/2024, 12:35 AMNate
05/15/2024, 12:36 AMNate
05/15/2024, 12:36 AMJames
05/15/2024, 12:36 AMNate
05/15/2024, 12:36 AMJames
05/15/2024, 12:37 AMpython3.11 test.py
) - but maybe it needs to be a deployment to be able to read the aws credential block (which is empty because the credentials are assigned to the ec2 instance).James
05/15/2024, 12:39 AMimport boto3
from prefect import flow
@flow(name="Test Run")
def test_run():
bucket_name = 'some_bucket'
s3 = boto3.client('s3', region_name='ap-southeast-2')
response = s3.list_objects_v2(Bucket=bucket_name)
if 'Contents' in response:
# Iterate over each object and print its key (file name)
for obj in response['Contents']:
print(obj['Key'])
else:
print("No objects found in the bucket.")
if __name__ == "__main__":
test_run()
Nate
05/15/2024, 12:39 AMAwsCredentials
directly in your code if you're just running a flow
do you happen to have a session token defined in that aws creds block? or perhaps an old token in your ~/.aws/credentials
on your machine?James
05/15/2024, 12:40 AMNate
05/15/2024, 12:41 AMJames
05/15/2024, 12:41 AMaws_credentials_block = AwsCredentials.load("aws-data-account")
glue_client = aws_credentials_block.get_boto3_session().client("glue")
James
05/15/2024, 12:47 AMNate
05/15/2024, 12:55 AMthe remote agenthmm what remote agent do you mean? if you're just running the script, there isnt necessarily an agent involved if you run the script locally, I imagine boto is using whatever creds it can find on your local
James
05/15/2024, 12:58 AMJames
05/15/2024, 12:58 AMNate
05/15/2024, 1:02 AMprefect worker start --pool ec2-subprocess
and use something like systemd to make sure that worker stays alive
and then when you create deployments, associate them with that work pool like
prefect deploy path/to/flow.py:my_flow --pool ec2-subprocess
note that in this case, you'd need that worker to have all the deps your flows need, which is why people reach for ECS / containers and run an ECS worker or completely sidestep running a worker and just use our ECS push pool to have us spin up containers in your VPC when you create a flow run from a deployment using some AwsCredentials
you specify on that work poolJames
05/15/2024, 2:17 AMNate
05/15/2024, 2:18 AM