Documentation for Automation with AWS AWS 1.0 – other releases are available in the Automation with AWS Documentation Directory.
View

Unknown macro: {spacejump}

or visit the current documentation home.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

Use the Publish SNS Message action to relay Bamboo notifications, JIRA workflow transitions and JIRA Service Desk automation rule executions via the Amazon Simple Notification Service (SNS), a fast, flexible, fully managed push notification service that lets you send individual messages or to fan-out messages to large numbers of recipients:

Amazon SNS makes it simple and cost effective to send push notifications to mobile device users, email recipients or even send messages to other distributed services.

With Amazon SNS, you can send notifications to Apple, Google, Fire OS, and Windows devices, as well as to Android devices in China with Baidu Cloud Push. You can use SNS to send SMS messages to mobile device users worldwide.

Beyond these endpoints, Amazon SNS can also deliver messages to Amazon Simple Queue Service (SQS), AWS Lambda functions, or to any HTTP endpoint.

Integrations

You can use the Publish SNS Message action with the following integrations:

Filter by label

There are no items with the selected labels at this time.

Requirements

The Publish SNS Message action requires sufficient IAM permissions - an adequate IAM policy similar to the one provisioned by the Automation with AWS (Core) CloudFormation template might look as follows:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "sns:GetTopicAttributes",
                "sns:ListTopics",
                "sns:Publish"
            ],
            "Resource": "*",
            "Effect": "Allow",
            "Sid": "SNSPublishMessageAndDiscoverTopics"
        }
    ]
}

(lightbulb) Refer to Controlling User Access to Your AWS Account for details on how to create more granular/secure policies, including a few Example Policies for Amazon SNS.

Configuration

To configure a Publish SNS Message action:

  1. Complete the following settings:

    Parameters

    Specify the action parameters according to the following skeleton in JSON format – refer to sns . publish for details:

    You must specify exactly one parameter out of TopicArn, PhoneNumber or TargetArn.

    You can inject contextual variables into the remote action payload, refer to Entity Variables for details.

    Publish SNS Message skeleton
    {
        "TopicArn": "",
        "TargetArn": "",
        "PhoneNumber": "",
        "Message": "",
        "Subject": "",
        "MessageStructure": "",
        "MessageAttributes": {
            "KeyName": {
                "DataType": "",
                "StringValue": "",
                "BinaryValue": null
            }
        }
    }

Entity Variables

You can inject contextual variables with workflow entities into the remote action payload template – currently available entities are:

  • Page:
    DeploymentResult — The Bamboo ${deploymentResult} entity returns the following JSON shape:
    DeploymentResult shape (JSON)
    {
      "agentId": "<>",
      "deploymentVersionName": "<>",
      "environmentId": "<>",
      "executedDate": "<>",
      "finishedDate": "<>",
      "id": "<>",
      "queuedDate": "<>",
      "reasonSummary": "<>",
      "startedDate": "<>"
    }
  • Page:
    Plan — The Bamboo ${plan} entity returns the following JSON shape:
     Plan shape (JSON)
    {
      "averageBuildDuration": "<the average duration of the recent builds>",
      "buildKey: "<the build's unique key>",
      "buildName": "<the build specific portion of the name>",
      "currentStatus": "<a string key as to what the status is>",
      "description": "<the instant messaging content>",
      "firstBuildNumber": "<the number of the first build>",
      "id": "<the database id of the plan>",
      "key": "<the plan's unique key>",
      "lastBuildNumber": "<the number of the latest build>"
    }


  • Page:
    ResultsSummary — The Bamboo ${resultsSummary} entity returns the following JSON shape:
    ResultsSummary shape (JSON)
    {
      "buildAgentId": "<the id of the latest agent that built the result>",
      "buildCancelledDate": "<when the build was cancelled>",
      "buildCompletedDate": "<when the build finished>",
      "buildDate": "<>",
      "buildNumber": "<>",
      "buildTime": "<>",
      "changesListSummary": "<>",
      "duration": "<the duration of the build in milliseconds>",
      "durationDescription": "<the duration in a 'pretty' format>",
      "formatVersion": "<>",
      "id": "<>",
      "logSize": "<the size of the log file associated with this result>",
      "processingDuration": "<>",
      "processingDurationDescription": "<>",
      "queueTime": "<>",
      "reasonSummary": "<>",
      "relativeBuildDate": "<>",
      "relativeBuildStartedDate": "<the relative started time (duration) compared to current date>",
      "relativeQueueDate": "<>",
      "restartCount": "<>",
      "shortReasonSummary": "<>",
      "testSummary": "<>",
      "timeToFix": "<the stored version of how long (milli seconds) it took for this build to fix a failure>"
    }
  • Page:
    Comment

    The Jira ${comment} entity returns the same JSON shape returned from the Jira REST API when a comment is retrieved – refer to the GET /rest/api/2/issue/{issueIdOrKey}/comment documentation for details.

  • Page:
    User

    The Jira ${user} entity returns the same JSON shape returned from the Jira REST API when a user is retrieved – refer to the GET /rest/api/2/user documentation for details.

  • Page:
    Issue

    The Jira ${issue} entity returns the same JSON shape returned from the Jira REST API when an issue is retrieved with NO expand parameters – refer to the GET /rest/api/2/issue/{issueIdOrKey} documentation for details.

  • Page:
    Notification — The Bamboo ${notification} entity returns the following JSON shape:
    Notification shape (JSON)
    {
      "description": "<a description>",
      "emailSubject: "<the email subject>",
      "htmlEmailContent": "<the HTML email content>",
      "imContent": "<the instant messaging content>",
      "textEmailContent": "<the text email content>"
    }
  • Page:
    Event — The core ${event} entity returns the following JSON shape:
    Event shape (JSON)
    {
      "traceId": "<UUID>",
      "timestamp: "<ISO 8601>"
      "simpleName": "<simple Java class name, if available>"
    }

Examples

  • Page:
    Publish SNS Message - raw text format — This parameters template demonstrates publishing a SNS message in raw text format with the Publish SNS Message action:

    Publish SNS Message parameters example (raw text format)

    {
      "TopicArn": "arn:aws:sns:ap-southeast-2:123456789012:sample-AutomationWithAWSQuickstartSNSTopic-15EO7TT8O93XT",
      "Message": "$event.simpleName with trace ID $event.traceId triggered at $event.timestamp",
      "Subject": "Automation with AWS: $event.simpleName triggered at $event.timestamp"
    }
  • Page:
    Publish SNS Message - structured JSON format — This parameters template demonstrates publishing a SNS message in structured JSON format with the Publish SNS Message action:

    JSON escaping requirements

    If a parameter within the JSON formatted parameters template is a JSON structure in itself (e.g. the Lambda function payload), it needs to be escaped before adding it as a value - this has two implications:

    • (tick) custom content needs to be escaped, which can be achieved by Composing action payloads with utility functions, specifically the $util.escapeJson() function

    • (warning) variables with conflicting content (e.g. multi line variables like JIRA's $issue.fields.description or Bamboo's $notification.textEmailContent or JSON structures retrieved via JSONPath) need to be escaped twice, via $util.escapeJson($util.escapeJson(...)) - we are exploring options on how to make this easier in a future release

    JSON Message Generator

    The AWS Management Console features a JSON Message Generator that eases composition of the required JSON message structure, refer to section Create Different Messages for Each Protocol for within Publish to a topic for details.

    Publish SNS Message parameters example (structured JSON format – escaped manually)

    {
      "TopicArn": "arn:aws:sns:ap-southeast-2:123456789012:sample-AutomationWithAWSQuickstartSNSTopic-15EO7TT8O93XT",
      "Message": "{ \"default\": \"$event.simpleName with trace ID $event.traceId triggered at $event.timestamp\"}",
      "MessageStructure": "json",
      "Subject": "Automation with AWS: $event.simpleName triggered at $event.timestamp"
    }

    Publish SNS Message parameters example (structured JSON format – escaped with utility function)

    {
      "TopicArn": "arn:aws:sns:ap-southeast-2:123456789012:sample-AutomationWithAWSQuickstartSNSTopic-15EO7TT8O93XT",
      "Message": "$util.escapeJson('{
        "default": "$event.simpleName with trace ID $event.traceId triggered at $event.timestamp"
      }')",
      "MessageStructure": "json",
      "Subject": "Automation with AWS: $event.simpleName triggered at $event.timestamp"
    }
  • Page:
    Send SMS Message — This parameters template demonstrates sending a SMS message directly to a phone number with the Publish SNS Message action:

    Send SMS Message parameters example

    {
      "PhoneNumber": "+61.1234567890",
      "Message": "Automation with AWS: $event.simpleName with trace ID $event.traceId triggered at $event.timestamp",
      "MessageAttributes": {
        "AWS.SNS.SMS.SenderID": {
          "DataType": "String",
          "StringValue": "Utoolity"
        }
      }
    }

How-to Articles

Filter by label

There are no items with the selected labels at this time.

Frequently Asked Questions (FAQ)

  • No labels