Table: aws_secretsmanager_secrets

This table shows data for AWS Secrets Manager Secrets.

https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_ListSecrets.html (opens in a new tab)

The primary key for this table is arn.

Relations

The following tables depend on aws_secretsmanager_secrets:

Columns

NameType
_cq_iduuid
_cq_parent_iduuid
account_idutf8
regionutf8
arn (PK)utf8
policyjson
tagsjson
created_datetimestamp[us, tz=UTC]
deleted_datetimestamp[us, tz=UTC]
descriptionutf8
kms_key_idutf8
last_accessed_datetimestamp[us, tz=UTC]
last_changed_datetimestamp[us, tz=UTC]
last_rotated_datetimestamp[us, tz=UTC]
nameutf8
next_rotation_datetimestamp[us, tz=UTC]
owning_serviceutf8
primary_regionutf8
replication_statusjson
rotation_enabledbool
rotation_lambda_arnutf8
rotation_rulesjson
version_ids_to_stagesjson

Example Queries

These SQL queries are sampled from CloudQuery policies and are compatible with PostgreSQL.

Remove unused Secrets Manager secrets

SELECT
  'Remove unused Secrets Manager secrets' AS title,
  account_id,
  arn AS resource_id,
  CASE
  WHEN (
    last_accessed_date IS NULL
    AND created_date < now() - '90 days'::INTERVAL
  )
  OR (
      last_accessed_date IS NOT NULL
      AND last_accessed_date < now() - '90 days'::INTERVAL
    )
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  aws_secretsmanager_secrets;

Secrets Manager secrets configured with automatic rotation should rotate successfully

SELECT
  'Secrets Manager secrets configured with automatic rotation should rotate successfully'
    AS title,
  account_id,
  arn AS resource_id,
  CASE
  WHEN (
    last_rotated_date IS NULL
    AND created_date
      < now()
        - '1 day'::INTERVAL * (rotation_rules->>'AutomaticallyAfterDays')::INT8
  )
  OR (
      last_rotated_date IS NOT NULL
      AND last_rotated_date
        < now()
          - '1 day'::INTERVAL
            * (rotation_rules->>'AutomaticallyAfterDays')::INT8
    )
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  aws_secretsmanager_secrets;

Secrets Manager secrets should be rotated within a specified number of days

SELECT
  'Secrets Manager secrets should be rotated within a specified number of days'
    AS title,
  account_id,
  arn AS resource_id,
  CASE
  WHEN (
    last_rotated_date IS NULL
    AND created_date < now() - '90 days'::INTERVAL
  )
  OR (
      last_rotated_date IS NOT NULL
      AND last_rotated_date < now() - '90 days'::INTERVAL
    )
  THEN 'fail'
  ELSE 'pass'
  END
    AS status
FROM
  aws_secretsmanager_secrets;

Secrets Manager secrets should have automatic rotation enabled

SELECT
  'Secrets Manager secrets should have automatic rotation enabled' AS title,
  account_id,
  arn AS resource_id,
  CASE WHEN rotation_enabled IS NOT true THEN 'fail' ELSE 'pass' END AS status
FROM
  aws_secretsmanager_secrets;