InvalidVolume.NotFound: The volume does not exist

Viewed 583

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."}

1 Answers

The issue for me was with the KMS Key. The KMS Key(arn:aws:kms:us-east-1:01234:key/456ccff-f6754-4xxx-xxx-xxxxxxxx) with which I was trying to encrypt the volume was configured with a different account(01234) and I was trying to access it in a different account(56789). Hence, it was not able to find the associated key.

Solution:- Changed the ARN of the KMS(arn:aws:kms:us-east-1:56789:key/456ccff-f6754-4xxx-xxx-xxxxxxxx) to that of the correct account, and it worked.

Related