puppetlabs-aws icon indicating copy to clipboard operation
puppetlabs-aws copied to clipboard

How to attach existing volume on ec2_instance

Open atmesh opened this issue 8 years ago • 1 comments
trafficstars

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',
  
  }

}

atmesh avatar Apr 03 '17 05:04 atmesh

Have you tried duplicating the volume_size in the second block?

cyberious avatar Jun 21 '17 07:06 cyberious