Skip to content

Commit

Permalink
Add ResourceType on ec2 snapshot copy (#1419) (#1605)
Browse files Browse the repository at this point in the history
[PR #1419/fad35892 backport][stable-5] Add ResourceType on ec2 snapshot copy

This is a backport of PR #1419 as merged into main (fad3589).
SUMMARY
Fixes this issue that shows up when tags are specified:
An error occurred waiting for the snapshot to become available.: An
error occurred (InvalidParameterValue) when calling the CopySnapshot
operation: Tag specification resource type must have a value

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_snapshot_copy
ADDITIONAL INFORMATION



# before

botocore.exceptions.ClientError: An error occurred (InvalidParameterValue) when calling the CopySnapshot operation: Tag specification resource type must have a value                              
fatal: [localhost]: FAILED! => {                                                                                                                                                                   
    "boto3_version": "1.24.57",                                                                                                                                                                    
    "botocore_version": "1.27.58",                                                                                                                                                                 
    "changed": false,                                                                                                                                                                              
    "error": {                                                                                                                                                                                     
        "code": "InvalidParameterValue",                                                                                                                                                           
        "message": "Tag specification resource type must have a value"                                                                                                                             
    },  
....


# after  (no error message)

changed: [localhost] => {                                                                                                                                                                          
    "changed": true,                                                                                                                                                                               
    "invocation": {                                                                                                                                                                                
        "module_args": {       
.....

Reviewed-by: Mark Chappell <None>
  • Loading branch information
patchback[bot] authored Nov 25, 2022
1 parent cca23e2 commit 6038fa9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/1419-fix-ec2_snapshot_copy-with-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_snapshot_copy - including tags caused the erorr "Tag specification resource type must have a value". Fix sets the ResourceType to snapshot to resolve this issue (https://github.com/ansible-collections/community.aws/pull/1419).
2 changes: 1 addition & 1 deletion plugins/modules/ec2_snapshot_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def copy_snapshot(module, ec2):
params['KmsKeyId'] = module.params.get('kms_key_id')

if module.params.get('tags'):
params['TagSpecifications'] = boto3_tag_specifications(module.params.get('tags'))
params['TagSpecifications'] = boto3_tag_specifications(module.params.get('tags'), types=['snapshot'])

try:
snapshot_id = ec2.copy_snapshot(**params)['SnapshotId']
Expand Down

0 comments on commit 6038fa9

Please sign in to comment.