I am sure I am missing something obvious, but I can't find a way to set the default EBS volume size per layer. Every instance I boot on this layer has a 10GB volume by default.
In the Layer configuration pane I try to add an EBS volume with the size I need, but it won't let me mount it on "/".
I need this extra size for my app installed at /srv/www but the doc says one should not mount a volume at this point:
Do not mount Amazon EBS volumes to the following mount points. If the instance is rebooted, autofs might use them to mount an ephemeral device instead of your volume.
/srv/www
You can specify the volume size from 10 GiB (the default) up to 100 GiB when you create a cluster using the AWS Management Console, the AWS CLI, or the Amazon EMR API. This sizing applies only to the EBS root device volume and applies to all instances in the cluster.
With Amazon EBS Elastic Volumes, you can increase the volume size, change the volume type, or adjust the performance of your EBS volumes. If your instance supports Elastic Volumes, you can do so without detaching the volume or restarting the instance.
At the moment of this writing you can't change the default root volume size using OpsWorks. However, when using the API's create-instance command you can provide a block device mapping (like on EC2) and define the size.
For example you can create a file with the contents below, and call it "instance.json" for convenience:
{
"InstanceType": "c4.large",
"RootDeviceType": "ebs",
"BlockDeviceMappings": [
{
"DeviceName": "ROOT_DEVICE",
"Ebs": {
"VolumeSize": 20,
"VolumeType": "gp2",
"DeleteOnTermination": true
}
}
]
}
And you can then execute a command like the one below to create an instance with the desired root volume size, using the file and replacing the correct stack and layer IDs:
aws opsworks create-instance --cli-input-json file://./instance.json --stack-id <stack-id-number-here> --layer-ids <one-or-more-layer-id-numbers-here>
If you prefer a oneliner, though a bit clunkier:
aws opsworks create-instance --stack-id <stack-id-number-here> --layer-ids <one-or-more-layer-id-numbers-here> --instance-type <e.g. c4.large> --block-device-mappings '[{"DeviceName":"ROOT_DEVICE","Ebs":{"VolumeType":"gp2","VolumeSize":20}}]'
Please note that this procedure only works when creating an instance, and you can't modify it after that, except manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With