Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Serverless eventbridgeruleevent #279

Merged
merged 4 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package serverless

import (
"github.com/awslabs/goformation/v4/cloudformation/policies"
)

// Function_EventBridgeRuleEvent AWS CloudFormation Resource (AWS::Serverless::Function.EventBridgeRuleEvent)
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule
type Function_EventBridgeRuleEvent struct {

// EventBusName AWS CloudFormation Property
// Required: false
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule
EventBusName string `json:"EventBusName,omitempty"`

// Input AWS CloudFormation Property
// Required: false
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule
Input string `json:"Input,omitempty"`

// InputPath AWS CloudFormation Property
// Required: false
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule
InputPath string `json:"InputPath,omitempty"`

// Pattern AWS CloudFormation Property
// Required: true
// See: https://docs.aws.amazon.com/eventbridge/latest/userguide/filtering-examples-structure.html
Pattern interface{} `json:"Pattern,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

// AWSCloudFormationUpdateReplacePolicy represents a CloudFormation UpdateReplacePolicy
AWSCloudFormationUpdateReplacePolicy policies.UpdateReplacePolicy `json:"-"`

// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
AWSCloudFormationDependsOn []string `json:"-"`

// AWSCloudFormationMetadata stores structured data associated with this resource
AWSCloudFormationMetadata map[string]interface{} `json:"-"`

// AWSCloudFormationCondition stores the logical ID of the condition that must be satisfied for this resource to be created
AWSCloudFormationCondition string `json:"-"`
}

// AWSCloudFormationType returns the AWS CloudFormation resource type
func (r *Function_EventBridgeRuleEvent) AWSCloudFormationType() string {
return "AWS::Serverless::Function.EventBridgeRuleEvent"
}
9 changes: 8 additions & 1 deletion cloudformation/serverless/function_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/awslabs/goformation/v4/cloudformation/utils"
)

// Function_Properties is a helper struct that can hold either a S3Event, SNSEvent, SQSEvent, KinesisEvent, DynamoDBEvent, ApiEvent, ScheduleEvent, CloudWatchEventEvent, CloudWatchLogsEvent, IoTRuleEvent, or AlexaSkillEvent value
// Function_Properties is a helper struct that can hold either a S3Event, SNSEvent, SQSEvent, KinesisEvent, DynamoDBEvent, ApiEvent, ScheduleEvent, CloudWatchEventEvent, CloudWatchLogsEvent, IoTRuleEvent, AlexaSkillEvent, or EventBridgeRuleEvent value
type Function_Properties struct {
S3Event *Function_S3Event
SNSEvent *Function_SNSEvent
Expand All @@ -20,6 +20,7 @@ type Function_Properties struct {
CloudWatchLogsEvent *Function_CloudWatchLogsEvent
IoTRuleEvent *Function_IoTRuleEvent
AlexaSkillEvent *Function_AlexaSkillEvent
EventBridgeRuleEvent *Function_EventBridgeRuleEvent
}

func (r Function_Properties) value() interface{} {
Expand Down Expand Up @@ -69,6 +70,10 @@ func (r Function_Properties) value() interface{} {
ret = append(ret, *r.AlexaSkillEvent)
}

if r.EventBridgeRuleEvent != nil {
ret = append(ret, *r.EventBridgeRuleEvent)
}

sort.Sort(utils.ByJSONLength(ret)) // Heuristic to select best attribute
if len(ret) > 0 {
return ret[0]
Expand Down Expand Up @@ -117,6 +122,8 @@ func (r *Function_Properties) UnmarshalJSON(b []byte) error {

json.Unmarshal(b, &r.AlexaSkillEvent)

json.Unmarshal(b, &r.EventBridgeRuleEvent)

case []interface{}:

}
Expand Down
34 changes: 32 additions & 2 deletions generate/sam-2016-10-31.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@
"CloudWatchEventEvent",
"CloudWatchLogsEvent",
"IoTRuleEvent",
"AlexaSkillEvent"
"AlexaSkillEvent",
"EventBridgeRuleEvent"
],
"UpdateType": "Immutable"
}
Expand Down Expand Up @@ -686,6 +687,35 @@
}
}
},
"AWS::Serverless::Function.EventBridgeRuleEvent": {
"Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule",
"Properties": {
"Pattern": {
"Documentation": "https://docs.aws.amazon.com/eventbridge/latest/userguide/filtering-examples-structure.html",
"Required": true,
"PrimitiveType": "Json",
"UpdateType": "Immutable"
},
"EventBusName": {
"Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule",
"Required": false,
"PrimitiveType": "String",
"UpdateType": "Immutable"
},
"Input": {
"Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule",
"Required": false,
"PrimitiveType": "String",
"UpdateType": "Immutable"
},
"InputPath": {
"Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#eventbridgerule",
"Required": false,
"PrimitiveType": "String",
"UpdateType": "Immutable"
}
}
},
"AWS::Serverless::Function.VpcConfig": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html",
"Properties": {
Expand Down Expand Up @@ -1257,4 +1287,4 @@
}
}
}
}
}