Is there a way to read a yaml file that is located in a subfolder of a folder in an s3 bucket without iterating over the contents?
An example path for a yaml file would look like s3://bucket/folder/sub/file.yml
.
There is a solution for yaml files in a bucket but without the option to access the subfolders
bucket = "bucket"
s3_client = boto3.client('s3')
response = s3_client.get_object(Bucket=bucket, Key="file.yml")
configfile = yaml.safe_load(response["Body"])
CodePudding user response:
Unless I'm misunderstanding your question, you would just specify all the subfolders in the Key
parameter:
response = s3_client.get_object(Bucket=bucket, Key="folder/sub/file.yml")