diff --git a/lib/argument-store.js b/lib/argument-store.js index c943aa5..3cc4f79 100644 --- a/lib/argument-store.js +++ b/lib/argument-store.js @@ -31,6 +31,8 @@ class ArgumentStore { "SEMAPHORE_AGENT_VOLUME_NAME": "", "SEMAPHORE_AGENT_VOLUME_TYPE": "gp2", "SEMAPHORE_AGENT_VOLUME_SIZE": "64", + "SEMAPHORE_AGENT_VOLUME_IOPS": "", + "SEMAPHORE_AGENT_VOLUME_THROUGHPUT": "", "SEMAPHORE_AGENT_TAGS": "", "SEMAPHORE_AGENT_LICENSE_CONFIGURATION_ARN": "", "SEMAPHORE_AGENT_MAC_FAMILY": "mac2", diff --git a/lib/aws-semaphore-agent-stack.js b/lib/aws-semaphore-agent-stack.js index 53e527b..7c3a8d2 100644 --- a/lib/aws-semaphore-agent-stack.js +++ b/lib/aws-semaphore-agent-stack.js @@ -441,14 +441,26 @@ class AwsSemaphoreAgentStack extends Stack { return undefined } + const volumeType = this.argumentStore.get("SEMAPHORE_AGENT_VOLUME_TYPE"); + const ebsDevice = { + volumeType: volumeType, + volumeSize: this.argumentStore.getAsNumber("SEMAPHORE_AGENT_VOLUME_SIZE"), + }; + + if (!this.argumentStore.isEmpty("SEMAPHORE_AGENT_VOLUME_IOPS")) { + ebsDevice.iops = this.argumentStore.getAsNumber("SEMAPHORE_AGENT_VOLUME_IOPS"); + } + + // Only set throughput when volume type is gp3 because it is not supported for other volume types. + if (volumeType === "gp3" && !this.argumentStore.isEmpty("SEMAPHORE_AGENT_VOLUME_THROUGHPUT")) { + ebsDevice.throughput = this.argumentStore.getAsNumber("SEMAPHORE_AGENT_VOLUME_THROUGHPUT"); + } + return [ { deviceName: this.argumentStore.get("SEMAPHORE_AGENT_VOLUME_NAME"), volume: { - ebsDevice: { - volumeType: this.argumentStore.get("SEMAPHORE_AGENT_VOLUME_TYPE"), - volumeSize: this.argumentStore.getAsNumber("SEMAPHORE_AGENT_VOLUME_SIZE") - } + ebsDevice: ebsDevice } } ] diff --git a/test/aws-semaphore-agent.test.js b/test/aws-semaphore-agent.test.js index 9948972..aadfeb9 100644 --- a/test/aws-semaphore-agent.test.js +++ b/test/aws-semaphore-agent.test.js @@ -375,7 +375,7 @@ describe("launch configuration", () => { DeviceName: "/dev/sda1", Ebs: { VolumeType: "gp2", - VolumeSize: 64 + VolumeSize: 64, } } ] @@ -388,6 +388,8 @@ describe("launch configuration", () => { argumentStore.set("SEMAPHORE_AGENT_VOLUME_NAME", "/dev/sda1"); argumentStore.set("SEMAPHORE_AGENT_VOLUME_TYPE", "gp3"); argumentStore.set("SEMAPHORE_AGENT_VOLUME_SIZE", "3981"); + argumentStore.set("SEMAPHORE_AGENT_VOLUME_IOPS", "4500"); + argumentStore.set("SEMAPHORE_AGENT_VOLUME_THROUGHPUT", "450"); const template = createTemplate(argumentStore); template.hasResourceProperties("AWS::EC2::LaunchTemplate", { @@ -397,7 +399,9 @@ describe("launch configuration", () => { DeviceName: "/dev/sda1", Ebs: { VolumeType: "gp3", - VolumeSize: 3981 + VolumeSize: 3981, + Iops: 4500, + Throughput: 450, } } ]