Table: aws_secretsmanager_secret - Query AWS Secrets Manager Secret using SQL
The AWS Secrets Manager Secret is a secure and scalable service that enables you to easily manage secrets throughout their lifecycle. Using Secrets Manager, you can secure, audit, and manage secrets used to access resources in the AWS Cloud, on third-party services, and on-premises. This service helps protect access to your applications, services, and IT resources without the upfront investment and on-going maintenance costs of operating your own infrastructure.
Table Usage Guide
The aws_secretsmanager_secret
table in Steampipe provides you with information about secrets within AWS Secrets Manager. This table allows you, as a DevOps engineer, to query secret-specific details, including metadata, versions, rotation configuration, and more. You can utilize this table to gather insights on secrets, such as secret rotation status, associated resource policies, and more. The schema outlines the various attributes of the secret for you, including the secret ARN, name, description, rotation rules, and associated tags.
Examples
Basic info
Gain insights into the creation and last accessed dates of your AWS Secrets Manager secrets. This can help in managing secret lifecycle, ensuring secrets are regularly updated or identifying unused secrets.
select name, created_date, description, last_accessed_datefrom aws_secretsmanager_secret;
select name, created_date, description, last_accessed_datefrom aws_secretsmanager_secret;
List secrets that do not automatically rotate
Discover the segments that contain secrets which do not have an automatic rotation feature enabled. This is useful for identifying potential security risks and ensuring best practices for data safety.
select name, created_date, description, rotation_enabledfrom aws_secretsmanager_secretwhere not rotation_enabled;
select name, created_date, description, rotation_enabledfrom aws_secretsmanager_secretwhere rotation_enabled = 0;
List secrets that automatically rotate every 7 days
Identify the secrets in your AWS Secrets Manager that are set to automatically rotate more frequently than every 7 days. This can be useful for maintaining a high level of security by ensuring that secrets are updated regularly.
select name, created_date, description, rotation_enabled, rotation_rulesfrom aws_secretsmanager_secretwhere rotation_rules -> 'AutomaticallyAfterDays' > '7';
select name, created_date, description, rotation_enabled, rotation_rulesfrom aws_secretsmanager_secretwhere json_extract(rotation_rules, '$.AutomaticallyAfterDays') > 7;
List secrets that are not replicated in other regions
Determine the areas in which certain secrets are not replicated across different regions. This can be useful for ensuring data redundancy and mitigating risks associated with data loss in specific geographical locations.
select name, created_date, description, replication_statusfrom aws_secretsmanager_secretwhere replication_status is null;
select name, created_date, description, replication_statusfrom aws_secretsmanager_secretwhere replication_status is null;
List policy details for the secrets
Determine the specifics of policies pertaining to your secrets. This query is useful for gaining insights into your secret management policies, helping you understand and manage your security better.
select name, jsonb_pretty(policy) as policy, jsonb_pretty(policy_std) as policy_stdfrom aws_secretsmanager_secret;
select name, policy, policy_stdfrom aws_secretsmanager_secret;
Control examples
- All Controls > Secrets Manager > Remove unused Secrets Manager secrets
- All Controls > Secrets Manager > Secrets Manager secrets should be rotated within a specified number of days
- AWS Foundational Security Best Practices > Secrets Manager > 1 Secrets Manager secrets should have automatic rotation enabled
- AWS Foundational Security Best Practices > Secrets Manager > 2 Secrets Manager secrets configured with automatic rotation should rotate successfully
- AWS Foundational Security Best Practices > Secrets Manager > 3 Remove unused Secrets Manager secrets
- AWS Foundational Security Best Practices > Secrets Manager > 4 Secrets Manager secrets should be rotated within a specified number of days
- Secrets Manager secrets should be encrypted using CMK
- Secrets Manager secrets should be rotated as per the rotation schedule
- Secrets Manager secrets should be rotated within specific number of days
- Secrets Manager secrets should have automatic rotation enabled
- Secrets Manager secrets that have not been used in 90 days should be removed
Schema for aws_secretsmanager_secret
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
arn | text | = | The Amazon Resource Name (ARN) of the secret. |
created_date | timestamp with time zone | The date and time when a secret was created. | |
deleted_date | timestamp with time zone | The date and time the deletion of the secret occurred. | |
description | text | = | The user-provided description of the secret. |
kms_key_id | text | The ARN or alias of the AWS KMS customer master key (CMK) used to encrypt the SecretString and SecretBinary fields in each version of the secret. | |
last_accessed_date | timestamp with time zone | The last date that this secret was accessed. | |
last_changed_date | timestamp with time zone | The last date and time that this secret was modified in any way. | |
last_rotated_date | timestamp with time zone | The most recent date and time that the Secrets Manager rotation process was successfully completed. | |
name | text | = | The friendly name of the secret. |
owning_service | text | Returns the name of the service that created the secret. | |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
policy | jsonb | A JSON-formatted string that describes the permissions that are associated with the attached secret. | |
policy_std | jsonb | Contains the permissions that are associated with the attached secret in a canonical form for easier searching. | |
primary_region | text | = | The Region where Secrets Manager originated the secret. |
region | text | The AWS Region in which the resource is located. | |
replication_status | jsonb | Describes a list of replication status objects as InProgress, Failed or InSync. | |
rotation_enabled | boolean | Indicates whether automatic, scheduled rotation is enabled for this secret. | |
rotation_lambda_arn | text | The ARN of an AWS Lambda function invoked by Secrets Manager to rotate and expire the secret either automatically per the schedule or manually by a call to RotateSecret. | |
rotation_rules | jsonb | A structure that defines the rotation configuration for the secret. | |
secret_versions_to_stages | jsonb | A list of all of the currently assigned SecretVersionStage staging labels and the SecretVersionId attached to each one. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | The list of user-defined tags associated with the secret. | |
title | text | Title of the resource. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws
You can pass the configuration to the command with the --config
argument:
steampipe_export_aws --config '<your_config>' aws_secretsmanager_secret