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", 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) {