Skip to main content

aws_sns_topic Resource

Use the aws_sns_topic InSpec audit resource to test properties of a single AWS Simple Notification Service Topic. SNS topics are channels for related events. AWS resources place events in the Simple Notification Service (SNS) topic, while other AWS resources subscribe to receive notifications when new events occur.

For additional information, including details on parameters and properties, see the AWS documentation on SNS.

Install

This resource is available in the Chef InSpec AWS resource pack.

For information on configuring your AWS environment for Chef InSpec and creating an InSpec profile that uses the InSpec AWS resource pack, see the Chef InSpec documentation on the AWS cloud platform.

Syntax

describe aws_sns_topic('arn:aws:sns:*::my-topic-name') do
  it { should exist }
end
# You may also use has syntax to pass the ARN
describe aws_sns_topic(arn: 'arn:aws:sns:*::my-topic-name') do
  it { should exist }
end

Parameters

arn (required)

This resource accepts a single parameter, the ARN of the SNS Topic. This can be passed either as a string or as a arn: 'value' key-value entry in a hash.

Properties

kms_master_key_id
Provides the ID of an AWS-managed customer master key (CMK) for Amazon SNS topic or a custom CMK.
confirmed_subscription_count
An integer indicating the number of currently active subscriptions.

Examples

Make sure something is subscribed to the topic.

describe aws_sns_topic('arn:aws:sns:*::my-topic-name') do
  its('confirmed_subscription_count') { should_not be_zero}
end

Matchers

For a full list of available matchers, see our Universal Matchers page.

This resource has the following special matchers.

exist

The control will pass if the describe returns at least one result.

Use should_not to test the entity should not exist.

describe aws_sns_topic('arn:aws:sns:*::good-news') do
  it { should exist }
end
describe aws_sns_topic('arn:aws:sns:*::bad-news') do
  it { should_not exist }
end

AWS Permissions

Your Principal will need the SNS:Client:GetTopicAttributesResponse action with Effect set to Allow.

You can find detailed documentation at Actions, Resources, and Condition Keys for Amazon SNS.

Edit this page on GitHub

Thank you for your feedback!

×