aws-s3-virusscan icon indicating copy to clipboard operation
aws-s3-virusscan copied to clipboard

Replace static RegionMap

Open duckworth opened this issue 1 year ago • 5 comments

with Query the latest Amazon Linux AMI from AWS Systems Manager Parameter Store

duckworth avatar May 11 '23 19:05 duckworth

Thanks a lot for your contribution, @duckworth.

I like the simplicity of your approach to fetch the latest AMIs from the Parameter Store.

However, I prefer having a list of AMIs in the template to ensure testability and stability.

What are your thoughts, @michaelwittig.

andreaswittig avatar May 11 '23 19:05 andreaswittig

I can try adding a param to override the AMI Id if you want it static for testing but have it fallback to the latest if it is blank.

duckworth avatar May 11 '23 19:05 duckworth

I understand the idea why it looks tempting to fetch the AMI from some remote place. But: We want the template to be deterministic. Introducing a variable that comes from the outside (aka side effect) is against this idea. A released and automatically tested template should stay the same no matter what. Otherwise we end up with releases that could break at some point when AWS decides to push an AMI that is incompatible in some way.

What we could (and should) do is update the map with the latest AMI IDs and release a new version.

michaelwittig avatar May 12 '23 11:05 michaelwittig

Yeah, I understand and it makes sense for a public template. There are just so many outdated templates with vulnerable ami's out there. I have started having them get latest AMI in case of stack creation but keep the AMI in case of stack updates, as I would rather have it break when creating a new stack and deal with it then.

If you are going to keep the static AMI the one thing I would suggest is adding yum_cron with security upgrades enabled. I can open a pull request for that if you are interested.

duckworth avatar May 13 '23 11:05 duckworth

What we usually do these days is to use SSM Patch Manager. That requires SystemsManagerAccess to bet set to true. The benefit is that you get monitoring out of the box. If the cron fails you have to add some logic to monitor that.

michaelwittig avatar May 23 '23 12:05 michaelwittig