Add cloudformation support for EventBridge
This commit is contained in:
parent
fc9cecc154
commit
7318523b50
3 changed files with 45 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
import functools
|
||||
import json
|
||||
|
|
@ -18,6 +19,7 @@ from moto.ec2 import models as ec2_models
|
|||
from moto.ecs import models as ecs_models
|
||||
from moto.elb import models as elb_models
|
||||
from moto.elbv2 import models as elbv2_models
|
||||
from moto.events import models as events_models
|
||||
from moto.iam import models as iam_models
|
||||
from moto.kinesis import models as kinesis_models
|
||||
from moto.kms import models as kms_models
|
||||
|
|
@ -94,6 +96,7 @@ MODEL_MAP = {
|
|||
"AWS::SNS::Topic": sns_models.Topic,
|
||||
"AWS::S3::Bucket": s3_models.FakeBucket,
|
||||
"AWS::SQS::Queue": sqs_models.Queue,
|
||||
"AWS::Events::Rule": events_models.Rule,
|
||||
}
|
||||
|
||||
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html
|
||||
|
|
|
|||
|
|
@ -55,6 +55,24 @@ class Rule(BaseModel):
|
|||
if index is not None:
|
||||
self.targets.pop(index)
|
||||
|
||||
@classmethod
|
||||
def create_from_cloudformation_json(
|
||||
cls, resource_name, cloudformation_json, region_name
|
||||
):
|
||||
properties = cloudformation_json["Properties"]
|
||||
event_backend = events_backends[region_name]
|
||||
event_name = properties.get("Name") or resource_name
|
||||
return event_backend.put_rule(name=event_name, **properties)
|
||||
|
||||
@classmethod
|
||||
def delete_from_cloudformation_json(
|
||||
cls, resource_name, cloudformation_json, region_name
|
||||
):
|
||||
properties = cloudformation_json["Properties"]
|
||||
event_backend = events_backends[region_name]
|
||||
event_name = properties.get("Name") or resource_name
|
||||
event_backend.delete_rule(name=event_name)
|
||||
|
||||
|
||||
class EventBus(BaseModel):
|
||||
def __init__(self, region_name, name):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue