Create SQS action
You need an Amazon SQS queue and an IAM role. If you have both, go to Configure Admin Portal.
Use Terraform
resource "aws_sqs_queue" "pubnub_queue" {
name = "pubnub-example"
fifo_queue = false
}
data "aws_iam_policy_document" "pubnub_sqs_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::535363102202:root"]
}
show all 55 linesCreate a queue
-
Open Amazon SQS. Go to Queues.
-
Click Create queue. Enter a name.
Supported queue type
Events & Actions supports the standard queue type.
-
Click Create queue.
-
Copy the Queue URL.
Create an IAM role
Create an IAM role with SQS write permission.
-
Open AWS Identity and Access Management. Go to Roles.
-
Click Create role. Name the role.
-
Set AWS account as the Trusted entity type.
-
In An AWS account, select Another AWS account. Enter 535363102202 as the Account ID. This is PubNub’s AWS account ID. PubNub uses this role to write to your queue.
-
Select Require external ID.
-
Paste your app's subscribe key from the Admin Portal into External ID.
Optional but recommended by AWS. It sets your subscribe key as the external ID for PubNub. Access policy example:
show all 17 lines{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::535363102202:root"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "<PubNub subscribe key>"
}
}
}Click Next.
-
Create a policy with
sqs:SendMessage
. Click Create policy. Switch to JSON. Paste this snippet. Use your queue ARN:{
"Statement": [
{
"Action": [
"sqs:SendMessage"
],
"Effect": "Allow",
"Resource": "<ARN of customer's SQS queue>"
}
],
"Version": "2012-10-17"
}Complete the policy in the wizard.
-
Select the policy. Click Next (Step 3).
-
Name the role.
-
Click Create Role.
-
Copy the Role ARN.
Configure Admin Portal
- Open Events & Actions in the Admin Portal. Click + Add Action.
- Select Amazon SQS.
- Paste the Queue URL and Role ARN.
- (Optional) Enable and configure retries in SQS retry.
- Pair the action with an event listener in Actions. Click Add event listener. Select an existing listener or create one.
- Click Save changes.