Skip to main content

aws_sns_topic Resource

[edit on GitHub]

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.

Installation

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

See the Chef InSpec documentation on cloud platforms for information on configuring your AWS environment for InSpec and creating an InSpec profile that uses the InSpec AWS resource pack.

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

This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our matchers page.

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.

Was this page helpful?

×









Search Results