AWS Tools for PowerShell のバージョン 5 (V5) がリリースされました。
新しいバージョンのツールの使用を開始するには、「AWS Tools for PowerShell ユーザーガイド (V5)」、特に V5 への移行に関するトピックを参照してください。
Tools for PowerShell V4 を使用した Amazon SNS の例
次のコードサンプルは、Amazon SNS で AWS Tools for PowerShell V4 を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。
アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。
各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。
トピック
アクション
次の例は、Publish-SNSMessage を使用する方法を説明しています。
- Tools for PowerShell V4
-
例 1: この例では、インラインで宣言された単一の MessageAttribute を使用してメッセージを発行しています。
Publish-SNSMessage -TopicArn "arn:aws:sns:us-west-2:123456789012:my-topic" -Message "Hello" -MessageAttribute @{'City'=[Amazon.SimpleNotificationService.Model.MessageAttributeValue]@{DataType='String'; StringValue ='AnyCity'}}例 2: この例では、事前に宣言された複数の MessageAttribute を使用してメッセージを発行しています。
$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-
API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V4) の「Publish」を参照してください。
-