Using Ansible Module ec2_vol to encrypt an existing volume using KMS Key and attach it to an ec2 instance
- name: Attach Encrypted Volumes
ec2_vol:
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
security_token: "{{ aws_token_key }}"
instance: "{{instance_ID}}"
region: "us-east-1"
snapshot: '{{ item.1.snap_id }}'
encrypted: yes
kms_key_id: "{{ KMS_Key }}"
device_name: '{{ item.0.split(",")[0] }}'
volume_type: gp2
delete_on_termination: yes
with_together:
- "{{ vols_to_be_detached.stdout_lines }}"
- "{{ snapshot_ids.results }}"
Post executing the Playbook, getting an error like "msg": "InvalidVolume.NotFound: The volume 'vol-0a7fe92dxxxx34' does not exist."}