Deterministically creating and tagging EC2 instances

前端 未结 2 1644
陌清茗
陌清茗 2021-01-01 05:53

I am creating 3 EC2 instances, and subsequently iterating and tagging each of them. Sometimes the tag request fails, although the instance later appears to be running.

2条回答
  •  不思量自难忘°
    2021-01-01 06:31

    Tag name cannot be created until the instance is launched . You might try giving the key_name while creating the instance. If you are using boto, it could be done by

    reservation = conn.run_instances(1, 1, instance_type='m1.small', key_name='samplename')
    

    Then instances can be retrieved by passing key_name and once they are in running state, you can also give them the tag name.

提交回复
热议问题