-
Type:
Suggestion
-
Resolution: Unresolved
-
None
-
Component/s: Elastic Bamboo
-
None
-
0
-
2
Problem definition
Bamboo only creates EBS volumes of type gp2 (the default) for Elastic Instances.
Suggested Resolution
Allow Bamboo to provide a list of EBS volume types so the Administrator can select the one that fits their case.
AWS EBS supports the following EBS volume types:
- gp2 and gp3 for General Purpose SSD
- io1 and io2 for Provisioned IOPS SSD
- st1 for Throughput Optimized HDD
- sc1 for Cold HDD, or standard for Magnetic
Possible implementation:
The EC2 Instance creation POST request should contain something like:
"BlockDeviceMapping.1.Ebs": [ "VolumeType": "<gp2 | gp3 | io1 | io2 | sc1 | st1 | standard>" ],
NOTE: If the selected volume type is io1 or io2, you must specify the IOPS that the volume supports:
"BlockDeviceMapping.1.Ebs": [ "VolumeType": "io1", "Iops": integer ],
Workaround
The workaround consists of a startup script added to the Instance that will convert any non-gp3 volumes to gp3 (including the root volume). Add the following to the instance startup script (Bamboo Administration > Overview > Image Configurations *> *Edit), or add it to your base image to run this during boot.
You are free to customise the script to your requirements, use different volume types, change IOPS, size, etc.
#!/bin/bash # This is part of a Proof of Concept # Do not declare AWS secrets in a public text file! # Use `aws configure` to set the credentials correctly AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" AWS_ACCESS_KEY_ID="XZXZZXZXZXZXZXZXZX" AWS_REGION="ap-southeast-2" # Replace with your region AWS_INSTANCE_ID=$(ec2metadata --instance-id) ALL_VOLS=$(aws ec2 describe-instances --region ${AWS_REGION} --instance-ids ${AWS_INSTANCE_ID} --query 'Reservations[].Instances[].BlockDeviceMappings[].{VolumeID: Ebs.VolumeId}' --output text) for vol in ${ALL_VOLS} ; do _VOL_TYPE=$(aws ec2 describe-volumes --region ${AWS_REGION} --volume-id $vol --query "Volumes[].VolumeType" --output text) if [ "${_VOL_TYPE}" != "gp3" ] ; then echo "Detected volume ${vol} as non-gp3. Converting..." aws ec2 modify-volume --region ${AWS_REGION} --volume-id $vol --volume-type gp3 else echo "EBS volume ${vol} is already of type gp3" fi done
You can follow the script execution once the Instance is up:
root@ip-10-xxx-xxx-xxx:/tmp# cat BambooStartupLog.log
Detected volume vol-d34db33fabc1234 as non-gp3. Converting...
{
"VolumeModification": {
"VolumeId": "vol-d34db33fabc1234",
"ModificationState": "modifying",
"TargetSize": 8,
"TargetIops": 3000,
"TargetVolumeType": "gp3",
"OriginalSize": 8,
"OriginalIops": 100,
"OriginalVolumeType": "gp2",
"Progress": 0,
"StartTime": "2023-02-02T16:12:35.000Z"
}
}
Script /tmp/BambooStartupScript-1.sh exited with status code: 0