Skip to content

Commit

Permalink
feat(schema): Serverless eventbridgeruleevent (awslabs#279)
Browse files Browse the repository at this point in the history
* added EventBridgeRuleEvent

* EventBridgeRuleEvent doc link

* added EventBridgeRuleEvent

* trigger GitHub actions

Co-authored-by: Matteo Ridolfi <[email protected]>
  • Loading branch information
spezam and Matteo Ridolfi authored Jun 22, 2020
1 parent 7c906d9 commit 2a9e572
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 3 deletions.
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 @@ -447,7 +447,8 @@
"CloudWatchEventEvent",
"CloudWatchLogsEvent",
"IoTRuleEvent",
"AlexaSkillEvent"
"AlexaSkillEvent",
"EventBridgeRuleEvent"
],
"UpdateType": "Immutable"
}
Expand Down Expand Up @@ -692,6 +693,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 @@ -1263,4 +1293,4 @@
}
}
}
}
}

0 comments on commit 2a9e572

Please sign in to comment.