VMware Cloud Community
Cloud_dev
Contributor
Contributor
Jump to solution

How to list EBS Block devices attached to AWS EC2 Instance using VRO workflow?

Please help me to list EBS volume Ids attached to an EC2 instance.

0 Kudos
1 Solution

Accepted Solutions
drummoau
Enthusiast
Enthusiast
Jump to solution

The property is on all objects (instances, volumes, network interfaces) but doesn't show in the object explorer.

Edit: I just fixed the code above, I had a double dot notation (client..getAmazonEC2Client())

View solution in original post

0 Kudos
7 Replies
scott28tt
VMware Employee
VMware Employee
Jump to solution

Moderator note: This discussion belongs in the vRO forum area, so I moved it there.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
drummoau
Enthusiast
Enthusiast
Jump to solution

Using the vRO AWS plug-in

// Where ec2Instance is of type AWS:EC2Instance

var ec2Client = ec2Instance.client.getAmazonEC2Client();

var ec2DescribeVolumesRequest = new EC2DescribeVolumesRequest();

var ec2Filter = new EC2Filter();

ec2Filter.setName("attachment.instance-id");

ec2Filter.setValues([ec2Instance.instanceId]);

var result = ec2Client.describeVolumes(ec2DescribeVolumesRequest.withFilters([ec2Filter]));

return result.getVolumes();

0 Kudos
Cloud_dev
Contributor
Contributor
Jump to solution

Thanx for the reply.
U suggested to take Input type of  ec2Instance(AWS:EC2Instance)
But AWS:EC2Instance does not show ec2instance.client attribute.

Error message showing cannot ec2instance.client.
Please help me to resolve this

0 Kudos
drummoau
Enthusiast
Enthusiast
Jump to solution

The property is on all objects (instances, volumes, network interfaces) but doesn't show in the object explorer.

Edit: I just fixed the code above, I had a double dot notation (client..getAmazonEC2Client())

0 Kudos
Cloud_dev
Contributor
Contributor
Jump to solution

Thanx for the help Smiley Happy.

This is our output file having Volumes attached to it.

[2016-11-09 05:47:43.979] [I] DynamicWrapper (Instance) : [EC2Volume]-[class com.vmware.o11n.plugin.aws.ec2.model.Volume] -- VALUE : {VolumeId: vol-b43f8528,Size: 20,SnapshotId: snap-3ecc5a48,AvailabilityZone: us-east-1a,State: in-use,CreateTime: Wed Nov 02 09:21:24 EDT 2016,Attachments: [{VolumeId: vol-b43f8528,InstanceId: i-dec3e347,Device: /dev/sda1,State: attached,AttachTime: Wed Nov 02 09:21:24 EDT 2016,DeleteOnTermination: true}],Tags: [{Key: InstanceID,Value: i-dec3e347}, {Key: CostCenter,Value: 0002355678}, {Key: ProjectName,Value: Development AWS Snapshot}],VolumeType: gp2,Iops: 100},DynamicWrapper (Instance) : [EC2Volume]-[class com.vmware.o11n.plugin.aws.ec2.model.Volume] -- VALUE : {VolumeId: vol-063f859a,Size: 1,SnapshotId: ,AvailabilityZone: us-east-1a,State: in-use,CreateTime: Wed Nov 02 09:21:41 EDT 2016,Attachments: [{VolumeId: vol-063f859a,InstanceId: i-dec3e347,Device: xvdf,State: attached,AttachTime: Wed Nov 02 09:22:02 EDT 2016,DeleteOnTermination: false}],Tags: [{Key: Description,Value: }, {Key: CostCenter,Value: 0002355678}, {Key: Name,Value: EBS}, {Key: InstanceID,Value: i-dec3e347}, {Key: VCAC Owner,Value: }, {Key: ProjectName,Value: Development AWS Snapshot}],VolumeType: standard,}

How to filter out only volume Ids from this output. Please help

0 Kudos
drummoau
Enthusiast
Enthusiast
Jump to solution

If you look in the Object Explorer at AWS:EC2Volume you will see it has a getVolumeId() method; it also has a volumeId property but this isn't show in the explorer.

Thus:

// where ec2Volumes is your result from the previous code (AWS:EC2olumes[])

for each (var ec2Volume in ec2Volumes) {

  System.debug(ec2Volume.volumeId);

}

When using the plug-in, you'll need to dig around in the API explorer looking at the AWS classes and methods; at the same time, it's best to look through the AWS Javadocs to get an idea of how it all works, as sometimes the plug-in does things differently or hasn't exposed certain methods/properties.

0 Kudos
Cloud_dev
Contributor
Contributor
Jump to solution

Hi Need your help to solve the following issue?

How to fetch/filter snapshots created from a EBS volume through VRO?

This question is Not Answered.(Mark as assumed answered)

chandan singhLurker

Please help me to find out list of snapshots created from a EBS volume through VRO workflow/action element.?

0 Kudos