Automated SNS notification

This sample creates a service that will automatically send a notification via AWS Single Notification Service (SNS) when a file is located in a specified directory and any changes are made to the file.

To achieve this, our Linx solution will use the Amazon SNS plugin and the DirectoryWatch service contained in the File plugin.

Pre-requisites

  • AWS user credentials and permissions have been set up on IAM to allow the user to perform the SNS Publish function.

  • The associated Amazon SNS Topic and Subscription have already been created.


Download

AmazonSNSnotification.zip


To run the sample

  1. Download the sample file (AmazonSNSnotification.zip).

  2. Open the Notification solution with Linx Designer.

  3. Click the Settings button on the toolbar.

  4. On the Settings tab enter the AWS credentials of a user that has been registered on AWS IAM and has the required permissions for SNS.

    Example (where the values of the mandatory variables are presented by X’s):

    _{"Key":"XXXXXXXXXXXXX", "KeySecret":"XXXXXXXXXXXXXXXXX", "RegionEndpoint":"XXXXXXXXXX", "UserAccountNumber":"999999999999", "UserName":"XXXXXXXXXX"}_
    
  5. Update the Topic ARN to reference your actual existing topic on AWS.

  6. In the Properties section for the DirectoryWatch service, note the Path value: c:\temp\backup - update this value to a suitable path, or create the c:\temp\backup directory on your machine.

  7. Follow the steps provided to recreate the end-to-end implementation of the sample.


Creating the sample

The following steps can be used to re-create the solution used in this sample, or to use as a guide when deploying and running the sample:

  1. Create a Solution, Project, and Process with descriptive names.

  2. Add the following Plugins to your Solution:

    • Amazon SNS
    • File
  3. From the Amazon SNS plugin, add the Publish function to your process, and rename it to Notify.

  4. Click on the Notify function in the main canvas, then enter the following key details in the Properties section:

    a. AWS Credentials of the user performing the function

    b. Subject – a subject for the email (notification) to be sent

    c. Message – the message for the email (notification) to be sent

    d. Topic ARN – The topic you want to publish to

  5. From the File plugin, add the DirectoryWatch Service to the Project.

  6. Enter the details of the Properties associated with the DirectoryWatch Service:

    a. Notify filter – select FileName, Size, and LastWrite

    b. Watch options – Select Watch for Changes

    c. Path – indicate the path of the directory to watch

    The effect of the above settings are: if any changes occur to the name, size or date/time of the last file update of any file in the specified directory, then ChangedEvent will be triggered.

  7. Set up ChangedEvent by doing the following:

    a. Click on ChangedEvent in the Solution Explorer section

    b. Drag and drop Notify from the Solution Explorer section onto the main canvas – the effect of this is that, when triggered, ChangedEvent will call the Notify function

  8. Debug the process

    For details on how to debug, please go here

  9. Deploy the Solution to Linx Server

    For details on how to deploy your Solution, please go here

  10. Start the Service on Linx Server by doing the following:

    a. Log in to Linx Server

    b. Select the applicable Solution

    c. Click the Start button to start the service

  11. Verify the successful backup of your files

    To check whether your service is executing as expected, do the following:

    a. From the specified directory, change a file’s content and save the file

    b. On Linx Server, check that the Event executed successfully

    c. Check that the email notification was received and that the subject and content are correct