{% extends "aws/base_resource.tf.j2" %}
{% block resources %}
{% for snapshot in resources %}
{{ resource_spacer() }}
resource "aws_ebs_snapshot" "{{ snapshot.SnapshotId | strip_id_prefix | tf_resource_name }}" {
  volume_id   = "{{ snapshot.VolumeId }}"
  description = "{{ snapshot.Description | default('Imported snapshot') }}"

  {% if snapshot.get('Encrypted') %}
  encrypted = {{ snapshot.Encrypted | lower }}
  {%  endif %}

  {% if snapshot.get('KmsKeyId') %}
  kms_key_id = "{{ snapshot.KmsKeyId }}"
  {%  endif %}

  {{ render_common_tags(snapshot, indent=2) }}

  lifecycle {
    prevent_destroy = true
    ignore_changes = [
      description
    ]
  }
}

{% endfor %}
{% endblock %}
