sns - Send Amazon Simple Notification Service (SNS) messages

New in version 1.6.

Synopsis

  • The sns module sends notifications to a topic on your Amazon SNS account

Requirements (on host that executes module)

  • boto

Options

parameter required default choices comments
aws_access_key
no None
AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used.
aliases: ec2_access_key, access_key
aws_secret_key
no None
AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used.
aliases: ec2_secret_key, secret_key
email
no
Message to send to email-only subscription
http
no
Message to send to HTTP-only subscription
https
no
Message to send to HTTPS-only subscription
message_attributes
no None
Dictionary of message attributes. These are optional structured data entries to be sent along to the endpoint.
This is in AWS's distinct Name/Type/Value format; see example below.
message_structure
yes json
  • json
  • string
The payload format to use for the message.
This must be 'json' to support non-default messages (`http`, `https`, `email`, `sms`, `sqs`). It must be 'string' to support message_attributes.
msg
yes
Default message to send.
aliases: default
region
no
The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used.
aliases: aws_region, ec2_region
sms
no
Message to send to SMS-only subscription
sqs
no
Message to send to SQS-only subscription
subject
no
Subject line for email delivery.
topic
yes
The topic you want to publish to.

Examples

- name: Send default notification message via SNS
  sns:
    msg: '{{ inventory_hostname }} has completed the play.'
    subject: Deploy complete!
    topic: deploy
  delegate_to: localhost

- name: Send notification messages via SNS with short message for SMS
  sns:
    msg: '{{ inventory_hostname }} has completed the play.'
    sms: deployed!
    subject: Deploy complete!
    topic: deploy
  delegate_to: localhost

- name: Send message with message_attributes
  sns:
    topic: "deploy"
    msg: "message with extra details!"
    message_attributes:
      channel:
        data_type: String
        string_value: "mychannel"
      color:
        data_type: String
        string_value: "green"
  delegate_to: localhost

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/sns_module.html