Using AWS CLI to enable encryption for SNS topic

Viewed 871
2 Answers

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 .

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.

Related