instance_definition = copy.deepcopy(conf.t)
instance_definition['Type'] = 'AWS::EC2::Instance'
instance_definition['Properties']['Tags'] = self._tags()
+ if self.properties.get('VPCZoneIdentifier'):
+ instance_definition['Properties']['SubnetId'] = \
+ self.properties['VPCZoneIdentifier'][0]
# resolve references within the context of this stack.
fully_parsed = self.stack.resolve_runtime_data(instance_definition)
'AllowedValues': ['EC2', 'ELB'],
'Implemented': False},
'LoadBalancerNames': {'Type': 'List'},
+ 'VPCZoneIdentifier': {'Type': 'List'},
'Tags': {'Type': 'List', 'Schema': {'Type': 'Map',
'Schema': tags_schema}}
}
def FnGetRefId(self):
return unicode(self.name)
+ def validate(self):
+ res = super(AutoScalingGroup, self).validate()
+ if res:
+ return res
+
+ # TODO(pasquier-s): once Neutron is able to assign subnets to
+ # availability zones, it will be possible to specify multiple subnets.
+ # For now, only one subnet can be specified. The bug #1096017 tracks
+ # this issue.
+ if self.properties.get('VPCZoneIdentifier') and \
+ len(self.properties['VPCZoneIdentifier']) != 1:
+ raise exception.NotSupported(feature=_("Anything other than one "
+ "VPCZoneIdentifier"))
+
class LaunchConfiguration(resource.Resource):
tags_schema = {'Key': {'Type': 'String',
rsrc.delete()
self.m.VerifyAll()
+
+ def test_vpc_zone_identifier(self):
+ t = template_format.parse(as_template)
+ properties = t['Resources']['WebServerGroup']['Properties']
+ properties['VPCZoneIdentifier'] = ['xxxx']
+
+ stack = utils.parse_stack(t, params=self.params)
+
+ self._stub_lb_reload(1)
+ now = timeutils.utcnow()
+ self._stub_meta_expected(now, 'ExactCapacity : 1')
+ self._stub_create(1)
+ self.m.ReplayAll()
+
+ rsrc = self.create_scaling_group(t, stack, 'WebServerGroup')
+ instances = rsrc.get_instances()
+ self.assertEqual(1, len(instances))
+ self.assertEqual('xxxx', instances[0].properties['SubnetId'])
+
+ rsrc.delete()
+ self.m.VerifyAll()
+
+ def test_invalid_vpc_zone_identifier(self):
+ t = template_format.parse(as_template)
+ properties = t['Resources']['WebServerGroup']['Properties']
+ properties['VPCZoneIdentifier'] = ['xxxx', 'yyyy']
+
+ stack = utils.parse_stack(t, params=self.params)
+
+ self.assertRaises(exception.NotSupported, self.create_scaling_group, t,
+ stack, 'WebServerGroup')