AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Publish-SNSMessage-TopicArn <String>-Message <String>-MessageStructure <String>-Subject <String>-MessageAttribute <Hashtable>-MessageDeduplicationId <String>-MessageGroupId <String>-PhoneNumber <String>-TargetArn <String>-Select <String>-PassThru <SwitchParameter>-Force <SwitchParameter>-ClientConfig <AmazonSimpleNotificationServiceConfig>
TargetArn
).
If you send a message to a topic, Amazon SNS delivers the message to each endpoint that is subscribed to the topic. The format of the message depends on the notification protocol for each subscribed endpoint.
When a messageId
is returned, the message is saved and Amazon SNS immediately delivers it to subscribers.
To use the Publish
action for publishing a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn for the TargetArn parameter. The EndpointArn is returned when making a call with the CreatePlatformEndpoint
action.
For more information about formatting messages, see Send Custom Platform-Specific Payloads in Messages to Mobile Devices. Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
MessageStructure
parameter to json
and use a JSON object for the Message
parameter. Constraints:Publish
action is 1,600 characters.Publish
call to return an error (no partial delivery).Required? | True |
Position? | 2 |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | MessageAttributes |
MessageDeduplicationId
can contain up to 128 alphanumeric characters (a-z, A-Z, 0-9)
and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)
.Every message must have a unique MessageDeduplicationId
, which is a token used for deduplication of sent messages. If a message with a particular MessageDeduplicationId
is sent successfully, any message sent with the same MessageDeduplicationId
during the 5-minute deduplication interval is treated as a duplicate. If the topic has ContentBasedDeduplication
set, the system generates a MessageDeduplicationId
based on the contents of the message. Your MessageDeduplicationId
overrides the generated one. Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
MessageGroupId
can contain up to 128 alphanumeric characters (a-z, A-Z, 0-9)
and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)
.The MessageGroupId
is a tag that specifies that a message belongs to a specific message group. Messages that belong to the same message group are processed in a FIFO manner (however, messages in different message groups might be processed out of order). Every message must include a MessageGroupId
. Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
MessageStructure
to json
if you want to send a different message for each protocol. For example, using one publish action, you can send a short message to your SMS subscribers and a longer message to your email subscribers. If you set MessageStructure
to json
, the value of the Message
parameter must: json
Required? | False |
Position? | 3 |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
PhoneNumber
parameter, you must specify a value for the TargetArn
or TopicArn
parameters. Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | 4 |
Accept pipeline input? | True (ByPropertyName) |
TargetArn
parameter, you must specify a value for the PhoneNumber
or TopicArn
parameters. Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
TopicArn
parameter, you must specify a value for the PhoneNumber
or TargetArn
parameters. Required? | False |
Position? | 1 |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AK |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AWSProfilesLocation, ProfilesLocation |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | StoredCredentials, AWSProfileName |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | RegionToCall |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | SK, SecretAccessKey |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | ST |
Publish-SNSMessage -TopicArn "arn:aws:sns:us-west-2:123456789012:my-topic" -Message "Hello" -MessageAttribute @{'City'=[Amazon.SimpleNotificationService.Model.MessageAttributeValue]@{DataType='String'; StringValue ='AnyCity'}}This example shows publishing a message with a single MessageAttribute declared inline.
$cityAttributeValue = New-Object Amazon.SimpleNotificationService.Model.MessageAttributeValue
$cityAttributeValue.DataType = "String"
$cityAttributeValue.StringValue = "AnyCity"
$populationAttributeValue = New-Object Amazon.SimpleNotificationService.Model.MessageAttributeValue
$populationAttributeValue.DataType = "Number"
$populationAttributeValue.StringValue = "1250800"
$messageAttributes = New-Object System.Collections.Hashtable
$messageAttributes.Add("City", $cityAttributeValue)
$messageAttributes.Add("Population", $populationAttributeValue)
Publish-SNSMessage -TopicArn "arn:aws:sns:us-west-2:123456789012:my-topic" -Message "Hello" -MessageAttribute $messageAttributes
This example shows publishing a message with multiple MessageAttributes declared in advance.
AWS Tools for PowerShell: 2.x.y.z