Cleanup multi-region support for ELB, SQS, Cloudformation, EC2, Autoscaling.
This commit is contained in:
parent
b39861052b
commit
bd847bd941
16 changed files with 184 additions and 90 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
import json
|
||||
|
||||
import boto.cloudformation
|
||||
from moto.core import BaseBackend
|
||||
|
||||
from .parsing import ResourceMap, OutputMap
|
||||
|
|
@ -9,9 +10,10 @@ from .exceptions import ValidationError
|
|||
|
||||
|
||||
class FakeStack(object):
|
||||
def __init__(self, stack_id, name, template, notification_arns=None):
|
||||
def __init__(self, stack_id, name, template, region_name, notification_arns=None):
|
||||
self.stack_id = stack_id
|
||||
self.name = name
|
||||
self.region_name = region_name
|
||||
self.notification_arns = notification_arns if notification_arns else []
|
||||
self.template = template
|
||||
self.status = 'CREATE_COMPLETE'
|
||||
|
|
@ -19,7 +21,7 @@ class FakeStack(object):
|
|||
template_dict = json.loads(self.template)
|
||||
self.description = template_dict.get('Description')
|
||||
|
||||
self.resource_map = ResourceMap(stack_id, name, template_dict)
|
||||
self.resource_map = ResourceMap(stack_id, name, region_name, template_dict)
|
||||
self.resource_map.create()
|
||||
|
||||
self.output_map = OutputMap(self.resource_map, template_dict)
|
||||
|
|
@ -40,9 +42,15 @@ class CloudFormationBackend(BaseBackend):
|
|||
self.stacks = {}
|
||||
self.deleted_stacks = {}
|
||||
|
||||
def create_stack(self, name, template, notification_arns=None):
|
||||
def create_stack(self, name, template, region_name, notification_arns=None):
|
||||
stack_id = generate_stack_id(name)
|
||||
new_stack = FakeStack(stack_id=stack_id, name=name, template=template, notification_arns=notification_arns)
|
||||
new_stack = FakeStack(
|
||||
stack_id=stack_id,
|
||||
name=name,
|
||||
template=template,
|
||||
region_name=region_name,
|
||||
notification_arns=notification_arns,
|
||||
)
|
||||
self.stacks[stack_id] = new_stack
|
||||
return new_stack
|
||||
|
||||
|
|
@ -90,4 +98,8 @@ class CloudFormationBackend(BaseBackend):
|
|||
self.delete_stack(stack_to_delete.stack_id)
|
||||
|
||||
|
||||
cloudformation_backend = CloudFormationBackend()
|
||||
cloudformation_backends = {}
|
||||
for region in boto.cloudformation.regions():
|
||||
cloudformation_backends[region.name] = CloudFormationBackend()
|
||||
|
||||
cloudformation_backend = cloudformation_backends['us-east-1']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue