Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Contoh Amazon SNS menggunakan AWS CLI
Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface dengan Amazon SNS.
Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Skenario adalah contoh kode yang menunjukkan kepada Anda bagaimana menyelesaikan tugas tertentu dengan memanggil beberapa fungsi dalam layanan atau dikombinasikan dengan yang lain Layanan AWS.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Tindakan
Contoh kode berikut menunjukkan cara menggunakanadd-permission
.
- AWS CLI
-
Untuk menambahkan izin ke topik
add-permission
Contoh berikut menambahkan izin untuk AWS akun987654321098
untuk menggunakanPublish
tindakan dengan topik yang ditentukan di bawah AWS akun123456789012
.aws sns add-permission \ --topic-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
\ --labelPublish-Permission
\ --aws-account-id987654321098
\ --action-namePublish
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat AddPermission
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancheck-if-phone-number-is-opted-out
.
- AWS CLI
-
Untuk memeriksa pesan SMS opt-out untuk nomor telepon
check-if-phone-number-is-opted-out
Contoh berikut memeriksa apakah nomor telepon yang ditentukan dipilih untuk tidak menerima pesan SMS dari AWS akun saat ini.aws sns check-if-phone-number-is-opted-out \ --phone-number
+1555550100
Output:
{ "isOptedOut": false }
-
Untuk detail API, lihat CheckIfPhoneNumberIsOptedOut
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanconfirm-subscription
.
- AWS CLI
-
Untuk mengonfirmasi langganan
confirm-subscription
Perintah berikut menyelesaikan proses konfirmasi yang dimulai saat Anda berlangganan topik SNS bernama.my-topic
Parameter --token berasal dari pesan konfirmasi yang dikirim ke titik akhir notifikasi yang ditentukan dalam panggilan berlangganan.aws sns confirm-subscription \ --topic-arn
arn:aws:sns:us-west-2:123456789012:my-topic
\ --token2336412f37fb687f5d51e6e241d7700ae02f7124d8268910b858cb4db727ceeb2474bb937929d3bdd7ce5d0cce19325d036bc858d3c217426bcafa9c501a2cace93b83f1dd3797627467553dc438a8c974119496fc3eff026eaa5d14472ded6f9a5c43aec62d83ef5f49109da7176391
Output:
{ "SubscriptionArn": "arn:aws:sns:us-west-2:123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f" }
-
Untuk detail API, lihat ConfirmSubscription
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-platform-application
.
- AWS CLI
-
Untuk membuat aplikasi platform
create-platform-application
Contoh berikut membuat aplikasi platform Google Firebase menggunakan kredensi platform yang ditentukan.aws sns create-platform-application \ --name
MyApplication
\ --platformGCM
\ --attributesPlatformCredential=EXAMPLEabcd12345jklm67890stuv12345bcdef
Output:
{ "PlatformApplicationArn": "arn:aws:sns:us-west-2:123456789012:app/GCM/MyApplication" }
-
Untuk detail API, lihat CreatePlatformApplication
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-topic
.
- AWS CLI
-
Untuk membuat topik SNS
create-topic
Contoh berikut membuat topik SNS bernamamy-topic
.aws sns create-topic \ --name
my-topic
Output:
{ "ResponseMetadata": { "RequestId": "1469e8d7-1642-564e-b85d-a19b4b341f83" }, "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic" }
Untuk informasi selengkapnya, lihat Menggunakan Antarmuka Baris AWS Perintah dengan Amazon SQS dan Amazon SNS di Panduan Pengguna Antarmuka Baris AWS Perintah.
-
Untuk detail API, lihat CreateTopic
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-endpoint
.
- AWS CLI
-
Untuk menghapus titik akhir aplikasi platform
delete-endpoint
Contoh berikut menghapus endpoint aplikasi platform yang ditentukan.aws sns delete-endpoint \ --endpoint-arn
arn:aws:sns:us-west-2:123456789012:endpoint/GCM/MyApplication/12345678-abcd-9012-efgh-345678901234
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat DeleteEndpoint
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-platform-application
.
- AWS CLI
-
Untuk menghapus aplikasi platform
delete-platform-application
Contoh berikut menghapus aplikasi platform yang ditentukan.aws sns delete-platform-application \ --platform-application-arn
arn:aws:sns:us-west-2:123456789012:app/ADM/MyApplication
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat DeletePlatformApplication
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-topic
.
- AWS CLI
-
Untuk menghapus topik SNS
delete-topic
Contoh berikut menghapus topik SNS yang ditentukan.aws sns delete-topic \ --topic-arn
"arn:aws:sns:us-west-2:123456789012:my-topic"
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat DeleteTopic
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-endpoint-attributes
.
- AWS CLI
-
Untuk membuat daftar atribut endpoint aplikasi platform
get-endpoint-attributes
Contoh berikut mencantumkan atribut untuk endpoint aplikasi platform tertentu.aws sns get-endpoint-attributes \ --endpoint-arn
arn:aws:sns:us-west-2:123456789012:endpoint/GCM/MyApplication/12345678-abcd-9012-efgh-345678901234
Output:
{ "Attributes": { "Enabled": "true", "Token": "EXAMPLE12345..." } }
-
Untuk detail API, lihat GetEndpointAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-platform-application-attributes
.
- AWS CLI
-
Untuk membuat daftar atribut aplikasi platform
get-platform-application-attributes
Contoh berikut mencantumkan atribut untuk aplikasi platform tertentu.aws sns get-platform-application-attributes \ --platform-application-arn
arn:aws:sns:us-west-2:123456789012:app/MPNS/MyApplication
Output:
{ "Attributes": { "Enabled": "true", "SuccessFeedbackSampleRate": "100" } }
-
Untuk detail API, lihat GetPlatformApplicationAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-sms-attributes
.
- AWS CLI
-
Untuk mencantumkan atribut pesan SMS default
get-sms-attributes
Contoh berikut mencantumkan atribut default untuk mengirim pesan SMS.aws sns get-sms-attributes
Output:
{ "attributes": { "DefaultSenderID": "MyName" } }
-
Untuk detail API, lihat Dapatkan SMSAttributes
Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-subscription-attributes
.
- AWS CLI
-
Untuk mengambil atribut langganan untuk topik
Berikut ini
get-subscription-attributes
menampilkan atribut langganan yang ditentukan. Anda bisa mendapatkansubscription-arn
dari outputlist-subscriptions
perintah.aws sns get-subscription-attributes \ --subscription-arn
"arn:aws:sns:us-west-2:123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f"
Output:
{ "Attributes": { "Endpoint": "my-email@example.com", "Protocol": "email", "RawMessageDelivery": "false", "ConfirmationWasAuthenticated": "false", "Owner": "123456789012", "SubscriptionArn": "arn:aws:sns:us-west-2:123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f", "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic" } }
-
Untuk detail API, lihat GetSubscriptionAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-topic-attributes
.
- AWS CLI
-
Untuk mengambil atribut dari suatu topik
get-topic-attributes
Contoh berikut menampilkan atribut untuk topik yang ditentukan.aws sns get-topic-attributes \ --topic-arn
"arn:aws:sns:us-west-2:123456789012:my-topic"
Output:
{ "Attributes": { "SubscriptionsConfirmed": "1", "DisplayName": "my-topic", "SubscriptionsDeleted": "0", "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", "Owner": "123456789012", "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:DeleteTopic\",\"SNS:GetTopicAttributes\",\"SNS:Publish\",\"SNS:RemovePermission\",\"SNS:AddPermission\",\"SNS:SetTopicAttributes\"],\"Resource\":\"arn:aws:sns:us-west-2:123456789012:my-topic\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"0123456789012\"}}}]}", "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic", "SubscriptionsPending": "0" } }
-
Untuk detail API, lihat GetTopicAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-endpoints-by-platform-application
.
- AWS CLI
-
Untuk membuat daftar titik akhir untuk aplikasi platform
list-endpoints-by-platform-application
Contoh berikut mencantumkan titik akhir dan atribut endpoint untuk aplikasi platform tertentu.aws sns list-endpoints-by-platform-application \ --platform-application-arn
arn:aws:sns:us-west-2:123456789012:app/GCM/MyApplication
Output:
{ "Endpoints": [ { "Attributes": { "Token": "EXAMPLE12345..., "Enabled": "true" }, "EndpointArn": "arn:aws:sns:us-west-2:123456789012:endpoint/GCM/MyApplication/12345678-abcd-9012-efgh-345678901234" } ] }
-
Untuk detail API, lihat ListEndpointsByPlatformApplication
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-phone-numbers-opted-out
.
- AWS CLI
-
Untuk membuat daftar opt-out pesan SMS
list-phone-numbers-opted-out
Contoh berikut mencantumkan nomor telepon yang dipilih untuk tidak menerima pesan SMS.aws sns list-phone-numbers-opted-out
Output:
{ "phoneNumbers": [ "+15555550100" ] }
-
Untuk detail API, lihat ListPhoneNumbersOptedOut
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-platform-applications
.
- AWS CLI
-
Untuk membuat daftar aplikasi platform
list-platform-applications
Contoh berikut mencantumkan aplikasi platform untuk ADM dan MPNS.aws sns list-platform-applications
Output:
{ "PlatformApplications": [ { "PlatformApplicationArn": "arn:aws:sns:us-west-2:123456789012:app/ADM/MyApplication", "Attributes": { "SuccessFeedbackSampleRate": "100", "Enabled": "true" } }, { "PlatformApplicationArn": "arn:aws:sns:us-west-2:123456789012:app/MPNS/MyOtherApplication", "Attributes": { "SuccessFeedbackSampleRate": "100", "Enabled": "true" } } ] }
-
Untuk detail API, lihat ListPlatformApplications
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-subscriptions-by-topic
.
- AWS CLI
-
Untuk membuat daftar langganan yang terkait dengan topik
Berikut ini
list-subscriptions-by-topic
mengambil daftar langganan SNS yang terkait dengan topik yang ditentukan.aws sns list-subscriptions-by-topic \ --topic-arn
"arn:aws:sns:us-west-2:123456789012:my-topic"
Output:
{ "Subscriptions": [ { "Owner": "123456789012", "Endpoint": "my-email@example.com", "Protocol": "email", "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic", "SubscriptionArn": "arn:aws:sns:us-west-2:123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f" } ] }
-
Untuk detail API, lihat ListSubscriptionsByTopic
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-subscriptions
.
- AWS CLI
-
Untuk membuat daftar langganan SNS Anda
list-subscriptions
Contoh berikut menampilkan daftar langganan SNS di akun Anda AWS .aws sns list-subscriptions
Output:
{ "Subscriptions": [ { "Owner": "123456789012", "Endpoint": "my-email@example.com", "Protocol": "email", "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic", "SubscriptionArn": "arn:aws:sns:us-west-2:123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f" } ] }
-
Untuk detail API, lihat ListSubscriptions
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-tags-for-resource
.
- AWS CLI
-
Untuk mencantumkan tag untuk suatu topik
list-tags-for-resource
Contoh berikut mencantumkan tag untuk topik Amazon SNS yang ditentukan.aws sns list-tags-for-resource \ --resource-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
Output:
{ "Tags": [ { "Key": "Team", "Value": "Alpha" } ] }
-
Untuk detail API, lihat ListTagsForResource
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-topics
.
- AWS CLI
-
Untuk membuat daftar topik SNS Anda
list-topics
Contoh berikut mencantumkan semua topik SNS di AWS akun Anda.aws sns list-topics
Output:
{ "Topics": [ { "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic" } ] }
-
Untuk detail API, lihat ListTopics
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanopt-in-phone-number
.
- AWS CLI
-
Untuk ikut serta dalam pesan SMS
opt-in-phone-number
Contoh berikut memilih nomor telepon yang ditentukan untuk menerima pesan SMS.aws sns opt-in-phone-number \ --phone-number
+15555550100
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat OptInPhoneNumber
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanpublish
.
- AWS CLI
-
Contoh 1: Untuk mempublikasikan pesan ke topik
publish
Contoh berikut menerbitkan pesan yang ditentukan ke topik SNS yang ditentukan. Pesan berasal dari file teks, yang memungkinkan Anda untuk memasukkan jeda baris.aws sns publish \ --topic-arn
"arn:aws:sns:us-west-2:123456789012:my-topic"
\ --messagefile://message.txt
Isi dari
message.txt
:Hello World Second Line
Output:
{ "MessageId": "123a45b6-7890-12c3-45d6-111122223333" }
Contoh 2: Untuk mempublikasikan pesan SMS ke nomor telepon
publish
Contoh berikut menerbitkan pesanHello world!
ke nomor+1-555-555-0100
telepon.aws sns publish \ --message
"Hello world!"
\ --phone-number+1-555-555-0100
Output:
{ "MessageId": "123a45b6-7890-12c3-45d6-333322221111" }
-
Untuk detail API, lihat Menerbitkan
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanput-data-protection-policy
.
- AWS CLI
-
Untuk menetapkan kebijakan perlindungan data
Contoh 1: Untuk menolak penerbit mempublikasikan pesan dengan CreditCardNumber
put-data-protection-policy
Contoh berikut menyangkal penerbit dari mempublikasikan pesan dengan. CreditCardNumberaws sns put-data-protection-policy \ --resource-arn
arn:aws:sns:us-east-1:123456789012:mytopic
\ --data-protection-policy "{\"Name\":\"data_protection_policy\",\"Description\":\"Example data protection policy\",\"Version\":\"2021-06-01\",\"Statement\":[{\"DataDirection\":\"Inbound\",\"Principal\":[\"*\"],\"DataIdentifier\":[\"arn:aws:dataprotection::aws:data-identifier/CreditCardNumber\"],\"Operation\":{\"Deny\":{}}}]}"Perintah ini tidak menghasilkan output.
Contoh 2: Untuk memuat parameter dari file
Berikut ini
put-data-protection-policy
memuat parameter dari file.aws sns put-data-protection-policy \ --resource-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
\ --data-protection-policyfile://policy.json
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat PutDataProtectionPolicy
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanremove-permission
.
- AWS CLI
-
Untuk menghapus izin dari topik
remove-permission
Contoh berikut menghapus izinPublish-Permission
dari topik yang ditentukan.aws sns remove-permission \ --topic-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
\ --labelPublish-Permission
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat RemovePermission
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-endpoint-attributes
.
- AWS CLI
-
Untuk mengatur atribut titik akhir
set-endpoint-attributes
Contoh berikut menonaktifkan endpoint aplikasi platform yang ditentukan.aws sns set-endpoint-attributes \ --endpoint-arn
arn:aws:sns:us-west-2:123456789012:endpoint/GCM/MyApplication/12345678-abcd-9012-efgh-345678901234
\ --attributesEnabled=false
Output:
{ "Attributes": { "Enabled": "false", "Token": "EXAMPLE12345..." } }
-
Untuk detail API, lihat SetEndpointAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-platform-application-attributes
.
- AWS CLI
-
Untuk mengatur atribut aplikasi platform
set-platform-application-attributes
Contoh berikut menetapkanEventDeliveryFailure
atribut untuk aplikasi platform yang ditentukan ke ARN dari topik Amazon SNS yang ditentukan.aws sns set-platform-application-attributes \ --platform-application-arn
arn:aws:sns:us-west-2:123456789012:app/GCM/MyApplication
\ --attributesEventDeliveryFailure=arn:aws:sns:us-west-2:123456789012:AnotherTopic
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat SetPlatformApplicationAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-sms-attributes
.
- AWS CLI
-
Untuk mengatur atribut pesan SMS
set-sms-attributes
Contoh berikut menetapkan ID pengirim default untuk pesan SMS keMyName
.aws sns set-sms-attributes \ --attributes
DefaultSenderID=MyName
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat Menyetel SMSAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-subscription-attributes
.
- AWS CLI
-
Untuk mengatur atribut langganan
set-subscription-attributes
Contoh berikut menetapkanRawMessageDelivery
atribut ke langganan SQS.aws sns set-subscription-attributes \ --subscription-arn
arn:aws:sns:us-east-1:123456789012:mytopic:f248de18-2cf6-578c-8592-b6f1eaa877dc
\ --attribute-nameRawMessageDelivery
\ --attribute-valuetrue
Perintah ini tidak menghasilkan output.
set-subscription-attributes
Contoh berikut menetapkanFilterPolicy
atribut ke langganan SQS.aws sns set-subscription-attributes \ --subscription-arn
arn:aws:sns:us-east-1:123456789012:mytopic:f248de18-2cf6-578c-8592-b6f1eaa877dc
\ --attribute-nameFilterPolicy
\ --attribute-value "{ \"anyMandatoryKey\": [\"any\", \"of\", \"these\"] }"Perintah ini tidak menghasilkan output.
set-subscription-attributes
Contoh berikut menghapusFilterPolicy
atribut dari langganan SQS.aws sns set-subscription-attributes \ --subscription-arn
arn:aws:sns:us-east-1:123456789012:mytopic:f248de18-2cf6-578c-8592-b6f1eaa877dc
\ --attribute-nameFilterPolicy
\ --attribute-value"{}"
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat SetSubscriptionAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanset-topic-attributes
.
- AWS CLI
-
Untuk menetapkan atribut untuk topik
set-topic-attributes
Contoh berikut menetapkanDisplayName
atribut untuk topik tertentu.aws sns set-topic-attributes \ --topic-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
\ --attribute-nameDisplayName
\ --attribute-valueMyTopicDisplayName
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat SetTopicAttributes
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakansubscribe
.
- AWS CLI
-
Untuk berlangganan topik
subscribe
Perintah berikut berlangganan alamat email ke topik yang ditentukan.aws sns subscribe \ --topic-arn
arn:aws:sns:us-west-2:123456789012:my-topic
\ --protocolemail
\ --notification-endpointmy-email@example.com
Output:
{ "SubscriptionArn": "pending confirmation" }
-
Untuk detail API, lihat Berlangganan
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakantag-resource
.
- AWS CLI
-
Untuk menambahkan tag ke topik
tag-resource
Contoh berikut menambahkan tag metadata ke topik Amazon SNS yang ditentukan.aws sns tag-resource \ --resource-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
\ --tagsKey=Team,Value=Alpha
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat TagResource
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanunsubscribe
.
- AWS CLI
-
Untuk berhenti berlangganan dari suatu topik
unsubscribe
Contoh berikut menghapus langganan yang ditentukan dari suatu topik.aws sns unsubscribe \ --subscription-arn
arn:aws:sns:us-west-2:0123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat Berhenti berlangganan
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanuntag-resource
.
- AWS CLI
-
Untuk menghapus tag dari topik
untag-resource
Contoh berikut menghapus tag apa pun dengan kunci yang ditentukan dari topik Amazon SNS yang ditentukan.aws sns untag-resource \ --resource-arn
arn:aws:sns:us-west-2:123456789012:MyTopic
\ --tag-keysTeam
Perintah ini tidak menghasilkan output.
-
Untuk detail API, lihat UntagResource
di Referensi AWS CLI Perintah.
-
Skenario
Contoh kode berikut menunjukkan cara membuat titik akhir platform untuk notifikasi push Amazon SNS.
- AWS CLI
-
Untuk membuat endpoint aplikasi platform
create-platform-endpoint
Contoh berikut membuat titik akhir untuk aplikasi platform tertentu menggunakan token yang ditentukan.aws sns create-platform-endpoint \ --platform-application-arn
arn:aws:sns:us-west-2:123456789012:app/GCM/MyApplication
\ --tokenEXAMPLE12345...
Output:
{ "EndpointArn": "arn:aws:sns:us-west-2:1234567890:endpoint/GCM/MyApplication/12345678-abcd-9012-efgh-345678901234" }