S3 (Simple Storage Service)

This document contains information about the S3 service supported in Handel. This Handel service provisions an S3 bucket for use by your applications.

Note

For static websites in S3, see the S3 Static Site service.

Service Limitations

This service currently only provisions a bare-bones S3 bucket for data storage. It does support versioning, but the following other features are not currently supported:

  • CORS configuration
  • Bucket logging
  • Cross-region replication

Parameters

This service takes the following parameters:

Parameter Type Required Default Description
type string Yes   This must always be s3 for this service type.
bucket_name string No <appName>-<environmentName>-<serviceName>-<serviceType> The name of the bucket to create. This name must be globally unique across all AWS accounts, so ‘myBucket’ will likely be taken. :)
bucket_acl string No   Warning: A canned access control list (ACL) that grants predefined permissions to the bucket. These are global permissions ie, PublicRead means the bucket is open to the world. Allowed values: AuthenticatedRead, AwsExecRead, BucketOwnerRead, BucketOwnerFullControl, LogDeliveryWrite, Private, PublicRead
versioning string No disabled Whether to enable versioning on the bucket. Allowed values: enabled, disabled
logging string No disabled Whether to enable logging on the bucket. Allowed values: enabled, disabled.
lifecycles Lifecycles No   Lifecycle Policies to apply to the bucket. See AWS Docs for more info
tags Resource Tags No   Any tags you want to apply to your S3 bucket

Lifecycles

A list of life cycle rules

lifecycles:
  - name: <string> # Required
    prefix: <string> # Optional
    transitions: # Optional but one of transitions or version_transitions are required
      - type: <ia, glacier, expiration> # type must be ia (Standard-IA infrequent Access), glacier, or expiration)
        days: 30
    version_transitions: # Optional but one of transitions or version_transitions are required, only days are supported
      - type: <ia, glacier, expiration>
        days: 30

Transitions are defined by the following:

Parameter Type Required Default Description
type string Yes None Type of transition must be one of ia(Standard Infrequent Access), glacier, expiration (deletion)
days integer No None Number of days until transition must specify all transition as days or dates not both
date ISO 8601 UTC No None Date to transition in ISO 8602 UTC format must specify all transition as days or dates not both

More complex example:

lifecycles:
  - name: ia30glacier365expire720
    transitions:
      - type: ia
        days: 30
      - type: expiration
        days: 720
      - type: glacier
        days: 365
    version_transitions:
      - type: ia
        days: 30
      - type: expiration
        days: 90

Example Handel File

Simple Bucket

This Handel file shows an S3 service being configured:

version: 1

name: my-s3-bucket

environments:
  dev:
    mybucket:
      type: s3
      # Because we don't specify a bucket_name, the bucket will be named 'my-s3-bucket-dev-mybucket-s3' (see default in table above)
      versioning: enabled

S3 Events

This Handel file shows an S3 service that is configured to send events to a Lambda function:

version: 1

name: test-s3-events

environments:
  dev:
    function:
      type: lambda
      path_to_code: .
      handler: index.handler
      runtime: python3.6
    bucket:
      type: s3
      event_consumers:
      - service_name: function
        bucket_events:
        - s3:ObjectCreated:*
        filters:
        - name: prefix
          value: somefolderprefix

Filters for Bucket Suffixes are also supported.

Depending on this service

This service outputs the following environment variables:

Environment Variable Description
<SERVICE_NAME>_BUCKET_NAME The name of the created bucket
<SERVICE_NAME>_BUCKET_URL The HTTPS URL of the created bucket
<SERVICE_NAME>_REGION_ENDPOINT The domain of the S3 region endpoint, which you can use when configuring your AWS SDK

See Environment Variable Names for information about how the service name is included in the environment variable name.

Events produced by this service

The CloudWatch Events service currently produces events for the following services types:

  • Lambda
  • SNS
  • SQS

Events consumed by this service

The S3 service does not consume events from other Handel services.