{% set config = merged_configs.get('aws_kinesis_stream', {}) %}
{% set comments = compliance_comments.get('aws_kinesis_stream', []) %}
# ------------------------------------------------------------------------------
# Kinesis Data Stream
# ------------------------------------------------------------------------------
{% for comment in comments %}
# {{ comment }}
{% endfor %}

resource "aws_kinesis_stream" "this" {
  name = "{{ config.get('name', project_id ~ '-stream') }}"

  stream_mode_details {
    stream_mode = "{{ config.get('stream_mode', 'ON_DEMAND') }}"
  }

  {% if config.get('stream_mode', 'ON_DEMAND') == 'PROVISIONED' %}
  shard_count = {{ config.get('shard_count', 1) }}
  {% endif %}

  retention_period = {{ config.get('retention_period', 24) }}

  # Encryption
  encryption_type = "{{ config.get('encryption_type', 'KMS') }}"
  kms_key_id      = "{{ config.get('kms_key_id', 'alias/aws/kinesis') }}"

  tags = {
    Name      = "{{ config.get('name', project_id ~ '-stream') }}"
    ManagedBy = "complyform"
  }
}
