Skip to main content

Amazon S3 for data import Data Source

An Amazon S3 for data import Data Source pulls JSON, YAML or XML files from an Amazon S3 bucket and recursively into directories, and loads the files into Styra DAS. It uses Rego for transformation or filtering on data before it is loaded into Styra DAS. It authenticates using IAM access key and secret access key that is stored as a secret in Styra DAS.

Configuring Data Source through the Styra DAS UI

Configure <das-id>.styra.com to access a JSON object import Data Source using the Styra DAS UI.

  1. Login to the Styra DAS UI.
  2. Select the System to add the Data Source.
  3. Click the kebab icon (three dots ⋮) to the right of the System and select Add Data Source. The Add Data Source dialog box appears.
  4. Select Amazon S3 for JSON object import.
  5. In Path type a new or existing path separated by /. For example, datasourcetypes.
  6. In Data source name (required) type a name for the Data Source type. For example, Amazon S3 for JSON object import.
  7. (Optional) Type in a Description.
  8. In AWS region (required) select your AWS region from the drop-down selection.
  9. In Bucket Name (and Path) (required) type a string representing the bucket name. Enter the bucket name and a path within that bucket. For example, amazon-s3-bucket-testing. For more information on how to setup an AWS user and S3 bucket for secure Styra DAS to Amazon S3 access, see Amazon S3 Bucket Access page.
    note
    • If only one file is returned from Amazon S3 then the result contains the content of that file. For example, if the bucket name and path is tests3/test.json the result is {"foo": "bar"}.
    • If multiple files are returned from Amazon S3 then the result will have additional layers with the full folder structure and file names to avoid collisions. For example, if the bucket name and path is bucket and path: tests3/data the result is {"data": {"file.json": {"foo": "bar"}}}.
  10. In Endpoint override type a gateway endpoint. For more information, see Amazon S3 Endpoints.
  11. In Refresh interval type a refresh interval which is the amount of time between polling intervals. Default is s.
  12. In Access Keys for IAM Users type the following access key credentials.
    • In Access Key ID (required) type the access key ID. For more information, see AWS IAM User Access Keys.
    • In Secret Access Key (required) type the Styra DAS secret you are using for an Amazon S3 bucket within your own AWS account.
  13. (Optional) Click the arrow to expand the Advanced field.
  14. In Data transform specify a policy and write a query that allows you to apply Rego transformations before it is persisted as data. For example, Select Custom and fill in the following fields:
    • In Policy type an existing policy separated by /. For example, transform/transform.rego.
    • In Rego querytype a path to the Rego rule to evaluate. For example, data.transform.query.
  15. Leave the Enable on-premises data source agent switch off.
  16. ClickAdd.

The following shows an example output which appears after the data source is created in DAS.

{
"data": {
"s3-test.json": {
"foo1": "bar1"
},
"s3-test.yaml": {
"foo3": "bar3"
},
"s3-test.yml": {
"foo2": "bar2"
}
}
}