Providing you are a LUSID user with sufficient access control permissions, you can create a notification to send to Amazon SQS when an event you have subscribed to occurs. For example, you could queue a SQS message when the LUSID ‘portfolio created’ event occurs.
- Method 1: Using the Notification REST API
- Method 2: Using the LUSID web app
- Method 3: Using Luminesce
Using the Notification REST API
Currently, you can create one notification per API call. Note you must have already subscribed to the event you want to attach the Amazon SQS notification to.
- Before you can create a notification, you must perform a one-time setup of your AWS credentials in the LUSID Configuration Store. You need to create a configuration set containing the following:
- A Key of
apiKey
with a Value containing your AWS access key ID. - A Key of
apiSecret
with a Value containing your AWS secret access key. - A Key of
queueUrl
with a Value containing your SQS queue URL. See how to upload credentials to the Configuration Store.
- A Key of
- Obtain an API access token.
- Call the CreateNotification API for your LUSID domain, passing in your API access token and:
- The
scope
andcode
of the subscription to attach it to. - A unique
notificationId
. - A
displayName
and, optionally,description
. - A
notificationType
containing:- A
Type
ofAmazonSqs
. - A
Body
containing the notification message. You can use attributes of the subscribed event in mustache templates to make the text more meaningful. - An
ApiKeyRef
containing the reference toapiKey
in the configuration set created earlier. For example, if you created a shared configuration set with scopeAWS
and codeSQS
, you might enterconfig://shared/AWS/SQS/apiKey
. - An
ApiSecretRef
containing the reference toapiSecret
in the configuration set created earlier. For example, if you created a shared configuration set with scopeAWS
and codeSQS
, you might enterconfig://shared/AWS/SQS/apiSecret
. - An
QueueUrlRef
containing the reference toqueueUrl
in the configuration set created earlier. For example, if you created a shared configuration set with scopeAWS
and codeSQS
, you might enterconfig://shared/AWS/SQS/queueUrl
.
- A
- The
For example, to attach an Amazon SQS notification to a subscription with the scope PortfolioEvents
and code PortfolioCreated
you might send the following:
curl -X POST "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreated/notifications"
-H "Authorization: Bearer <your-API-access-token>"
-H "Content-Type: application/json"
-d '{
"notificationId": "SqsNotification1",
"displayName": "AwsSqsNotification",
"description": "Notification for AWS SQS",
"notificationType": {
"Type": "AmazonSqs",
"Body": "Portfolio created in scope {{Body.portfolioScope}} with code {{Body.portfolioCode}}",
"ApiKeyRef": "config://shared/AWS/SQS/apiKey",
"ApiSecretRef": "config://shared/AWS/SQS/apiSecret",
"QueueUrlRef": "config://shared/AWS/SQS/queueUrl"
}
}'
The response is as follows. Note you can use the notificationId
to reference the notification again in subsequent API calls:
{
"notificationId": "SqsNotification1",
"displayName": "AwsSqsNotification",
"description": "Notification for AWS SQS",
"notificationType": {
"type": "AmazonSqs",
"body": "Portfolio created in scope {{Body.portfolioScope}} with code {{Body.portfolioCode}}",
"apiKeyRef": "config://shared/AWS/SQS/apiKey",
"apiSecretRef": "config://shared/AWS/SQS/apiSecret",
"queueUrlRef": "config://shared/AWS/SQS/queueUrl"
},
"createdAt": "2023-08-03T09:41:52.6175307+00:00",
"userIdCreated": "00uji4twb3jDcHGjN2p8",
"modifiedAt": "2023-08-03T09:41:52.6175307+00:00",
"userIdModified": "00uji4twb3jDcHGjN2p8",
"href": "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreated/notifications/SqsNotification1"
}
Using the LUSID web app
<Coming soon>