Documentation

    PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.21

    Documentation for other releases can be found by using the version selector in the top right of any doc page.

    aws_s3

    Manage AWS S3 objects for cloud storage operations.

    Attributes

    check_mode:
      support: full
    

    Parameters

    Parameter Required Type Values Description
    bucket true string   The S3 bucket name.
    object   string   The S3 object key path.
    src   string   Local file path to upload (required for mode=put).
    dest   string   Local file path to download (required for mode=get).
    mode   string get
    put
    delete
    list
    The operation mode: get, put, delete, or list.
    region   string   AWS region. If not provided, uses AWS_REGION or AWS_DEFAULT_REGION environment variable.
    endpoint   string   Custom S3 endpoint URL (for S3-compatible services like MinIO).
    access_key   string   AWS access key ID. If not provided, uses AWS_ACCESS_KEY_ID environment variable.
    secret_key   string   AWS secret access key. If not provided, uses AWS_SECRET_ACCESS_KEY environment variable.
    prefix   string   Prefix to filter objects when listing.
    max_keys   integer   Maximum number of objects to return when listing.

    Examples

    - name: Download file from S3
      aws_s3:
        bucket: my-bucket
        object: config/app.yaml
        dest: /etc/app/config.yaml
        mode: get
    
    - name: Upload file to S3
      aws_s3:
        bucket: my-bucket
        object: backups/data.tar.gz
        src: /tmp/data.tar.gz
        mode: put
    
    - name: Delete object from S3
      aws_s3:
        bucket: my-bucket
        object: old/backup.tar.gz
        mode: delete
    
    - name: List objects in bucket
      aws_s3:
        bucket: my-bucket
        mode: list
      register: s3_objects
    
    - name: Upload with custom endpoint (MinIO)
      aws_s3:
        bucket: my-bucket
        object: data/file.txt
        src: /tmp/file.txt
        mode: put
        endpoint: http://minio:9000
    
    - name: Download with specific region
      aws_s3:
        bucket: my-bucket
        object: config.yaml
        dest: /tmp/config.yaml
        mode: get
        region: us-west-2