Guys,
I can use boto to create instance, but my problem, i dont know how to add tag when use it & get ip address.
If i use ansible, i can give tag name & get ip address of new instance, but the problem the default of root size is 8GB.
How can i add my python file to create instance in ansible/ edit ec2 in ansible?
Thx.
PS: this my python file to create instance:
#!/usr/bin/python
import boto.ec2
conn = boto.ec2.connect_to_region(“ap-southeast-1”,
aws_access_key_id=‘youraccesskey’,
aws_secret_access_key=‘yoursecretaccesskey’)
dev_sda1 = boto.ec2.blockdevicemapping.EBSBlockDeviceType()
dev_sda1.size = 150 # change root volume to 100GB instead of default 8gb
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping()
bdm[‘/dev/sda1’] = dev_sda1
reservation = conn.run_instances(
‘ami-085b155a’,
key_name=‘yourkeyname’,
instance_type=‘m3.large’,
security_groups=[‘yoursecgroupname’],
block_device_map = bdm)