Documentation
¶
Index ¶
Constants ¶
const (
// RFC8601 is the date/time format used by AWS.
RFC8601 = "2006-01-02T15:04:05.000Z"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AMIClean ¶
type AMIClean struct { NamePrefix string Delete bool Tag *ec2.Tag Invert bool Unused bool ExpirationDate time.Time Logger *zap.Logger EC2Client *ec2.EC2 }
AMIClean defines parameters for cleaning up AMIs based on a tag and expiration date.
func (*AMIClean) CheckImage ¶
CheckImage compares a given image to the purge criteria and returns true if the image matches the criteria.
func (*AMIClean) CheckUnused ¶
CheckUnused takes an image and then checks to see if it is in use as an instance. If the image is in use, it should return false; if it is not in use, it should return true. Note that we're only checking for AMIs we own with this account in this account; if we've shared them with other accounts, we have no idea if they are being used (and finding out is nontrivial, unfortunately). TODO: Also check to see if we are using it for any ASG launch configurations. This is more difficult because you cannot filter them by AMI ID like you can with instances; you have to fetch all of them and then parse through them doing the comparison, making it much more onerous. :/
func (*AMIClean) GetImages ¶
func (a *AMIClean) GetImages() (*ec2.DescribeImagesOutput, error)
GetImages gets us all the private AMIs on our account so that they can be looked through later. We have to do this here because the AWS API does not allow you to search for AMIs by creation date or by *not* having a tag set to a certain value, which would speed this up considerably.