This guide provides information on using SQS to publish events to Outpost.

Message Structure

SQS messages should have the same payload structure as the Publish API endpoint.

{
  "tenant_id": "<TENANT_ID>",
  "destination_id": "<DESTINATION_ID>", // Optional. Provide a way of routing events to a specific destination
  "topic": "topic.name", // Topic defined in TOPICS environment variable
  "eligible_for_retry": true | false, // Should event delivery be retried? Default is true.
  "metadata": Payload, // can be any JSON payload,
  "data": Payload // can be any JSON payload
}

Failed messages

When Outpost fails to process a message, it makes the message visible again and SQS redelivers it immediately, with no backoff and no limit. This includes messages that can never succeed, such as invalid JSON, data that is not a JSON object, or a missing topic when TOPICS is set. A message larger than MAX_EVENT_SIZE_BYTES is the exception: Outpost deletes it on its first delivery, so it never reaches your dead-letter queue.

Dead-lettering and redelivery limits are configured on your queue, not in Outpost. Set a redrive policy with a dead-letter queue and maxReceiveCount. Outpost resets the visibility timeout on failure, so the queue's visibility timeout does not delay redeliveries.

PUBLISH_MAX_REDELIVERIES sets a limit on the Outpost side instead: once a message has been redelivered that many times, Outpost deletes it. 0 deletes a message on its first failure. To keep those messages, set maxReceiveCount no higher than PUBLISH_MAX_REDELIVERIES so your dead-letter queue receives them first.

Configuration

Provide Outpost with connection and routing information for your SQS instance used for publishing events.

Environment Variables

PUBLISH_AWS_SQS_REGION="<REGION>"
PUBLISH_AWS_SQS_QUEUE="<QUEUE_NAME>"
PUBLISH_AWS_SQS_ACCESS_KEY_ID="<KEY_ID>"
PUBLISH_AWS_SQS_SECRET_ACCESS_KEY="<SECRET>"

Optionally, you can provide the PUBLISH_AWS_SQS_ENDPOINT environment variable to specify the endpoint URL for the SQS service. This can be useful for local development or when using a non-standard SQS endpoint.

Example

PUBLISH_AWS_SQS_REGION="eu-north-1"
PUBLISH_AWS_SQS_QUEUE="outpost-pub-queue"
PUBLISH_AWS_SQS_ACCESS_KEY_ID="REDACTED"
PUBLISH_AWS_SQS_SECRET_ACCESS_KEY="REDACTED"

YAML

publishmq:
  aws_sqs:
    region: <AWS_REGION>
    queue: <QUEUE_NAME>
    access_key_id: <KEY_ID>
    secret_access_key: <SECRET>

    # Optional.
    # Useful for local development or when using a non-standard SQS endpoint.
    endpoint: <URL>

    # Optional. See "Assuming an IAM role".
    role_arn: <ROLE_ARN>
    external_id: <EXTERNAL_ID>
    role_session_name: <SESSION_NAME>
    sts_region: <AWS_REGION>

Example

publishmq:
  aws_sqs:
    region: eu-north-1
    queue: outpost-pub-queue
    access_key_id: REDACTED
    secret_access_key: REDACTED

Assuming an IAM role

Outpost can read your queue through an IAM role that you create in your AWS account. No access key is shared with Hookdeck.

  1. In Hookdeck Publishing settings, turn on Publish events via a message queue, choose AWS SQS under Message queue provider and IAM role under Authentication. Enter the queue's Region and Queue name. The page then shows the two policies used in the next steps, filled in for your project.

  2. In the AWS console, go to IAM, Roles, Create role. Choose Custom trust policy and paste the trust policy from the page. It lets Hookdeck's role assume yours, and requires your project ID as the external ID. Choose Next twice, name the role, and choose Create role.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": { "AWS": "<HOOKDECK_ROLE_ARN>" },
          "Action": "sts:AssumeRole",
          "Condition": { "StringEquals": { "sts:ExternalId": "<PROJECT_ID>" } }
        }
      ]
    }
    
  3. Open the role, go to Permissions, Add permissions, Create inline policy. Choose JSON and paste the permissions policy from the page, replacing the account ID placeholder with your AWS account ID.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "sqs:ChangeMessageVisibility",
            "sqs:DeleteMessage",
            "sqs:GetQueueUrl",
            "sqs:ReceiveMessage"
          ],
          "Resource": "arn:aws:sqs:<REGION>:<ACCOUNT_ID>:<QUEUE_NAME>"
        }
      ]
    }
    
  4. Copy the role's ARN from its summary page into Role ARN and save.

Outpost's access appears in your CloudTrail logs under the session name outpost-<PROJECT_ID>. To remove access, delete the role or change its trust policy.

To set the role with the Config API instead of step 4, send PUBLISH_AWS_SQS_ROLE_ARN with PUBLISH_AWS_SQS_REGION and PUBLISH_AWS_SQS_QUEUE. A role can't be combined with an access key or a custom endpoint.

Outpost can read the queue through an IAM role. It assumes the role with the access key, or with the AWS SDK default credential chain (environment variables, shared config, or the role of the instance, task or pod it runs on) when no key is set.

  1. Create an IAM role with a trust policy that names the identity Outpost runs as. The Condition is optional; include it to require an external ID.

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": { "AWS": "<ARN of the user or role Outpost runs as>" },
          "Action": "sts:AssumeRole",
          "Condition": { "StringEquals": { "sts:ExternalId": "<EXTERNAL_ID>" } }
        }
      ]
    }
    
  2. Give the role the required permissions on the queue:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "sqs:ChangeMessageVisibility",
            "sqs:DeleteMessage",
            "sqs:GetQueueUrl",
            "sqs:ReceiveMessage"
          ],
          "Resource": "arn:aws:sqs:<REGION>:<ACCOUNT_ID>:<QUEUE_NAME>"
        }
      ]
    }
    
  3. If Outpost runs in a different AWS account from the role, also allow its identity to call sts:AssumeRole on the role.

  4. Configure Outpost with the role. Leave out the access key to use the default credential chain. Set the external ID only if the trust policy requires one.

    PUBLISH_AWS_SQS_REGION="<REGION>"
    PUBLISH_AWS_SQS_QUEUE="<QUEUE_NAME>"
    PUBLISH_AWS_SQS_ROLE_ARN="arn:aws:iam::<ACCOUNT_ID>:role/<ROLE_NAME>"
    PUBLISH_AWS_SQS_EXTERNAL_ID="<EXTERNAL_ID>"
    

The session is named outpost in the role account's CloudTrail logs; set PUBLISH_AWS_SQS_ROLE_SESSION_NAME to change it.

Outpost calls STS in the queue's Region. If that Region isn't enabled for the identity Outpost runs as, such as an opt-in Region enabled only in the queue's account, set PUBLISH_AWS_SQS_STS_REGION to a Region it can use, such as us-east-1.

Required Permissions

The following permissions are required for the provided access key. When a role is set, they go on the role instead.

  • sqs:ChangeMessageVisibility
  • sqs:DeleteMessage
  • sqs:GetQueueUrl
  • sqs:ReceiveMessage

Health

In a self-hosted deployment, if the publish consumer fails (it can't subscribe, or 10 receives fail in a row, about 70 seconds), /healthz reports it failed (HTTP 503) until the process restarts. You can turn on restarts instead by adding publishmq to SUPERVISOR_RESTART_WORKERS: Outpost then restarts the consumer with a backoff and reports it degraded while it retries. See Supervisor for the limits after which it reports failed.

Troubleshooting