Navigation

Amazon S3 Service

Warning

This service has been deprecated and replaced with the more general AWS Service. This documentation is provided solely to support existing Stitch apps.

Amazon S3 is a component of Amazon Web Services that provides a simple key-value store useful for storing and serving static resources.

You will need the following to integrate Amazon S3 with your MongoDB Stitch app:

  • At least one globally-readable S3 bucket.
  • An Amazon AWS user with PutObject permission on that bucket and an access key pair.

Add an Amazon S3 Service

To set up an Amazon S3 service in MongoDB Stitch:

  1. Click Services in the left navigation pane and click Add a Service.
  2. Select the S3 box.
  3. Enter a name for your service in the Service Name box.
  4. Select the Amazon Region where you deployed your bucket (the US Standard region is us-east-1).
  5. Enter your Amazon Access Key ID and Secret Access Key. To see how you can view and manage your AWS keys, see Managing Access Keys for your AWS Account.
  6. Click Add service.

Service Actions

The Amazon S3 service in MongoDB Stitch provides the following actions which are available in functions and in the SDKs:

Action Description
s3Service.put() Uploads a binary data to an S3 bucket.
s3Service.signPolicy() Generates a document that contains the policy, signature, and credential, which you can use to issue a POST request directly to S3.

For general information on service actions and how to use them, see Service Actions.

Service Rules

You must specify rules to enable the S3 actions. A rule must evaluate to true to enable the action. For general information on service rule construction and syntax, see Service Rules.

The following arguments are permitted in S3 service rules, and they can be accessed with the "%%args" expansion:

Field Type Description
bucket String The S3 bucket name.
key String The object key, or key name, which uniquely identifies the object in the bucket; i.e. the path to the object in the bucket.
acl String

The access control list (ACL) permissions. The value can be one of the following strings:

  • "private"
  • "public-read"
  • "public-read-write"
  • "aws-exec-read"
  • "authenticated-read"
  • "bucket-owner-read"
  • "bucket-owner-full-control"
contentType String The MIME type of the content, such as text/plain or audio/mpeg.

Example

Actions When
put
{
  "bucket" : { "%in": "%%values.mybuckets" },
  "contentType" : "text/plain"
}

This Amazon S3 service rule ensures that applications can only perform a put action when:

  • the bucket is a string listed in mybuckets, where mybuckets is a user-defined constant. For more information on defining constants, see Values.
  • the contentType is "text/plain".