@@ -26,6 +26,12 @@ interface CostPoint {
2626 nimbusMonthly : number ;
2727}
2828
29+ interface TerraformSuggestion {
30+ desiredCapacity : number ;
31+ comment : string ;
32+ snippet : string ;
33+ }
34+
2935const DEFAULT_INPUTS : RoiInputs = {
3036 runsPerDay : 180 ,
3137 avgRuntimeMins : 12 ,
@@ -109,6 +115,28 @@ export function ToolsPage() {
109115 URL . revokeObjectURL ( url ) ;
110116 } ;
111117
118+ const terraformSuggestion = useMemo < TerraformSuggestion > ( ( ) => {
119+ const totalMinutesPerDay = inputs . runsPerDay * inputs . avgRuntimeMins ;
120+ const targetUtilisationMinutes = 8 * 60 ; // assume 8 productive hours per agent
121+ const desiredCapacity = Math . max ( 1 , Math . ceil ( totalMinutesPerDay / targetUtilisationMinutes ) ) ;
122+ const snippet = [
123+ "# Suggested values generated by the ROI calculator" ,
124+ `agent_instance_type = "t3.large"` ,
125+ `agent_desired_capacity = ${ desiredCapacity } ` ,
126+ ] . join ( "\n" ) ;
127+ const comment =
128+ "Assuming ~8 productive hours per agent each day. Tweak the instance type or desired capacity to match your workload." ;
129+ return {
130+ desiredCapacity,
131+ comment,
132+ snippet,
133+ } ;
134+ } , [ inputs ] ) ;
135+
136+ const handleCopyTerraform = ( ) => {
137+ void navigator . clipboard . writeText ( terraformSuggestion . snippet ) ;
138+ } ;
139+
112140 return (
113141 < div className = "tools__container" >
114142 < header className = "tools__header" >
@@ -187,6 +215,19 @@ export function ToolsPage() {
187215 </ li >
188216 </ ul >
189217 </ section >
218+
219+ < section className = "tools__section" >
220+ < div className = "tools__chart-header" >
221+ < h2 > Terraform autoscaling snippet</ h2 >
222+ < button type = "button" onClick = { handleCopyTerraform } className = "tools__download" >
223+ Copy snippet
224+ </ button >
225+ </ div >
226+ < p className = "tools__terraform-comment" > { terraformSuggestion . comment } </ p >
227+ < pre className = "tools__terraform-snippet" >
228+ { terraformSuggestion . snippet }
229+ </ pre >
230+ </ section >
190231 </ div >
191232 ) ;
192233}
0 commit comments