rules:
- id: aws-timestream-database-encrypted-with-cmk
  patterns:
  - pattern: |
      resource "aws_timestreamwrite_database" $ANYTHING {
        ...
      }
  - pattern-not-inside: |
      resource "aws_timestreamwrite_database" $ANYTHING {
        ...
        kms_key_id = ...
        ...
      }
  message: >-
    Ensure Timestream database is encrypted at rest using KMS CMKs. CMKs gives you control over the encryption
    key in terms of access and rotation.
  metadata:
    category: security
    technology:
    - terraform
    - aws
    owasp:
    - A03:2017 - Sensitive Data Exposure
    cwe:
    - 'CWE-320: CWE CATEGORY: Key Management Errors'
    references:
    - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
    subcategory:
    - audit
    likelihood: LOW
    impact: LOW
    confidence: LOW
  languages: [hcl]
  severity: WARNING
