Pattern: Preventative Template
Templates with predefined configurations that enforce cost-optimizing methods can proactively manage and reduce future expenses.
Context
Retroactively implementing cost-saving changes can be inefficient and expensive, especially in the context of large systems.
Solution
Preventative templates can be designed to prioritize cost-optimizations and lead to a proactive enforcement of good practices further on.
Example
Adds a full file with a template for cost optimization that is not yet implemented within the project:
@@ -0,0 +1,111 @@ resource "template" "example" {
+ AWSTemplateFormatVersion: 2010-09-09
+ Description: Template for reducing costs on PN
+
+ Parameters:
+ StopEc2FuctionTagName:
+ Type: String
+ Default: 'tostop'
+ Description: Name of EC2 Tag that will be stopped
+
+ StopEc2FuctionTagValue:
+ Type: String
+ Default: 'true'
+ Description: Value of EC2 Tag that will be stopped
+
+ StopEc2FuctionTagNameCronExpression:
+ Type: String
+ Default: 'cron(0 22 * * ? *)'
+ Description: Cron expression when ec2 stop
# ...
}
References
Occurrences
AWS CloudFormation
- https://github.com/adrian83/aws-samples/commit/2aedc136fc1ed5e6b794268e5aeba6b625fcf903
- https://github.com/awslabs/aws-well-architected-labs/commit/f82be3a26e356335ebf8feab6971f278215f335c
- https://github.com/primeharbor/aws-account-automation/commit/18f1e36b061d631dca72b494661a21dc37594148
- https://github.com/sjakthol/aws-account-infra/commit/ab4424e4f8a34f47d8511c982b84bfce7086d59a
- https://github.com/PRX/Infrastructure/commit/9961cdbffd8f0750ba4acfa15b3c8f1dc13d4e85
- https://github.com/Sage-Bionetworks/aws-infra/commit/73d9fd5d784eecf01a175ff33152a6ccba5f37ba
- https://github.com/kennyk65/aws-teaching-demos/commit/5dfc77f0065462480ee1eec85927cee7c7d57a77
- https://github.com/karthickcse05/aws-cost-explorer/commit/2750d8c79ab56e69ce2d06e08f02390ae7ba4183
- https://github.com/felixrichardt/cloud-carbon-footprint/commit/f5f4150801b64b5baaa68ecbddccd336a3013d32
- https://github.com/aws-samples/aws-serverless-notifier-plugins/commit/935d60da5f246433742fd66496d5caa84a4c80d2
- https://github.com/danielgblanco/diaspora-aws/commit/e758a12feaaa4b56c18068c1f4426442b9840c79
- https://github.com/superwerker/superwerker/commit/21ef2d4c44d4a881c45e99ace627f1c66fa8d141
- https://github.com/pagopa/pn-infra/commit/4845feae578f173eaa75ffbf03f049a7fe735552
- https://github.com/PRX/Infrastructure/commit/d9d90ba0a708d9c37c5f0fde020a3e094f67cf59
- https://github.com/Nonagon-Media/acg/commit/dfc8a883d178a78c5233e1d790cc5f8209f93b6b
- https://github.com/xhiroga/til/commit/9d549cbcad7886c8861c5f69fb8f3d549e2f7664
- https://github.com/christoferson/aws-cloudformation/commit/fbde48d9640dbff07552bb4f7357b44b16ad9675
- https://github.com/btkrausen/aws/commit/84932c34ae2a4967809a76e58a67b41f89e43dde
- https://github.com/PRX/Infrastructure/commit/579ba639b31f26998b6817c9558f1db2c6cfd028
- https://github.com/tomwwright/littleorange/commit/4bca2634fd0e7b2f90111838924d68decd71eef5
- https://github.com/nathanpeck/ecs-patterns-vitepress/commit/58f54cb34506995953cf59a380ad6670be93ed50
- https://github.com/Nxtra/aws-billing-alarms/commit/0a15638e30d0e0a55ee76c3402a67ff91c50339e
- https://github.com/awslabs/cid-framework/commit/a9e275cdc1bb0b38fbd2a172b6a61534c869ecd2