steampunk.aws.s3_object_info (0.9.0) — module

List S3 objects

Authors: Manca Bizjak (@mancabizjak), Aljaz Kosir (@aljazkosir), Saso Stanovnik (@sstanovnik), Miha Dolinar (@mdolinar), Tadej Borovsak (@tadeboro)

preview | supported by XLAB Steampunk

Install collection

Install with ansible-galaxy collection install steampunk.aws:==0.9.0


Add to requirements.yml

  collections:
    - name: steampunk.aws
      version: 0.9.0

Description

Retrieve information about AWS S3 objects.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: List all objects in all buckets accessible to us
  s3_object_info:
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result.objects
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: List all objects in specific bucket
  s3_object_info:
    bucket: steamybucket
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result.objects
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: List objects with specified keys, regardless of the bucket they are in
  s3_object_info:
    keys:
      - xobject
      - lobject
      - aobject
      - bobject
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result.objects
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Display specific objects in a specific bucket
  s3_object_info:
    bucket: steamybucket
    keys:
      - xobject
      - lobject
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result.objects

Inputs

    
auth:
    description:
    - Parameters for authenticating with the AWS service. Each of them may be defined
      via environment variables.
    suboptions:
      access_key:
        description:
        - The AWS access key ID. If not set, the value of the AWS_ACCESS_KEY environment
          variable will be checked.
        - Mutually exclusive with I(profile).
        required: false
        type: str
      profile:
        description:
        - The name of the AWS profile configured with C(aws configure).
        - Can be used instead of explicitly specifying your access credentials and region.
        - Use C(default) to use the default profile.
        - Mutually exclusive with I(access_key) and I(secret_key).
        required: false
        type: str
      region:
        description:
        - The name of the AWS region.
        - If not set, the value of the AWS_REGION environment variable will be checked.
        - If you set a I(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:
        description:
        - The AWS secret access key. If not set, the value of the AWS_SECRET_KEY environment
          variable will be checked.
        - Mutually exclusive with I(profile).
        required: false
        type: str
      url:
        description:
        - 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.
        required: false
        type: str
    type: dict

keys:
    description: Limit results to the specified objects only
    elements: str
    type: list

bucket:
    description: Limit results to the specified S3 Bucket only
    type: str

Outputs

objects:
  contains:
    bucket:
      description: Name of S3 Bucket.
      returned: always
      sample: steamybucket
      type: str
    etag:
      description: The entity tag (an MD5 hash) of the S3 object's contents.
      returned: always
      sample: 54292ef8bb5854ef3f9d32df302ed245
      type: str
    key:
      description: The S3 object's key name.
      returned: always
      sample: file.txt
      type: str
    last_modified:
      description: Date and time of the S3 object's last modification.
      returned: always
      sample: '2020-06-24T11:50:15+00:00'
      type: str
    metadata:
      description: User-defined metadata of the S3 object.
      returned: always
      sample:
        foo: bar
      type: dict
    owner:
      description: The owner of the S3 object.
      returned: always
      sample:
        id: ff686298db457b3ac7
        name: xlab
      type: dict
    size:
      description: Size of the object's content in bytes.
      returned: always
      sample: 433937
      type: str
    storage_class:
      description: The storage class of the S3 object.
      returned: always
      sample: standard
      type: str
    tags:
      description: Tags associated with the S3 object.
      returned: always
      sample:
        App: test-app
      type: dict
  description:
  - List of S3 objects
  returned: success
  type: list

See also