Buttonize logo

SQS Queue Message Form

SQS
SQS

Create a simple user interface for your team to publish messages to SQS queues. No need anymore to build cumbersome frontends, auth and APIs just to send a simple message to SQS queue.

SqsQueueMessageForm construct is a simple way how to enable anyone in the team to publish messages to SQS queues with pre-defined message shape.

Features

  • Easily send a message to SQS queue
  • Define arbitrary number of input fields
  • Resend the message again
  • Define message attributes
  • Build a custom message shape
  • Display custom instructions to give a guidance to the users

Preview

SQS Queue Message Form App preview

Usage

lib/example-stack.ts
import * as cdk from 'aws-cdk-lib'
import { Queue } from 'aws-cdk-lib/aws-sqs'
import { Buttonize, Input } from 'buttonize/cdk'
import { SqsQueueMessageForm } from 'buttonize/library'
import { Construct } from 'constructs'
export class ExampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props)
Buttonize.init(this, { apiKey: 'YOUR_API_KEY' })
const queue = new Queue(this, 'SqsQueue')
new SqsQueueMessageForm(this, 'QueueMessageForm', {
name: 'Product cache invalidation panel',
description:
'Trigger invalidation of a product in all the caches in the in the company systems',
queue,
submitButtonLabel: 'Invalidate',
fields: [
Input.text({
id: 'id',
label: 'Product ID'
}),
Input.select({
id: 'reason',
options: [
{ label: 'New manual update', value: 'manual_update' },
{ label: 'System bug', value: 'bug' }
]
})
],
messageAttributes: {
operation: 'invalidate'
},
messagePayload: {
product: {
pid: '{{id}}'
},
metadata: {
reasonStatement: '{{reason.value}}'
}
}
})
}
}

SQS receive message response sample.json
{
"Messages": [
{
"Body": "{\"metadata\":{\"reasonStatement\":\"manual_update\"},\"product\":{\"pid\":\"123\"}}",
"MessageAttributes": {
"operation": { "StringValue": "invalidate", "DataType": "String" }
}
}
]
}

Simplified key-value fields definition

Buttonize uses Input.text component for the input elements.

lib/example-stack.ts
new SqsQueueMessageForm(this, 'QueueMessageForm', {
queueArn: 'arn:aws:sqs:<region>:<account-number>:<queue-name>',
fields: {
name: 'What is your name?'
}
/*
Same like:
fields: [
Input.text({
id: 'name',
label: 'What is your name?'
})
]
*/
})

SQS receive message response sample.json
{
"Messages": [
{
"Body": "{\"name\":\"John Doe\"}"
}
]
}
Setup
New repository
npx create-buttonize --template library/sqs-queue-message-form --api-key=YOUR_API_KEY
Existing repository
import { Buttonize } from 'buttonize/cdk'
import { SqsQueueMessageForm } from 'buttonize/library'
Buttonize.init(this, { apiKey: 'YOUR_API_KEY' })
new SqsQueueMessageForm(this, 'MessageForm', {
queue: yourSqsQueue,
fields: {
name: 'What is your name?'
}
})
Deploy
npx cdk deploy
Delete
npx cdk destroy
Package
npm buttonize
Source
github SqsQueueMessageForm.ts
Additional resources

Buttonize X.com profile Buttonize GitHub profile

© 2024 Buttonize OÜ

With ❤️ made in 🇨🇿

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.