puppetlabs-toy-chest / puppetlabs-aws

Puppet module for managing AWS resources to build out infrastructure
Apache License 2.0
188 stars 216 forks source link

How to attach existing volume on ec2_instance #443

Open atmesh opened 7 years ago

atmesh commented 7 years ago

I have been trying to attach EBS volume to a VM created using this module using volume name. It gives error "Parameter block_devices failed on Ec2_instance[instance-name]: block device must include at least one of: volume_size snapshot_id". What is the procedure to create a volume and attach it?

class check {

ec2_volume { 'puppet test':
  ensure            => 'present',
  availability_zone => 'ap-south-1a',
  iops              => '100',
  region            => 'ap-south-1',
  size              => '30',
  volume_type       => 'io1',
}  ->

ec2_instance { 'check':
    ensure              => 'running',
    availability_zone   => 'ap-south-1b',
    block_devices       => [{
        delete_on_termination => true,
        device_name           => '/dev/sda1',
        volume_size           => 30
      },
      {
        delete_on_termination => false,
        device_name           => 'puppet test',
      }
      ],
    ebs_optimized       => true,
    image_id            => 'ami-cdbdd7a2',
    instance_type       => 'm4.xlarge',
    key_name            => 'check',
    monitoring          => false,
    region              => 'ap-south-1',
    security_groups     => ['check'],
    subnet              => 'NP-SN-AZB-172.23.16.0.24',

  }

}
cyberious commented 7 years ago

Have you tried duplicating the volume_size in the second block?