diff --git a/docs/cloudformation_compatibility.rst b/docs/cloudformation_compatibility.rst index 15fab40a4..509d6d28e 100644 --- a/docs/cloudformation_compatibility.rst +++ b/docs/cloudformation_compatibility.rst @@ -139,7 +139,17 @@ Description All Enabled All ======================== ================================== ======================== -CloudWatchEvent +CloudWatchEvent (superseded by EventBridgeRule, see below) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +======================== ================================== ======================== + Property Name Intrinsic(s) Supported Reasons +======================== ================================== ======================== +Pattern All +Input All +InputPath All +======================== ================================== ======================== + +EventBridgeRule ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ======================== ================================== ======================== Property Name Intrinsic(s) Supported Reasons diff --git a/docs/internals/generated_resources.rst b/docs/internals/generated_resources.rst index 004a94363..d9ac2050d 100644 --- a/docs/internals/generated_resources.rst +++ b/docs/internals/generated_resources.rst @@ -385,7 +385,7 @@ AWS::Lambda::Permission MyFunction\ **MyTimer**\ Permission AWS::Events::Rule MyFunction\ **MyTimer** ================================== ================================ -CloudWatchEvent +CloudWatchEvent (superseded by EventBridgeRule, see below) ^^^^^^^^^^^^^^^ Example: @@ -401,9 +401,13 @@ Example: Type: CloudWatchEvent Properties: Pattern: + source: + - aws.ec2 + detail-type: + - EC2 Instance State-change Notification detail: state: - - terminated + - terminated ... Additional generated resources: @@ -415,6 +419,39 @@ AWS::Lambda::Permission MyFunction\ **OnTerminate**\ Permission AWS::Events::Rule MyFunction\ **OnTerminate** ================================== ================================ +EventBridgeRule +^^^^^^^^^^^^^^^ + +Example: + +.. code:: yaml + + MyFunction: + Type: AWS::Serverless::Function + Properties: + ... + Events: + OnTerminate: + Type: EventBridgeRule + Properties: + Pattern: + source: + - aws.ec2 + detail-type: + - EC2 Instance State-change Notification + detail: + state: + - terminated + ... + +Additional generated resources: + +================================== ================================ +CloudFormation Resource Type Logical ID +================================== ================================ +AWS::Lambda::Permission MyFunction\ **OnTerminate**\ Permission +AWS::Events::Rule MyFunction\ **OnTerminate** +================================== ================================ AWS::Serverless::Api -------------------- diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/readme b/examples/2016-10-31/cloudwatch-event-to-msteams/readme new file mode 100644 index 000000000..1976bc0aa --- /dev/null +++ b/examples/2016-10-31/cloudwatch-event-to-msteams/readme @@ -0,0 +1,3 @@ +CloudWatch Events has been re-launched as Amazon EventBridge with full backwards compatibility + +Please see ../eventbridge-event-to-msteams/ for the migrated code \ No newline at end of file diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/events/event_federated.json b/examples/2016-10-31/eventbridge-event-to-msteams/events/event_federated.json similarity index 100% rename from examples/2016-10-31/cloudwatch-event-to-msteams/events/event_federated.json rename to examples/2016-10-31/eventbridge-event-to-msteams/events/event_federated.json diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/events/event_iam.json b/examples/2016-10-31/eventbridge-event-to-msteams/events/event_iam.json similarity index 100% rename from examples/2016-10-31/cloudwatch-event-to-msteams/events/event_iam.json rename to examples/2016-10-31/eventbridge-event-to-msteams/events/event_iam.json diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/events/event_security_group.json b/examples/2016-10-31/eventbridge-event-to-msteams/events/event_security_group.json similarity index 100% rename from examples/2016-10-31/cloudwatch-event-to-msteams/events/event_security_group.json rename to examples/2016-10-31/eventbridge-event-to-msteams/events/event_security_group.json diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml b/examples/2016-10-31/eventbridge-event-to-msteams/template.yaml similarity index 98% rename from examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml rename to examples/2016-10-31/eventbridge-event-to-msteams/template.yaml index e06c5b579..cbffa06d5 100644 --- a/examples/2016-10-31/cloudwatch-event-to-msteams/template.yaml +++ b/examples/2016-10-31/eventbridge-event-to-msteams/template.yaml @@ -42,7 +42,7 @@ Resources: Resource: '*' Events: WatchSecurityGroupRule: - Type: CloudWatchEvent + Type: EventBridgeRule Description: Detects EC2 Security Group Events to Send to Teams Properties: EventBusName: event-bus-name diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/vars.json b/examples/2016-10-31/eventbridge-event-to-msteams/vars.json similarity index 100% rename from examples/2016-10-31/cloudwatch-event-to-msteams/vars.json rename to examples/2016-10-31/eventbridge-event-to-msteams/vars.json diff --git a/examples/2016-10-31/cloudwatch-event-to-msteams/watch-security-group.py b/examples/2016-10-31/eventbridge-event-to-msteams/watch-security-group.py similarity index 100% rename from examples/2016-10-31/cloudwatch-event-to-msteams/watch-security-group.py rename to examples/2016-10-31/eventbridge-event-to-msteams/watch-security-group.py diff --git a/examples/2016-10-31/schedule/README.md b/examples/2016-10-31/schedule/README.md index 1fd03739f..56db94b10 100644 --- a/examples/2016-10-31/schedule/README.md +++ b/examples/2016-10-31/schedule/README.md @@ -10,7 +10,7 @@ The `ScheduledFunction` is of type `AWS::Serverless::Function`. This is a Server `AWS::Lambda::Function` is the top-level CloudFormation resource to define an Amazon Lambda function. Because we want to schedule the function’s periodic execution, we include an `Events` property on our `AWS::Serverless::Function` resource. This allows us to define the function execution schedule *within* the context of the function’s properties. Behind-the-scenes, the `Events` property expands into a `AWS::Events::Rule` resource with an invocation rate of once every 5 minutes. -Lastly, in order for the CloudWatch Events API to invoke our function, it needs permissions to do so. `AWS::Lambda::Permission` grants CloudWatch Events the permission to invoke our function. +Lastly, in order for the EventBridge API to invoke our function, it needs permissions to do so. `AWS::Lambda::Permission` grants CloudWatch Events the permission to invoke our function. ### Deployment diff --git a/examples/apps/logicmonitor-send-cloudwatch-events/readme b/examples/apps/logicmonitor-send-cloudwatch-events/readme index 8609b15dc..ba4b2bc2a 100644 --- a/examples/apps/logicmonitor-send-cloudwatch-events/readme +++ b/examples/apps/logicmonitor-send-cloudwatch-events/readme @@ -1,38 +1,3 @@ -''' -This function handles a Slack slash command and echoes the details back to the user. +CloudWatch Events has been re-launched as Amazon EventBridge with full backwards compatibility -Follow these steps to configure the slash command in Slack: - - 1. Navigate to https://.slack.com/services/new - - 2. Search for and select "Slash Commands". - - 3. Enter a name for your command and click "Add Slash Command Integration". - - 4. Copy the token string from the integration settings and use it in the next section. - - 5. After you complete this blueprint, enter the provided API endpoint URL in the URL field. - - -To encrypt your secrets use the following steps: - - 1. Create or use an existing KMS Key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html - - 2. Click the "Enable Encryption Helpers" checkbox - - 3. Paste into the kmsEncryptedToken environment variable and click encrypt - - -Follow these steps to complete the configuration of your command API endpoint - - 1. When completing the blueprint configuration select "Open" for security - on the "Configure triggers" page. - - 2. Enter a name for your execution role in the "Role name" field. - Your function's execution role needs kms:Decrypt permissions. We have - pre-selected the "KMS decryption permissions" policy template that will - automatically add these permissions. - - 3. Update the URL for your Slack slash command with the invocation URL for the - created API resource in the prod stage. -''' \ No newline at end of file +Please see ../logicmonitor-send-eventbridge-events/ for the migrated code \ No newline at end of file diff --git a/examples/apps/logicmonitor-send-cloudwatch-events/lambda_function.py b/examples/apps/logicmonitor-send-eventbridge-events/lambda_function.py similarity index 96% rename from examples/apps/logicmonitor-send-cloudwatch-events/lambda_function.py rename to examples/apps/logicmonitor-send-eventbridge-events/lambda_function.py index adead669a..9ac8d9c75 100644 --- a/examples/apps/logicmonitor-send-cloudwatch-events/lambda_function.py +++ b/examples/apps/logicmonitor-send-eventbridge-events/lambda_function.py @@ -1,6 +1,6 @@ ''' This function uses the LogicMonitor REST API to create LogicMonitor OpsNotes -for CloudWatch Events. +for EventBridge Events. Once the Ops Notes have been created for monitored resources that have associated events, you'll see them on all graphs for those resources. Assuming you already have monitored AWS resources in LogicMonitor, you'll @@ -40,13 +40,12 @@ ACCOUNT_NAME environment variable and click encrypt. -Follow these steps to configure CloudWatch Events Rules that will trigger +Follow these steps to configure EventBridge Rules that will trigger the Lambda Function: - 1. Create a CloudWatch Event Rule that matches the events you'd like + 1. Create an EventBridge Rule that matches the events you'd like to show up in your LogicMonitor account - https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ - WhatIsCloudWatchEvents.html + https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html 2. Configure the rule to trigger this Lambda Function. diff --git a/examples/apps/logicmonitor-send-cloudwatch-events/license.txt b/examples/apps/logicmonitor-send-eventbridge-events/license.txt similarity index 100% rename from examples/apps/logicmonitor-send-cloudwatch-events/license.txt rename to examples/apps/logicmonitor-send-eventbridge-events/license.txt diff --git a/examples/apps/logicmonitor-send-eventbridge-events/readme b/examples/apps/logicmonitor-send-eventbridge-events/readme new file mode 100644 index 000000000..8609b15dc --- /dev/null +++ b/examples/apps/logicmonitor-send-eventbridge-events/readme @@ -0,0 +1,38 @@ +''' +This function handles a Slack slash command and echoes the details back to the user. + +Follow these steps to configure the slash command in Slack: + + 1. Navigate to https://.slack.com/services/new + + 2. Search for and select "Slash Commands". + + 3. Enter a name for your command and click "Add Slash Command Integration". + + 4. Copy the token string from the integration settings and use it in the next section. + + 5. After you complete this blueprint, enter the provided API endpoint URL in the URL field. + + +To encrypt your secrets use the following steps: + + 1. Create or use an existing KMS Key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html + + 2. Click the "Enable Encryption Helpers" checkbox + + 3. Paste into the kmsEncryptedToken environment variable and click encrypt + + +Follow these steps to complete the configuration of your command API endpoint + + 1. When completing the blueprint configuration select "Open" for security + on the "Configure triggers" page. + + 2. Enter a name for your execution role in the "Role name" field. + Your function's execution role needs kms:Decrypt permissions. We have + pre-selected the "KMS decryption permissions" policy template that will + automatically add these permissions. + + 3. Update the URL for your Slack slash command with the invocation URL for the + created API resource in the prod stage. +''' \ No newline at end of file diff --git a/examples/apps/logicmonitor-send-cloudwatch-events/requirements.txt b/examples/apps/logicmonitor-send-eventbridge-events/requirements.txt similarity index 100% rename from examples/apps/logicmonitor-send-cloudwatch-events/requirements.txt rename to examples/apps/logicmonitor-send-eventbridge-events/requirements.txt diff --git a/examples/apps/logicmonitor-send-cloudwatch-events/template.yaml b/examples/apps/logicmonitor-send-eventbridge-events/template.yaml similarity index 79% rename from examples/apps/logicmonitor-send-cloudwatch-events/template.yaml rename to examples/apps/logicmonitor-send-eventbridge-events/template.yaml index eec39c217..3090373fa 100644 --- a/examples/apps/logicmonitor-send-cloudwatch-events/template.yaml +++ b/examples/apps/logicmonitor-send-eventbridge-events/template.yaml @@ -1,20 +1,20 @@ AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Description: >- - Creates LogicMonitor OpsNotes for CloudWatch Events, thereby enabling + Creates LogicMonitor OpsNotes for EventBridge Events, thereby enabling correlation between events and performance data. Parameters: KeyIdParameter: Type: String Resources: - logicmonitorsendcloudwatchevents: + logicmonitorsendeventbridgeevents: Type: 'AWS::Serverless::Function' Properties: Handler: lambda_function.lambda_handler Runtime: python2.7 CodeUri: . Description: >- - Creates LogicMonitor OpsNotes for CloudWatch Events, thereby enabling + Creates LogicMonitor OpsNotes for EventBridge Events, thereby enabling correlation between events and performance data. MemorySize: 128 Timeout: 30 diff --git a/samtranslator/model/eventsources/push.py b/samtranslator/model/eventsources/push.py index ee795dd30..6ce46eec0 100644 --- a/samtranslator/model/eventsources/push.py +++ b/samtranslator/model/eventsources/push.py @@ -93,7 +93,7 @@ class Schedule(PushEventSource): } def to_cloudformation(self, **kwargs): - """Returns the CloudWatch Events Rule and Lambda Permission to which this Schedule event source corresponds. + """Returns the EventBridge Rule and Lambda Permission to which this Schedule event source corresponds. :param dict kwargs: no existing resources need to be modified :returns: a list of vanilla CloudFormation Resources, to which this Schedule event expands @@ -124,7 +124,7 @@ def to_cloudformation(self, **kwargs): return resources def _construct_target(self, function): - """Constructs the Target property for the CloudWatch Events Rule. + """Constructs the Target property for the EventBridge Rule. :returns: the Target property :rtype: dict @@ -140,7 +140,7 @@ def _construct_target(self, function): class CloudWatchEvent(PushEventSource): - """CloudWatch Events event source for SAM Functions.""" + """CloudWatch Events/EventBridge event source for SAM Functions.""" resource_type = 'CloudWatchEvent' principal = 'events.amazonaws.com' property_types = { @@ -151,11 +151,11 @@ class CloudWatchEvent(PushEventSource): } def to_cloudformation(self, **kwargs): - """Returns the CloudWatch Events Rule and Lambda Permission to which this CloudWatch Events event source - corresponds. + """Returns the CloudWatch Events/EventBridge Rule and Lambda Permission to which + this CloudWatch Events/EventBridge event source corresponds. :param dict kwargs: no existing resources need to be modified - :returns: a list of vanilla CloudFormation Resources, to which this CloudWatch Events event expands + :returns: a list of vanilla CloudFormation Resources, to which this CloudWatch Events/EventBridge event expands :rtype: list """ function = kwargs.get('function') @@ -180,7 +180,7 @@ def to_cloudformation(self, **kwargs): return resources def _construct_target(self, function): - """Constructs the Target property for the CloudWatch Events Rule. + """Constructs the Target property for the CloudWatch Events/EventBridge Rule. :returns: the Target property :rtype: dict @@ -197,6 +197,11 @@ def _construct_target(self, function): return target +class EventBridgeRule(CloudWatchEvent): + """EventBridge Rule event source for SAM Functions.""" + resource_type = 'EventBridgeRule' + + class S3(PushEventSource): """S3 bucket event source for SAM Functions.""" resource_type = 'S3' diff --git a/samtranslator/validator/sam_schema/schema.json b/samtranslator/validator/sam_schema/schema.json index c01534263..c18f10620 100644 --- a/samtranslator/validator/sam_schema/schema.json +++ b/samtranslator/validator/sam_schema/schema.json @@ -354,6 +354,24 @@ ], "type": "object" }, + "AWS::Serverless::Function.EventBridgeRule": { + "additionalProperties": false, + "properties": { + "Input": { + "type": "string" + }, + "InputPath": { + "type": "string" + }, + "Pattern": { + "type": "object" + } + }, + "required": [ + "Pattern" + ], + "type": "object" + }, "AWS::Serverless::Function.LogEvent": { "additionalProperties": false, "properties": { @@ -471,6 +489,9 @@ { "$ref": "#/definitions/AWS::Serverless::Function.CloudWatchEventEvent" }, + { + "$ref": "#/definitions/AWS::Serverless::Function.EventBridgeRule" + }, { "$ref": "#/definitions/AWS::Serverless::Function.LogEvent" }, diff --git a/tests/translator/input/eventbridgerule.yaml b/tests/translator/input/eventbridgerule.yaml new file mode 100644 index 000000000..e9006a464 --- /dev/null +++ b/tests/translator/input/eventbridgerule.yaml @@ -0,0 +1,27 @@ +Resources: + ScheduledFunction: + Type: 'AWS::Serverless::Function' + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO + Handler: hello.handler + Runtime: python2.7 + Events: + Schedule: + Type: Schedule + Properties: + Schedule: 'rate(1 minute)' + TriggeredFunction: + Type: 'AWS::Serverless::Function' + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip?versionId=3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO + Handler: hello.handler + Runtime: python2.7 + Events: + OnTerminate: + Type: EventBridgeRule + Properties: + EventBusName: ExternalEventBridge + Pattern: + detail: + state: + - terminated diff --git a/tests/translator/input/cloudwatchevent_schedule_properties.yaml b/tests/translator/input/eventbridgerule_schedule_properties.yaml similarity index 96% rename from tests/translator/input/cloudwatchevent_schedule_properties.yaml rename to tests/translator/input/eventbridgerule_schedule_properties.yaml index 72a612034..0c947dfc8 100644 --- a/tests/translator/input/cloudwatchevent_schedule_properties.yaml +++ b/tests/translator/input/eventbridgerule_schedule_properties.yaml @@ -22,7 +22,7 @@ Resources: Runtime: python2.7 Events: OnTerminate: - Type: CloudWatchEvent + Type: EventBridgeRule Properties: Pattern: detail: diff --git a/tests/translator/input/function_event_conditions.yaml b/tests/translator/input/function_event_conditions.yaml index 3dd9bad2a..98936ac78 100644 --- a/tests/translator/input/function_event_conditions.yaml +++ b/tests/translator/input/function_event_conditions.yaml @@ -33,7 +33,7 @@ Resources: AutoPublishAlias: Live Events: - CWSchedule: + EBSchedule: Type: Schedule Properties: Schedule: 'rate(1 minute)' @@ -46,6 +46,14 @@ Resources: state: - terminated + EBRule: + Type: EventBridgeRule + Properties: + Pattern: + detail: + state: + - launched + CWLog: Type: CloudWatchLogs Properties: diff --git a/tests/translator/input/function_with_alias_and_event_sources.yaml b/tests/translator/input/function_with_alias_and_event_sources.yaml index 0d436671c..41a6bc27c 100644 --- a/tests/translator/input/function_with_alias_and_event_sources.yaml +++ b/tests/translator/input/function_with_alias_and_event_sources.yaml @@ -16,7 +16,7 @@ Resources: AutoPublishAlias: Live Events: - CWSchedule: + EBSchedule: Type: Schedule Properties: Schedule: 'rate(1 minute)' @@ -29,6 +29,14 @@ Resources: state: - terminated + EBRule: + Type: EventBridgeRule + Properties: + Pattern: + detail: + state: + - launched + CWLog: Type: CloudWatchLogs Properties: diff --git a/tests/translator/output/aws-cn/eventbridgerule.json b/tests/translator/output/aws-cn/eventbridgerule.json new file mode 100644 index 000000000..a8c2feb5a --- /dev/null +++ b/tests/translator/output/aws-cn/eventbridgerule.json @@ -0,0 +1,185 @@ +{ + "Resources": { + "ScheduledFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "TriggeredFunctionOnTerminatePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "TriggeredFunction" + }, + "SourceArn": { + "Fn::GetAtt": [ + "TriggeredFunctionOnTerminate", + "Arn" + ] + } + } + }, + "ScheduledFunctionSchedulePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "ScheduledFunction" + }, + "SourceArn": { + "Fn::GetAtt": [ + "ScheduledFunctionSchedule", + "Arn" + ] + } + } + }, + "ScheduledFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "ScheduledFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "TriggeredFunctionOnTerminate": { + "Type": "AWS::Events::Rule", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "terminated" + ] + } + }, + "EventBusName": "ExternalEventBridge", + "Targets": [ + { + "Id": "TriggeredFunctionOnTerminateLambdaTarget", + "Arn": { + "Fn::GetAtt": [ + "TriggeredFunction", + "Arn" + ] + } + } + ] + } + }, + "TriggeredFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "TriggeredFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "TriggeredFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "ScheduledFunctionSchedule": { + "Type": "AWS::Events::Rule", + "Properties": { + "ScheduleExpression": "rate(1 minute)", + "Targets": [ + { + "Id": "ScheduledFunctionScheduleLambdaTarget", + "Arn": { + "Fn::GetAtt": [ + "ScheduledFunction", + "Arn" + ] + } + } + ] + } + } + } +} diff --git a/tests/translator/output/aws-cn/cloudwatchevent_schedule_properties.json b/tests/translator/output/aws-cn/eventbridgerule_schedule_properties.json similarity index 100% rename from tests/translator/output/aws-cn/cloudwatchevent_schedule_properties.json rename to tests/translator/output/aws-cn/eventbridgerule_schedule_properties.json diff --git a/tests/translator/output/aws-cn/function_event_conditions.json b/tests/translator/output/aws-cn/function_event_conditions.json index 62522bc66..bd96a2df1 100644 --- a/tests/translator/output/aws-cn/function_event_conditions.json +++ b/tests/translator/output/aws-cn/function_event_conditions.json @@ -54,7 +54,24 @@ ] } } - }, + }, + "MyAwesomeFunctionEBRulePermission": { + "Type": "AWS::Lambda::Permission", + "Condition": "MyCondition", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "MyAwesomeFunctionAliasLive" + }, + "SourceArn": { + "Fn::GetAtt": [ + "MyAwesomeFunctionEBRule", + "Arn" + ] + } + } + }, "MyAwesomeFunctionDDBStream": { "Type": "AWS::Lambda::EventSourceMapping", "Condition": "MyCondition", @@ -169,14 +186,14 @@ } } }, - "MyAwesomeFunctionCWSchedule": { + "MyAwesomeFunctionEBSchedule": { "Type": "AWS::Events::Rule", "Condition": "MyCondition", "Properties": { "ScheduleExpression": "rate(1 minute)", "Targets": [ { - "Id": "MyAwesomeFunctionCWScheduleLambdaTarget", + "Id": "MyAwesomeFunctionEBScheduleLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } @@ -275,7 +292,28 @@ } ] } - }, + }, + "MyAwesomeFunctionEBRule": { + "Type": "AWS::Events::Rule", + "Condition": "MyCondition", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "launched" + ] + } + }, + "Targets": [ + { + "Id": "MyAwesomeFunctionEBRuleLambdaTarget", + "Arn": { + "Ref": "MyAwesomeFunctionAliasLive" + } + } + ] + } + }, "MyAwesomeFunctionVersion640128d35d": { "DeletionPolicy": "Retain", "Type": "AWS::Lambda::Version", @@ -290,7 +328,7 @@ "Condition": "MyCondition", "Type": "AWS::SNS::Topic" }, - "MyAwesomeFunctionCWSchedulePermission": { + "MyAwesomeFunctionEBSchedulePermission": { "Type": "AWS::Lambda::Permission", "Condition": "MyCondition", "Properties": { @@ -301,7 +339,7 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWSchedule", + "MyAwesomeFunctionEBSchedule", "Arn" ] } diff --git a/tests/translator/output/aws-cn/function_with_alias_and_event_sources.json b/tests/translator/output/aws-cn/function_with_alias_and_event_sources.json index 0d29ad2ea..726cb9dab 100644 --- a/tests/translator/output/aws-cn/function_with_alias_and_event_sources.json +++ b/tests/translator/output/aws-cn/function_with_alias_and_event_sources.json @@ -71,7 +71,23 @@ ] } } - }, + }, + "MyAwesomeFunctionEBRulePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "MyAwesomeFunctionAliasLive" + }, + "SourceArn": { + "Fn::GetAtt": [ + "MyAwesomeFunctionEBRule", + "Arn" + ] + } + } + }, "MyAwesomeFunctionDDBStream": { "Type": "AWS::Lambda::EventSourceMapping", "Properties": { @@ -218,13 +234,13 @@ } } }, - "MyAwesomeFunctionCWSchedule": { + "MyAwesomeFunctionEBSchedule": { "Type": "AWS::Events::Rule", "Properties": { "ScheduleExpression": "rate(1 minute)", "Targets": [ { - "Id": "MyAwesomeFunctionCWScheduleLambdaTarget", + "Id": "MyAwesomeFunctionEBScheduleLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } @@ -319,7 +335,27 @@ } ] } - }, + }, + "MyAwesomeFunctionEBRule": { + "Type": "AWS::Events::Rule", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "launched" + ] + } + }, + "Targets": [ + { + "Id": "MyAwesomeFunctionEBRuleLambdaTarget", + "Arn": { + "Ref": "MyAwesomeFunctionAliasLive" + } + } + ] + } + }, "MyAwesomeFunctionVersion640128d35d": { "DeletionPolicy": "Retain", "Type": "AWS::Lambda::Version", @@ -368,7 +404,7 @@ "Notifications": { "Type": "AWS::SNS::Topic" }, - "MyAwesomeFunctionCWSchedulePermission": { + "MyAwesomeFunctionEBSchedulePermission": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -378,7 +414,7 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWSchedule", + "MyAwesomeFunctionEBSchedule", "Arn" ] } diff --git a/tests/translator/output/aws-us-gov/eventbridgerule.json b/tests/translator/output/aws-us-gov/eventbridgerule.json new file mode 100644 index 000000000..10e5b8285 --- /dev/null +++ b/tests/translator/output/aws-us-gov/eventbridgerule.json @@ -0,0 +1,185 @@ +{ + "Resources": { + "ScheduledFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "TriggeredFunctionOnTerminatePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "TriggeredFunction" + }, + "SourceArn": { + "Fn::GetAtt": [ + "TriggeredFunctionOnTerminate", + "Arn" + ] + } + } + }, + "ScheduledFunctionSchedulePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "ScheduledFunction" + }, + "SourceArn": { + "Fn::GetAtt": [ + "ScheduledFunctionSchedule", + "Arn" + ] + } + } + }, + "ScheduledFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "ScheduledFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "TriggeredFunctionOnTerminate": { + "Type": "AWS::Events::Rule", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "terminated" + ] + } + }, + "EventBusName": "ExternalEventBridge", + "Targets": [ + { + "Id": "TriggeredFunctionOnTerminateLambdaTarget", + "Arn": { + "Fn::GetAtt": [ + "TriggeredFunction", + "Arn" + ] + } + } + ] + } + }, + "TriggeredFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "TriggeredFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "TriggeredFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "ScheduledFunctionSchedule": { + "Type": "AWS::Events::Rule", + "Properties": { + "ScheduleExpression": "rate(1 minute)", + "Targets": [ + { + "Id": "ScheduledFunctionScheduleLambdaTarget", + "Arn": { + "Fn::GetAtt": [ + "ScheduledFunction", + "Arn" + ] + } + } + ] + } + } + } +} diff --git a/tests/translator/output/aws-us-gov/cloudwatchevent_schedule_properties.json b/tests/translator/output/aws-us-gov/eventbridgerule_schedule_properties.json similarity index 100% rename from tests/translator/output/aws-us-gov/cloudwatchevent_schedule_properties.json rename to tests/translator/output/aws-us-gov/eventbridgerule_schedule_properties.json diff --git a/tests/translator/output/aws-us-gov/function_event_conditions.json b/tests/translator/output/aws-us-gov/function_event_conditions.json index cb1b9e7e2..1cc8c8f41 100644 --- a/tests/translator/output/aws-us-gov/function_event_conditions.json +++ b/tests/translator/output/aws-us-gov/function_event_conditions.json @@ -54,7 +54,24 @@ ] } } - }, + }, + "MyAwesomeFunctionEBRulePermission": { + "Type": "AWS::Lambda::Permission", + "Condition": "MyCondition", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "MyAwesomeFunctionAliasLive" + }, + "SourceArn": { + "Fn::GetAtt": [ + "MyAwesomeFunctionEBRule", + "Arn" + ] + } + } + }, "MyAwesomeFunctionDDBStream": { "Type": "AWS::Lambda::EventSourceMapping", "Condition": "MyCondition", @@ -169,14 +186,14 @@ } } }, - "MyAwesomeFunctionCWSchedule": { + "MyAwesomeFunctionEBSchedule": { "Type": "AWS::Events::Rule", "Condition": "MyCondition", "Properties": { "ScheduleExpression": "rate(1 minute)", "Targets": [ { - "Id": "MyAwesomeFunctionCWScheduleLambdaTarget", + "Id": "MyAwesomeFunctionEBScheduleLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } @@ -275,7 +292,28 @@ } ] } - }, + }, + "MyAwesomeFunctionEBRule": { + "Type": "AWS::Events::Rule", + "Condition": "MyCondition", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "launched" + ] + } + }, + "Targets": [ + { + "Id": "MyAwesomeFunctionEBRuleLambdaTarget", + "Arn": { + "Ref": "MyAwesomeFunctionAliasLive" + } + } + ] + } + }, "MyAwesomeFunctionVersion640128d35d": { "DeletionPolicy": "Retain", "Type": "AWS::Lambda::Version", @@ -290,7 +328,7 @@ "Condition": "MyCondition", "Type": "AWS::SNS::Topic" }, - "MyAwesomeFunctionCWSchedulePermission": { + "MyAwesomeFunctionEBSchedulePermission": { "Type": "AWS::Lambda::Permission", "Condition": "MyCondition", "Properties": { @@ -301,7 +339,7 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWSchedule", + "MyAwesomeFunctionEBSchedule", "Arn" ] } diff --git a/tests/translator/output/aws-us-gov/function_with_alias_and_event_sources.json b/tests/translator/output/aws-us-gov/function_with_alias_and_event_sources.json index 307283967..e751c70b8 100644 --- a/tests/translator/output/aws-us-gov/function_with_alias_and_event_sources.json +++ b/tests/translator/output/aws-us-gov/function_with_alias_and_event_sources.json @@ -71,7 +71,23 @@ ] } } - }, + }, + "MyAwesomeFunctionEBRulePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "MyAwesomeFunctionAliasLive" + }, + "SourceArn": { + "Fn::GetAtt": [ + "MyAwesomeFunctionEBRule", + "Arn" + ] + } + } + }, "MyAwesomeFunctionDDBStream": { "Type": "AWS::Lambda::EventSourceMapping", "Properties": { @@ -228,13 +244,13 @@ } } }, - "MyAwesomeFunctionCWSchedule": { + "MyAwesomeFunctionEBSchedule": { "Type": "AWS::Events::Rule", "Properties": { "ScheduleExpression": "rate(1 minute)", "Targets": [ { - "Id": "MyAwesomeFunctionCWScheduleLambdaTarget", + "Id": "MyAwesomeFunctionEBScheduleLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } @@ -329,7 +345,27 @@ } ] } - }, + }, + "MyAwesomeFunctionEBRule": { + "Type": "AWS::Events::Rule", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "launched" + ] + } + }, + "Targets": [ + { + "Id": "MyAwesomeFunctionEBRuleLambdaTarget", + "Arn": { + "Ref": "MyAwesomeFunctionAliasLive" + } + } + ] + } + }, "MyAwesomeFunctionVersion640128d35d": { "DeletionPolicy": "Retain", "Type": "AWS::Lambda::Version", @@ -378,7 +414,7 @@ "Notifications": { "Type": "AWS::SNS::Topic" }, - "MyAwesomeFunctionCWSchedulePermission": { + "MyAwesomeFunctionEBSchedulePermission": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -388,7 +424,7 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWSchedule", + "MyAwesomeFunctionEBSchedule", "Arn" ] } diff --git a/tests/translator/output/eventbridgerule.json b/tests/translator/output/eventbridgerule.json new file mode 100644 index 000000000..f566b680b --- /dev/null +++ b/tests/translator/output/eventbridgerule.json @@ -0,0 +1,185 @@ +{ + "Resources": { + "ScheduledFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "TriggeredFunctionOnTerminatePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "TriggeredFunction" + }, + "SourceArn": { + "Fn::GetAtt": [ + "TriggeredFunctionOnTerminate", + "Arn" + ] + } + } + }, + "ScheduledFunctionSchedulePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "ScheduledFunction" + }, + "SourceArn": { + "Fn::GetAtt": [ + "ScheduledFunctionSchedule", + "Arn" + ] + } + } + }, + "ScheduledFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "ScheduledFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "TriggeredFunctionOnTerminate": { + "Type": "AWS::Events::Rule", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "terminated" + ] + } + }, + "EventBusName": "ExternalEventBridge", + "Targets": [ + { + "Id": "TriggeredFunctionOnTerminateLambdaTarget", + "Arn": { + "Fn::GetAtt": [ + "TriggeredFunction", + "Arn" + ] + } + } + ] + } + }, + "TriggeredFunction": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "hello.zip", + "S3ObjectVersion": "3Tcgv52_0GaDvhDva4YciYeqRyPnpIcO" + }, + "Handler": "hello.handler", + "Role": { + "Fn::GetAtt": [ + "TriggeredFunctionRole", + "Arn" + ] + }, + "Runtime": "python2.7", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ] + } + }, + "TriggeredFunctionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "ManagedPolicyArns": [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ], + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + } + ], + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "sts:AssumeRole" + ], + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + }, + "ScheduledFunctionSchedule": { + "Type": "AWS::Events::Rule", + "Properties": { + "ScheduleExpression": "rate(1 minute)", + "Targets": [ + { + "Id": "ScheduledFunctionScheduleLambdaTarget", + "Arn": { + "Fn::GetAtt": [ + "ScheduledFunction", + "Arn" + ] + } + } + ] + } + } + } +} diff --git a/tests/translator/output/cloudwatchevent_schedule_properties.json b/tests/translator/output/eventbridgerule_schedule_properties.json similarity index 100% rename from tests/translator/output/cloudwatchevent_schedule_properties.json rename to tests/translator/output/eventbridgerule_schedule_properties.json diff --git a/tests/translator/output/function_event_conditions.json b/tests/translator/output/function_event_conditions.json index 8de5fff08..747db4a44 100644 --- a/tests/translator/output/function_event_conditions.json +++ b/tests/translator/output/function_event_conditions.json @@ -49,12 +49,29 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWEvent", + "MyAwesomeFunctionCWEvent", "Arn" ] } } - }, + }, + "MyAwesomeFunctionEBRulePermission": { + "Type": "AWS::Lambda::Permission", + "Condition": "MyCondition", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "MyAwesomeFunctionAliasLive" + }, + "SourceArn": { + "Fn::GetAtt": [ + "MyAwesomeFunctionEBRule", + "Arn" + ] + } + } + }, "MyAwesomeFunctionDDBStream": { "Type": "AWS::Lambda::EventSourceMapping", "Condition": "MyCondition", @@ -169,14 +186,14 @@ } } }, - "MyAwesomeFunctionCWSchedule": { + "MyAwesomeFunctionEBSchedule": { "Type": "AWS::Events::Rule", "Condition": "MyCondition", "Properties": { "ScheduleExpression": "rate(1 minute)", "Targets": [ { - "Id": "MyAwesomeFunctionCWScheduleLambdaTarget", + "Id": "MyAwesomeFunctionEBScheduleLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } @@ -254,7 +271,7 @@ } ] } - }, + }, "MyAwesomeFunctionCWEvent": { "Type": "AWS::Events::Rule", "Condition": "MyCondition", @@ -268,14 +285,35 @@ }, "Targets": [ { - "Id": "MyAwesomeFunctionCWEventLambdaTarget", + "Id": "MyAwesomeFunctionCWEventLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } } ] } - }, + }, + "MyAwesomeFunctionEBRule": { + "Type": "AWS::Events::Rule", + "Condition": "MyCondition", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "launched" + ] + } + }, + "Targets": [ + { + "Id": "MyAwesomeFunctionEBRuleLambdaTarget", + "Arn": { + "Ref": "MyAwesomeFunctionAliasLive" + } + } + ] + } + }, "MyAwesomeFunctionVersion640128d35d": { "DeletionPolicy": "Retain", "Type": "AWS::Lambda::Version", @@ -289,8 +327,8 @@ "Notifications": { "Condition": "MyCondition", "Type": "AWS::SNS::Topic" - }, - "MyAwesomeFunctionCWSchedulePermission": { + }, + "MyAwesomeFunctionEBSchedulePermission": { "Type": "AWS::Lambda::Permission", "Condition": "MyCondition", "Properties": { @@ -301,7 +339,7 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWSchedule", + "MyAwesomeFunctionEBSchedule", "Arn" ] } diff --git a/tests/translator/output/function_with_alias_and_event_sources.json b/tests/translator/output/function_with_alias_and_event_sources.json index c5755d9a1..16130f8ed 100644 --- a/tests/translator/output/function_with_alias_and_event_sources.json +++ b/tests/translator/output/function_with_alias_and_event_sources.json @@ -71,7 +71,23 @@ ] } } - }, + }, + "MyAwesomeFunctionEBRulePermission": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "Action": "lambda:invokeFunction", + "Principal": "events.amazonaws.com", + "FunctionName": { + "Ref": "MyAwesomeFunctionAliasLive" + }, + "SourceArn": { + "Fn::GetAtt": [ + "MyAwesomeFunctionEBRule", + "Arn" + ] + } + } + }, "MyAwesomeFunctionDDBStream": { "Type": "AWS::Lambda::EventSourceMapping", "Properties": { @@ -220,13 +236,13 @@ } } }, - "MyAwesomeFunctionCWSchedule": { + "MyAwesomeFunctionEBSchedule": { "Type": "AWS::Events::Rule", "Properties": { "ScheduleExpression": "rate(1 minute)", "Targets": [ { - "Id": "MyAwesomeFunctionCWScheduleLambdaTarget", + "Id": "MyAwesomeFunctionEBScheduleLambdaTarget", "Arn": { "Ref": "MyAwesomeFunctionAliasLive" } @@ -321,7 +337,27 @@ } ] } - }, + }, + "MyAwesomeFunctionEBRule": { + "Type": "AWS::Events::Rule", + "Properties": { + "EventPattern": { + "detail": { + "state": [ + "launched" + ] + } + }, + "Targets": [ + { + "Id": "MyAwesomeFunctionEBRuleLambdaTarget", + "Arn": { + "Ref": "MyAwesomeFunctionAliasLive" + } + } + ] + } + }, "MyAwesomeFunctionVersion640128d35d": { "DeletionPolicy": "Retain", "Type": "AWS::Lambda::Version", @@ -362,7 +398,7 @@ "Notifications": { "Type": "AWS::SNS::Topic" }, - "MyAwesomeFunctionCWSchedulePermission": { + "MyAwesomeFunctionEBSchedulePermission": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:invokeFunction", @@ -372,7 +408,7 @@ }, "SourceArn": { "Fn::GetAtt": [ - "MyAwesomeFunctionCWSchedule", + "MyAwesomeFunctionEBSchedule", "Arn" ] } diff --git a/tests/translator/test_translator.py b/tests/translator/test_translator.py index c7aa5c025..29beb28bb 100644 --- a/tests/translator/test_translator.py +++ b/tests/translator/test_translator.py @@ -146,7 +146,8 @@ class TestTranslatorEndToEnd(TestCase): 'application_with_intrinsics', 'basic_layer', 'cloudwatchevent', - 'cloudwatchevent_schedule_properties', + 'eventbridgerule', + 'eventbridgerule_schedule_properties', 'cloudwatch_logs_with_ref', 'cloudwatchlog', 'streams', diff --git a/tests/translator/validator/test_validator.py b/tests/translator/validator/test_validator.py index baf9da873..e1fa43a6d 100644 --- a/tests/translator/validator/test_validator.py +++ b/tests/translator/validator/test_validator.py @@ -9,6 +9,7 @@ @pytest.mark.parametrize('testcase', [ 'cloudwatchevent', + 'eventbridgerule', 'cloudwatch_logs_with_ref', 'cloudwatchlog', 'streams', diff --git a/versions/2016-10-31.md b/versions/2016-10-31.md index 7300d922b..7c89abc39 100644 --- a/versions/2016-10-31.md +++ b/versions/2016-10-31.md @@ -417,6 +417,7 @@ Properties: - [Api](#api) - [Schedule](#schedule) - [CloudWatchEvent](#cloudwatchevent) + - [EventBridgeRule](#eventbridgerule) - [CloudWatchLogs](#cloudwatchlogs) - [IoTRule](#iotrule) - [AlexaSkill](#alexaskill) @@ -686,6 +687,8 @@ Properties: The object describing an event source with type `CloudWatchEvent`. +The CloudWatch Events service has been re-launched as Amazon EventBridge with full backwards compatibility. Please see the subsequent [EventBridgeRule](#eventbridgerule) section. + ##### Properties Property Name | Type | Description @@ -706,6 +709,29 @@ Properties: - terminated ``` +#### EventBridgeRule + +The object describing an event source with type `EventBridgeRule`. + +##### Properties + +Property Name | Type | Description +---|:---:|--- +Pattern | [Event Pattern Object](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html) | **Required.** Pattern describing which EventBridge events trigger the function. Only matching events trigger the function. +Input | `string` | JSON-formatted string to pass to the function as the event body. This value overrides the matched event. +InputPath | `string` | JSONPath describing the part of the event to pass to the function. + +##### Example: EventBridge event source object + +```yaml +Type: EventBridgeRule +Properties: + Pattern: + detail: + state: + - terminated +``` + #### CloudWatchLogs The object describing an event source with type `CloudWatchLogs`.