1
votes

is there a way to use the AWS CLI to modify attributes of an SNS topic ? I'm trying to enable Encryption for an SNS topic but the documentation presented here

only specifies 2 methods:

  1. Using the AWS Console
  2. Using the Java AWS SDK
2

2 Answers

3
votes

Here is what you are looking for:

https://docs.aws.amazon.com/cli/latest/reference/sns/set-topic-attributes.html

--attribute-name (string)

A map of attributes with their corresponding values.

The following attribute applies only to server-side-encryption :

KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) for Amazon SNS or a custom CMK. For more information, see Key Terms . For more examples, see KeyId in the AWS Key Management Service API Reference .
3
votes

Use set-topic-attribute command.

Example:

aws sns set-topic-attributes --topic-arn arn:aws:sns:us-west-2:123456789012:MyTopic --attribute-name KmsMasterKeyId --attribute-value arn:aws:kms:us-east-2:111122223333:alias/ExampleAlias

You can also use the key id, key id arn or just alias name for the attribute value.