Add SNS topics to cloudformation.
This commit is contained in:
parent
f19fdc9802
commit
c22ea3014b
3 changed files with 75 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ from moto.elb import models as elb_models
|
|||
from moto.iam import models as iam_models
|
||||
from moto.rds import models as rds_models
|
||||
from moto.route53 import models as route53_models
|
||||
from moto.sns import models as sns_models
|
||||
from moto.sqs import models as sqs_models
|
||||
from .utils import random_suffix
|
||||
from .exceptions import MissingParameterError, UnformattedGetAttTemplateException
|
||||
|
|
@ -41,6 +42,7 @@ MODEL_MAP = {
|
|||
"AWS::Route53::HostedZone": route53_models.FakeZone,
|
||||
"AWS::Route53::RecordSet": route53_models.RecordSet,
|
||||
"AWS::Route53::RecordSetGroup": route53_models.RecordSetGroup,
|
||||
"AWS::SNS::Topic": sns_models.Topic,
|
||||
"AWS::SQS::Queue": sqs_models.Queue,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,22 @@ class Topic(object):
|
|||
return self.name
|
||||
raise UnformattedGetAttTemplateException()
|
||||
|
||||
@property
|
||||
def physical_resource_id(self):
|
||||
return self.arn
|
||||
|
||||
@classmethod
|
||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
||||
sns_backend = sns_backends[region_name]
|
||||
properties = cloudformation_json['Properties']
|
||||
|
||||
topic = sns_backend.create_topic(
|
||||
properties.get("TopicName")
|
||||
)
|
||||
for subscription in properties.get("Subscription", []):
|
||||
sns_backend.subscribe(topic.arn, subscription['Endpoint'], subscription['Protocol'])
|
||||
return topic
|
||||
|
||||
|
||||
class Subscription(object):
|
||||
def __init__(self, topic, endpoint, protocol):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue