Hi - I am encountering a botocore `NoCredentialsEr...
# prefect-community
Hi - I am encountering a botocore
NoCredentialsError('Unable to locate credentials')
error using Docker Storage (local image), prefect cloud and the
When the flow is run locally. There are no credential issues initializing the handler
s3_handler = S3ResultHandler(bucket='some-bucket')
To resolve the issue I created a Prefect Secret called
and tried
Copy code
aws_scrts = s.get()
s3_handler = S3ResultHandler(bucket='some-bucket', aws_credentials_secret=aws_scrts)
What is the best way to resolve aws credential error? Thanks
Hi @itay livni, taking a look now! Will get back to you with an answer ASAP.
It looks like you might be giving the
your secret values, rather than the name of your Prefect secret. Do you still get the
when you provide
? Here are a couple of links below for reference, if that's at all helpful. https://docs.prefect.io/api/latest/engine/result_handlers.html#s3resulthandler https://github.com/PrefectHQ/prefect/blob/master/src/prefect/engine/result_handlers/s3_result_handler.py#L68
@Zachary Hughes Just to be clear the AWS Prefect Secret name has to be all caps?
Not necessarily-- it just needs to be the name of your secret. I just used all-caps to denote that this was a portion of code that needed to be replaced. 🙂
So something else is going on. Because this flow was running previously in the same enviroment.. using different version of prefect
Hmm... do you recall what version of Prefect you were on, and what version you're on now?
well I am on 0.10.6
and the secret should look like this?
Copy code
'{"ACCESS_KEY": "something", "SECRET_ACCESS_KEY": "something"}'
I believe so!
Strange I did not need to muck around with this previously
I can ask around to see if folks know of any changes that could have impacted this! It depends on your setup, but I'm also wondering if boto's picking up changes in your environment/config, as the S3ResultHandler defaults to standard boto3 auth if you don't provide a secret.
Out of curiosity, how were you providing AWS creds previously?
I was not. It was magically happening behind the scene "If not provided, 
 will fall back on standard AWS rules for authentication."
Now - That stopped working
Copy code
s = Secret("aws_credentials")
aws_scrts = s.get()

s3_handler = S3ResultHandler(bucket='some-bucket', aws_credentials_secret=aws_scrts)
And when I build an image, using
and the code above I get this error.
Copy code
Beginning health checks...
System Version check: OK
Traceback (most recent call last):
  File "/root/.prefect/healthcheck.py", line 123, in <module>
    flows = cloudpickle_deserialization_check(flow_file_path)
  File "/root/.prefect/healthcheck.py", line 39, in cloudpickle_deserialization_check
  File "/MOC/etl_moc.py", line 48, in <module>
    aws_scrts = s.get()
  File "/usr/local/lib/python3.7/site-packages/prefect/client/secrets.py", line 139, in get
    ) from None
ValueError: Local Secret "aws_credentials" was not found.
and the secret does exist:
It looks like you're passing in the value of
, rather than the name of your secret. Can you try passing in the secret name "aws_credentials" like this?
s3_handler = S3ResultHandler(bucket='some-bucket', aws_credentials_secret="aws_credentials")
😁 1
@Zachary Hughes - For closure. (1) Why I "suddenly" need to use a prefect aws configuration is a mystery. (2) Using prefect secret works.
Thank you for your patience!
No patience required-- just glad it's working for you! 🙂 Haven't been able to isolate any core changes that might have prompted this shift, but I'll be sure to keep an eye out.