Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait between creating AMI and tagging it #16

Open
raymondbutcher opened this issue May 21, 2019 · 0 comments
Open

Wait between creating AMI and tagging it #16

raymondbutcher opened this issue May 21, 2019 · 0 comments

Comments

@raymondbutcher
Copy link

I just found an AMI missing the DeleteOn tag, checked the function logs, and found this:

Retaining AMI ami-REDACTED of instance i-REDACTED for 7 days
An error occurred (InvalidAMIID.NotFound) when calling the CreateTags operation: The image id '[ami-REDACTED]' does not exist: ClientError
Traceback (most recent call last):
File "/var/task/ami_backup.py", line 51, in lambda_handler
{'Key': 'DeleteOn', 'Value': delete_fmt},
File "/var/runtime/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
ClientError: An error occurred (InvalidAMIID.NotFound) when calling the CreateTags operation: The image id '[ami-REDACTED]' does not exist

I suppose adding a waiter would solve this.

And then when it retried:

An error occurred (InvalidAMIName.Duplicate) when calling the CreateImage operation: AMI name REDACTED-2019-05-06 is already in use by AMI ami-REDACTED: ClientError
Traceback (most recent call last):
File "/var/task/ami_backup.py", line 37, in lambda_handler
BlockDeviceMappings=block_device_mappings)
File "/var/runtime/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 612, in _make_api_call
raise error_class(parsed_response, operation_name)
ClientError: An error occurred (InvalidAMIName.Duplicate) when calling the CreateImage operation: AMI name REDACTED-2019-05-06 is already in use by AMI ami-REDACTED

I'm not sure how it should deal with this. Should it gracefully ensure the tag is on the AMI so it doesn't leave AMIs unable to be cleaned up? It would be bad to automatically delete an image that someone has created separately and happened to use the same naming convention as this module, but that seems unlikely and probably not worth worrying about.

I would/will submit a pull request to fix this, but don't have the time right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant