Skip to content

Commit 571ec15

Browse files
authored
add in default shutdown for crons to be terminate (#1716)
1 parent ca8ead3 commit 571ec15

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

provider/aws/aws_cron.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,20 @@ func (p *AWS) CreateCron(ctx *lepton.Context, name string, schedule string) erro
125125
scheduleName := name
126126
targetArn := "arn:aws:scheduler:::aws-sdk:ec2:runInstances"
127127
executionRoleArn := os.Getenv("EXECUTIONARN")
128+
if executionRoleArn == "" {
129+
fmt.Println("you need to set EXECUTIONARN to a valid IAM role that can assume the role for eventbridge scheduler")
130+
os.Exit(1)
131+
}
128132

129133
scheduleExpression := schedule
130134

131135
inputJSON := `{
132-
"ImageId":"` + ami + `",
133-
"InstanceType":"` + cloudConfig.Flavor + `",
134-
"MinCount":1,
135-
"MaxCount":1,
136-
"NetworkInterfaces":[
136+
"ImageId":"` + ami + `",
137+
"InstanceType":"` + cloudConfig.Flavor + `",
138+
"MinCount":1,
139+
"MaxCount":1,
140+
"InstanceInitiatedShutdownBehavior":"terminate",
141+
"NetworkInterfaces":[
137142
{
138143
"DeleteOnTermination": true,
139144
"DeviceIndex": 0,

0 commit comments

Comments
 (0)