Question

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

Was it helpful?

Solution 2

You can't mount volumes at /, that's the root. Unfortunately you can't set the root device size in OpsWorks. But you could mount a volume somewhere else like /mnt/www and symlink there.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top