Skip to main content

AWS S3

Prerequisites

Prerequisites

Before setting up the AWS S3 integration, ensure you have:

Setup an IAM user

An IAM user has permanent long-term credentials and is used to directly interact with AWS services like S3.

  1. Sign in to the AWS Management Console and open the IAM console

  2. In the navigation pane, choose Users, then click Create user

  3. Enter a name for the user (e.g., dashx-s3-user) and click Next

  4. Choose Attach policies directly

  5. Create a new policy by clicking Create policy:

    • Choose the JSON tab
    • Paste the following policy:
    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Effect": "Allow",
    "Action": [
    "s3:PutObject",
    "s3:GetObject",
    "s3:DeleteObject",
    "s3:ListBucket"
    ],
    "Resource": [
    "arn:aws:s3:::YOUR-BUCKET-NAME/*",
    "arn:aws:s3:::YOUR-BUCKET-NAME"
    ]
    }
    ]
    }
    • Replace YOUR-BUCKET-NAME with your actual S3 bucket name and Click Next
    • Name the policy (e.g., DashXS3Policy) and provide a description
    • Click Create policy
  6. Return to the user creation tab and refresh the policy list

  7. Search for and select the policy you just created and Click Next

  8. Review the user details and click Create user

  9. After the user is created, click on the user name to go to their details page

  10. Go to the Security credentials tab

  11. Under Access keys, click Create access key

  12. Choose Command Line Interface (CLI) as the use case

  13. Click Next, then click Create access key

warning

Make sure to securely store your Access key ID and Secret access key. For security reasons, you won't be able to retrieve the Secret access key again after leaving this page.

Setup S3 Bucket Policy

To ensure your S3 bucket has the correct permissions, you need to set up a bucket policy. Follow these steps:

  1. Open the S3 console.
  2. In the left navigation pane, choose General purpose buckets.
  3. In the Buckets list, choose the name of the bucket that you want to set the policy for.
  4. Choose the Permissions tab.
  5. In the Bucket policy section, choose Edit.
  6. Paste the following bucket policy into the editor:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
}
]
}
  • Replace YOUR-BUCKET-NAME with your actual S3 bucket name.
  1. Choose Save changes.

Note: This bucket policy allows public read access to the objects within your bucket. It is essential for enabling users to access the files stored in your S3 bucket via the web. However, be cautious with this setting as it makes your files publicly accessible. Adjust the policy according to your security requirements.

Setup S3 bucket CORS Configuration

  1. Next, set up CORS configuration for your bucket:
  • In the Permissions tab, scroll down to the Cross-origin resource sharing (CORS) section.
  • Choose Edit.
  • Paste the following CORS configuration into the editor:
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT"
],
"AllowedOrigins": [
"https://YOUR-WORKSPACE-DOMAIN.dashx.com"
],
"ExposeHeaders": [],
"MaxAgeSeconds": 3600
}
]
  • Replace YOUR-WORKSPACE-DOMAIN with your actual workspace domain.
  1. Choose Save changes to apply the CORS configuration.

Note: The CORS configuration is necessary to allow your web application, hosted on your workspace domain, to interact with the S3 bucket. This setting ensures that your application can perform operations like uploading files to the bucket from the specified domain.

Setup S3 bucket Event Notifications

Before setting up EventBridge rules, you need to enable event notifications on your S3 bucket:

  1. Open the S3 console.
  2. In the left navigation pane, choose General purpose buckets.
  3. In the buckets list, choose the name of the bucket that you want to enable events for.
  4. Choose Properties.
  5. Navigate to the Event Notifications section and find the Amazon EventBridge subsection. Choose Edit.
  6. Under "Send notifications to Amazon EventBridge for all events in this bucket" choose On.
  7. Save your changes.

Setup Webhooks on Amazon EventBridge

Since DashX performs client-side uploads, setting up webhooks is essential to handle events effectively. Follow these steps to configure webhooks using Amazon EventBridge:

  1. Navigate to the Amazon EventBridge console at https://console.aws.amazon.com/events/.
  2. In the navigation pane, select Rules.
  3. Click on Create rule.
  4. Provide a name and description for the rule, such as DashXUploadRule and click on Next.
  5. Under Build event Pattern, select Use pattern form.
    1. Set Event source to AWS services.
    2. For AWS Service, select S3.
    3. For Event type, select Amazon S3 Event Notification.
    4. For Event Type Specification 1 select ObjectCreated.
    5. For Event Type Specification 2 select Specific bucket(s) by name.
    6. For Bucket name, add your bucket name.
    7. Click Next.
  6. Under Select targets, choose EventBridge API destination.
    1. For API destination, select Create a new API destination.
    2. Fill in the following details for the API destination:
      • Name: DashXClientAPIDestination
      • Description: API destination for DashX client-side uploads
      • API endpoint: https://api.dashx.com/webhooks/YOUR-UNIQUE-WEBHOOK-ID
        • To get the endpoint, log in to your DashX workspace, navigate to the Integrations section, and find the Webhook value for the desired environment. Copy the URL of the webhook you want to use.
      • HTTP method: POST
    3. Set the Invocation rate limit according to your needs.
    4. Under Connection, choose Create a new connection.
    5. Fill in the following details for the connection:
      • Connection name: DashXConnection
      • Description: Connection for DashX client-side uploads
    6. Under Execution role, select Use existing role.
    7. Choose the appropriate role that has the necessary permissions to invoke the API destination.
    8. Click Next.
  7. Review your settings and click Create rule.

Note: This configuration enables forwarding of events from AWS S3 to DashX using EventBridge. Ensure the API endpoint and other settings align with your DashX workspace.