Include only AMI's owned by caller during pre-validate #354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I maintain the EKS-optimized AMI, and as a result I build a lot of AMI's. 😄
Our current naming convention for AMI's uses a date of the form
YYYYMMDD
. For better or worse, that's what we do. We have internal processes that build AMI's using this naming convention, and subsequently grant permissions for those AMI's to various other AWS accounts.The pre-validate step in the
amazon-ebs
builder will fail if any existing AMI returned by aec2.DescribeImages
call uses the proposed name. This makes sense, because the laterec2.CreateImage
call will fail with aInvalidAMIName.Duplicate
code if there is such a collision, after we've already executed the time-consuming steps.But, this
ec2.CreateImage
error only occurs when the caller has an existing AMI with the same name, whereas the pre-validate step currently fails even when an existing AMI that the caller has launch permissions for uses the same name (including public AMI's).This PR modifies the pre-validate step to only check for existing AMI's that are owned by the caller.