s3_object_info – List S3 objects¶
Retrieve information about AWS S3 objects.
Examples¶
- name: List all objects in all buckets accessible to us
s3_object_info:
register: result
- debug:
var: result.objects
- name: List all objects in specific bucket
s3_object_info:
bucket: steamybucket
register: result
- debug:
var: result.objects
- name: List objects with specified keys, regardless of the bucket they are in
s3_object_info:
keys:
- xobject
- lobject
- aobject
- bobject
register: result
- debug:
var: result.objects
- name: Display specific objects in a specific bucket
s3_object_info:
bucket: steamybucket
keys:
- xobject
- lobject
register: result
- debug:
var: result.objects
See Also¶
See also
Parameters¶
- auth (optional)
Parameters for authenticating with the AWS service. Each of them may be defined via environment variables.
type: dict- access_key (optional)
The AWS access key ID. If not set, the value of the AWS_ACCESS_KEY environment variable will be checked.
Mutually exclusive with profile.
type: str- profile (optional)
The name of the AWS profile configured with
aws configure
.Can be used instead of explicitly specifying your access credentials and region.
Use
default
to use the default profile.Mutually exclusive with access_key and secret_key.
type: str- region (optional)
The name of the AWS region.
If not set, the value of the AWS_REGION environment variable will be checked.
If you set a profile that specifies a default region, that region is used and you can omit this parameter. Use this parameter to override the profile’s default region.
type: str- secret_key (optional)
The AWS secret access key. If not set, the value of the AWS_SECRET_KEY environment variable will be checked.
Mutually exclusive with profile.
type: str- url (optional)
The URL to the AWS service related to the resource. By default, this is automatically determined through the region parameter.
If not set explicitly, the value of the AWS_<SERVICE>_URL environment variable will be used.
The services currently supported are EC2 and S3.
type: str
- bucket (optional)
Limit results to the specified S3 Bucket only
type: str- keys (optional)
Limit results to the specified objects only
type: list
Return Values¶
- objects (success), list,
List of S3 objects
- bucket (always), str, steamybucket
Name of S3 Bucket.
- key (always), str, file.txt
The S3 object’s key name.
- size (always), str, 433937
Size of the object’s content in bytes.
- last_modified (always), str, 2020-06-24T11:50:15+00:00
Date and time of the S3 object’s last modification.
- storage_class (always), str, standard
The storage class of the S3 object.
- etag (always), str, 54292ef8bb5854ef3f9d32df302ed245
The entity tag (an MD5 hash) of the S3 object’s contents.
- metadata (always), dict, {‘foo’: ‘bar’}
User-defined metadata of the S3 object.
- tags (always), dict, {‘App’: ‘test-app’}
Tags associated with the S3 object.
- owner (always), dict, {‘name’: ‘xlab’, ‘id’: ‘ff686298db457b3ac7’}
The owner of the S3 object.