Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/argument-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ArgumentStore {
"SEMAPHORE_AGENT_ASG_MAX_SIZE": "1",
"SEMAPHORE_AGENT_ASG_DESIRED": "",
"SEMAPHORE_AGENT_ASG_METRICS": "",
"SEMAPHORE_AGENT_ASG_MAX_INSTANCE_LIFETIME": "0",
"SEMAPHORE_AGENT_DISCONNECT_AFTER_JOB": "true",
"SEMAPHORE_AGENT_DISCONNECT_AFTER_IDLE_TIMEOUT": "300",
"SEMAPHORE_AGENT_OS": "ubuntu-focal",
Expand Down
5 changes: 5 additions & 0 deletions lib/aws-semaphore-agent-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ class AwsSemaphoreAgentStack extends Stack {
],
});

const maxInstanceLifetime = this.argumentStore.getAsNumber("SEMAPHORE_AGENT_ASG_MAX_INSTANCE_LIFETIME");
if (maxInstanceLifetime !== 0) {
autoScalingGroup.maxInstanceLifetime = maxInstanceLifetime;
}

// if the desired capacity is not specified, leave it empty.
// Setting a default desired capacity leads to Cloudformation resetting it during an in-place update.
// That can be an issue if you have your stack configured to automatically scale up/down, so we don't do that here.
Expand Down
11 changes: 10 additions & 1 deletion test/aws-semaphore-agent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ describe("auto scaling group", () => {
template.hasResourceProperties("AWS::AutoScaling::AutoScalingGroup", {
DesiredCapacity: Match.absent(),
MinSize: "0",
MaxSize: "1"
MaxSize: "1",
});
})

Expand Down Expand Up @@ -630,6 +630,15 @@ describe("auto scaling group", () => {

template.resourceCountIs("AWS::CloudFormation::CustomResource", 1);
})

test("max instance lifetime is set", () => {
const argumentStore = basicArgumentStore();
argumentStore.set("SEMAPHORE_AGENT_ASG_MAX_INSTANCE_LIFETIME", 86400);
const template = createTemplate(argumentStore);
template.hasResourceProperties("AWS::AutoScaling::AutoScalingGroup", {
MaxInstanceLifetime: 86400,
});
})
})

describe("scaler lambda", () => {
Expand Down