Skip to main content

aws_s3_bucket_policy Resource

Use the aws_s3_bucket_policy Chef InSpec audit resource to test properties of a single AWS S3 bucket policy.

The AWS::S3::BucketPolicy resource type applies an Amazon S3 bucket policy to an Amazon S3 bucket.

For additional information, including details on parameters and properties, see the AWS documentation on the AWS::S3::BucketPolicy resource.

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

Ensure that an S3 bucket policy exists.

describe aws_s3_bucket_policy(bucket: 'BUCKET_NAME') do
  it { should exist }
end

Parameters

bucket (required)

The name of the Amazon S3 bucket to which the policy applies.

Properties

Effect
The effect of the policy.
Sid
The policy statement ID of the S3 bucket.
Condition
The policy condition key of the S3 bucket.
Action
The policy action of the S3 bucket.
Resource
The policy resource type of the S3 bucket.
Principal
The policy principal of the S3 bucket.

Examples

Ensure a policy is available.

describe aws_s3_bucket_policy(bucket: 'BUCKET_NAME') do
  its('Sid') { should eq 'SID' }
end

Matchers

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

This resource has the following special matchers.

exist

Use should to test that the entity exists.

describe aws_s3_bucket_policy(bucket: 'BUCKET_NAME') do
  it { should exist }
end

Use should_not to test the entity does not exist.

describe aws_s3_bucket_policy(bucket: 'BUCKET_NAME') do
  it { should_not exist }
end

be_available

Use should to check if the entity is available.

describe aws_s3_bucket_policy(bucket: 'BUCKET_NAME') do
  it { should be_available }
end

AWS Permissions

Your Principal will need the S3:Client:GetBucketPolicyOutput action with Effect set to Allow.

Edit this page on GitHub

Thank you for your feedback!

×










Search Results