I am trying to find a way to provide an additional level of protection to keep S3 Buckets from accidentally deleted. I want to implement bucket policies, but I want to do it through cloudformation so that if new buckets are added I can simply run the script again and have the same policy applied to new buckets.
I found this post serverfault post on how to create a bucket policy to prevent the deletion of a bucket, so it's simple enough to add the policy to a single bucket. How can I get this to work in a cloudformation script so that it applies to all S3 buckets? It would be easy enough to just add a statement for every bucket, but that doesn't seem very maintainable if additional buckets are added.
Would it be possible to create parameter that would show every bucket as a checkbox and apply the policy that way?
Thanks!