Skip to content
This repository
Browse code

apply tags immediately after creating instance

  • Loading branch information...
commit 555b1673a1afe74799c4ce552b52dce5f43b1f3d 1 parent 05ee4fe
Tobias McNulty authored January 05, 2012

Showing 1 changed file with 4 additions and 3 deletions. Show diff stats Hide diff stats

  1. 7  fabulaws/ec2.py
7  fabulaws/ec2.py
@@ -155,6 +155,9 @@ def _create_instance(self, instance_id=None):
155 155
                             placement=self._placement)
156 156
             created = True
157 157
         inst = res.instances[0]
  158
+        if self._tags:
  159
+            logger.debug('Creating tags on instance.')
  160
+            self.conn.create_tags([inst.id], self._tags)
158 161
         logger.debug('Attached to EC2 instance {0}'.format(inst.id))
159 162
         if created:
160 163
             try:
@@ -252,7 +255,6 @@ def setup(self):
252 255
         """
253 256
         self.key, self.key_file = self._create_key_pair()
254 257
         self.instance = self._create_instance()
255  
-        self.add_tags(self._tags)
256 258
 
257 259
     def add_to_elb(self, elb_name):
258 260
         """
@@ -286,8 +288,7 @@ def add_tags(self, tags):
286 288
         """
287 289
         Associate specified tags with instance
288 290
         """
289  
-        if tags:
290  
-            self.conn.create_tags([self.instance.id], tags)
  291
+        self.conn.create_tags([self.instance.id], tags)
291 292
 
292 293
     @property
293 294
     def hostname(self):

0 notes on commit 555b167

Please sign in to comment.
Something went wrong with that request. Please try again.