Tampa
Tampa

Reputation: 78244

How to add a tag/name when creatng a volume on ec2 using boto

I can create a volume using boto using the below code.

But, I need to add a name or tag e.g 'my-tag'. How do I do that in boto when I create the volume?

    import boto
    from boto import ec2
    region_id = boto.ec2.get_region(region_id, aws_access_key_id=aws_access_key_id,
                                 aws_secret_access_key=self.aws_secret_access_key)
    conn = ec2.connection.EC2Connection(region=region_id, aws_access_key_id=aws_access_key_id,
                                        aws_secret_access_key=aws_secret_access_key)
    vol = conn.create_volume(gigs, placement)

Upvotes: 1

Views: 738

Answers (1)

markA
markA

Reputation: 1609

To Name it: vol.add_tag("Name","yourName") Name is just a special case sensitive tag

To Tag it: vol.add_tag("tagName","Value")

From Boto Documentation boto.ec2.ec2object Section

Upvotes: 2

Related Questions