From ce9807393de917d6ae78325a9633847383943167 Mon Sep 17 00:00:00 2001 From: Corey Christous Date: Wed, 25 Mar 2026 19:46:48 -0400 Subject: [PATCH 1/2] feat: make auto-allocate-host and auto-release-host configurable Add SEMAPHORE_AGENT_AUTO_ALLOCATE_HOST and SEMAPHORE_AGENT_AUTO_RELEASE_HOST environment variables to control the host resource group's auto-allocate and auto-release behavior. Both default to "true" for backward compatibility. Setting auto-release-host to "false" prevents License Manager from releasing dedicated hosts when instances terminate, which is necessary for pools with pre-allocated static hosts where min == max. --- lib/argument-store.js | 2 ++ lib/aws-semaphore-agent-stack.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/argument-store.js b/lib/argument-store.js index fbcd1db..755f1d5 100644 --- a/lib/argument-store.js +++ b/lib/argument-store.js @@ -38,6 +38,8 @@ class ArgumentStore { "SEMAPHORE_AGENT_LICENSE_CONFIGURATION_ARN": "", "SEMAPHORE_AGENT_MAC_FAMILY": "mac2", "SEMAPHORE_AGENT_MAC_DEDICATED_HOSTS": "", + "SEMAPHORE_AGENT_AUTO_ALLOCATE_HOST": "true", + "SEMAPHORE_AGENT_AUTO_RELEASE_HOST": "true", "SEMAPHORE_AGENT_AZS": "", "SEMAPHORE_AGENT_USE_PRE_SIGNED_URL": "false", "SEMAPHORE_AGENT_OVERPROVISION_STRATEGY": "none", diff --git a/lib/aws-semaphore-agent-stack.js b/lib/aws-semaphore-agent-stack.js index 3705471..751d9a5 100644 --- a/lib/aws-semaphore-agent-stack.js +++ b/lib/aws-semaphore-agent-stack.js @@ -382,11 +382,11 @@ class AwsSemaphoreAgentStack extends Stack { }, { name: "auto-allocate-host", - values: ["true"] + values: [this.argumentStore.get("SEMAPHORE_AGENT_AUTO_ALLOCATE_HOST")] }, { name: "auto-release-host", - values: ["true"] + values: [this.argumentStore.get("SEMAPHORE_AGENT_AUTO_RELEASE_HOST")] }, { name: "auto-host-recovery", From 10667aee58b8100336e8c49df54d3c9d772916a7 Mon Sep 17 00:00:00 2001 From: Corey Christous Date: Thu, 26 Mar 2026 17:47:56 -0400 Subject: [PATCH 2/2] test: add test for configurable auto-allocate/release-host and fix existing host resource group tests Add a test verifying that SEMAPHORE_AGENT_AUTO_ALLOCATE_HOST and SEMAPHORE_AGENT_AUTO_RELEASE_HOST flow through to the CloudFormation template. Also fix the two existing host resource group tests that were missing the auto-host-recovery parameter added in d1f68f2. --- test/aws-semaphore-agent.test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/aws-semaphore-agent.test.js b/test/aws-semaphore-agent.test.js index 076757a..b5ea5ba 100644 --- a/test/aws-semaphore-agent.test.js +++ b/test/aws-semaphore-agent.test.js @@ -950,6 +950,10 @@ describe("host resource group", () => { { Name: "auto-release-host", Values: ["true"] + }, + { + Name: "auto-host-recovery", + Values: ["true"] } ], }, @@ -1003,6 +1007,10 @@ describe("host resource group", () => { { Name: "auto-release-host", Values: ["true"] + }, + { + Name: "auto-host-recovery", + Values: ["true"] } ], }, @@ -1022,6 +1030,27 @@ describe("host resource group", () => { ] }); }) + + test("auto-allocate-host and auto-release-host can be configured", () => { + const argumentStore = basicArgumentStore(); + argumentStore.set("SEMAPHORE_AGENT_OS", "macos"); + argumentStore.set("SEMAPHORE_AGENT_LICENSE_CONFIGURATION_ARN", "arn:aws:license-manager:us-east-1:dummyaccount:license-configuration:lic-08ha0s8hd"); + argumentStore.set("SEMAPHORE_AGENT_AUTO_ALLOCATE_HOST", "false"); + argumentStore.set("SEMAPHORE_AGENT_AUTO_RELEASE_HOST", "false"); + + const template = createTemplate(argumentStore); + template.hasResourceProperties("AWS::ResourceGroups::Group", { + Configuration: Match.arrayWith([ + Match.objectLike({ + Type: "AWS::EC2::HostManagement", + Parameters: Match.arrayWith([ + { Name: "auto-allocate-host", Values: ["false"] }, + { Name: "auto-release-host", Values: ["false"] } + ]) + }) + ]) + }); + }) }) function createTemplate(argumentStore) {