forked from awslabs/goformation
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema): adding AWS::Serverless::StateMachine and FileSystemConf…
…igs to Function (awslabs#284) * [Feature] add Serverless FileSystemConfigs * [Feature] adding step functions to SAM template * working specs
- Loading branch information
Graham Jenson
authored
Jul 26, 2020
1 parent
ad54601
commit d2d23ca
Showing
23 changed files
with
2,085 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
cloudformation/serverless/aws-serverless-function_filesystemconfig.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package serverless | ||
|
||
import ( | ||
"github.com/awslabs/goformation/v4/cloudformation/policies" | ||
) | ||
|
||
// Function_FileSystemConfig AWS CloudFormation Resource (AWS::Serverless::Function.FileSystemConfig) | ||
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html#cfn-lambda-function-filesystemconfig-localmountpath | ||
type Function_FileSystemConfig struct { | ||
|
||
// Arn AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html#cfn-lambda-function-filesystemconfig-localmountpath | ||
Arn string `json:"Arn,omitempty"` | ||
|
||
// LocalMountPath AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html#cfn-lambda-function-filesystemconfig-localmountpath | ||
LocalMountPath string `json:"LocalMountPath,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_FileSystemConfig) AWSCloudFormationType() string { | ||
return "AWS::Serverless::Function.FileSystemConfig" | ||
} |
151 changes: 151 additions & 0 deletions
151
cloudformation/serverless/aws-serverless-statemachine.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package serverless | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/awslabs/goformation/v4/cloudformation/policies" | ||
) | ||
|
||
// StateMachine AWS CloudFormation Resource (AWS::Serverless::StateMachine) | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
type StateMachine struct { | ||
|
||
// Definition AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Definition interface{} `json:"Definition,omitempty"` | ||
|
||
// DefinitionSubstitutions AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
DefinitionSubstitutions map[string]string `json:"DefinitionSubstitutions,omitempty"` | ||
|
||
// DefinitionUri AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
DefinitionUri *StateMachine_DefinitionUri `json:"DefinitionUri,omitempty"` | ||
|
||
// Events AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Events map[string]StateMachine_EventSource `json:"Events,omitempty"` | ||
|
||
// Logging AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Logging *StateMachine_LoggingConfiguration `json:"Logging,omitempty"` | ||
|
||
// Name AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Name string `json:"Name,omitempty"` | ||
|
||
// Policies AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Policies *StateMachine_Policies `json:"Policies,omitempty"` | ||
|
||
// Role AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Role string `json:"Role,omitempty"` | ||
|
||
// Tags AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Tags map[string]string `json:"Tags,omitempty"` | ||
|
||
// Type AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html | ||
Type string `json:"Type,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 *StateMachine) AWSCloudFormationType() string { | ||
return "AWS::Serverless::StateMachine" | ||
} | ||
|
||
// MarshalJSON is a custom JSON marshalling hook that embeds this object into | ||
// an AWS CloudFormation JSON resource's 'Properties' field and adds a 'Type'. | ||
func (r StateMachine) MarshalJSON() ([]byte, error) { | ||
type Properties StateMachine | ||
return json.Marshal(&struct { | ||
Type string | ||
Properties Properties | ||
DependsOn []string `json:"DependsOn,omitempty"` | ||
Metadata map[string]interface{} `json:"Metadata,omitempty"` | ||
DeletionPolicy policies.DeletionPolicy `json:"DeletionPolicy,omitempty"` | ||
UpdateReplacePolicy policies.UpdateReplacePolicy `json:"UpdateReplacePolicy,omitempty"` | ||
Condition string `json:"Condition,omitempty"` | ||
}{ | ||
Type: r.AWSCloudFormationType(), | ||
Properties: (Properties)(r), | ||
DependsOn: r.AWSCloudFormationDependsOn, | ||
Metadata: r.AWSCloudFormationMetadata, | ||
DeletionPolicy: r.AWSCloudFormationDeletionPolicy, | ||
UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy, | ||
Condition: r.AWSCloudFormationCondition, | ||
}) | ||
} | ||
|
||
// UnmarshalJSON is a custom JSON unmarshalling hook that strips the outer | ||
// AWS CloudFormation resource object, and just keeps the 'Properties' field. | ||
func (r *StateMachine) UnmarshalJSON(b []byte) error { | ||
type Properties StateMachine | ||
res := &struct { | ||
Type string | ||
Properties *Properties | ||
DependsOn []string | ||
Metadata map[string]interface{} | ||
DeletionPolicy string | ||
UpdateReplacePolicy string | ||
Condition string | ||
}{} | ||
|
||
dec := json.NewDecoder(bytes.NewReader(b)) | ||
dec.DisallowUnknownFields() // Force error if unknown field is found | ||
|
||
if err := dec.Decode(&res); err != nil { | ||
fmt.Printf("ERROR: %s\n", err) | ||
return err | ||
} | ||
|
||
// If the resource has no Properties set, it could be nil | ||
if res.Properties != nil { | ||
*r = StateMachine(*res.Properties) | ||
} | ||
if res.DependsOn != nil { | ||
r.AWSCloudFormationDependsOn = res.DependsOn | ||
} | ||
if res.Metadata != nil { | ||
r.AWSCloudFormationMetadata = res.Metadata | ||
} | ||
if res.DeletionPolicy != "" { | ||
r.AWSCloudFormationDeletionPolicy = policies.DeletionPolicy(res.DeletionPolicy) | ||
} | ||
if res.UpdateReplacePolicy != "" { | ||
r.AWSCloudFormationUpdateReplacePolicy = policies.UpdateReplacePolicy(res.UpdateReplacePolicy) | ||
} | ||
if res.Condition != "" { | ||
r.AWSCloudFormationCondition = res.Condition | ||
} | ||
return nil | ||
} |
45 changes: 45 additions & 0 deletions
45
cloudformation/serverless/aws-serverless-statemachine_apievent.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package serverless | ||
|
||
import ( | ||
"github.com/awslabs/goformation/v4/cloudformation/policies" | ||
) | ||
|
||
// StateMachine_ApiEvent AWS CloudFormation Resource (AWS::Serverless::StateMachine.ApiEvent) | ||
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api | ||
type StateMachine_ApiEvent struct { | ||
|
||
// Method AWS CloudFormation Property | ||
// Required: true | ||
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api | ||
Method string `json:"Method,omitempty"` | ||
|
||
// Path AWS CloudFormation Property | ||
// Required: true | ||
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api | ||
Path string `json:"Path,omitempty"` | ||
|
||
// RestApiId AWS CloudFormation Property | ||
// Required: false | ||
// See: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api | ||
RestApiId string `json:"RestApiId,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 *StateMachine_ApiEvent) AWSCloudFormationType() string { | ||
return "AWS::Serverless::StateMachine.ApiEvent" | ||
} |
50 changes: 50 additions & 0 deletions
50
cloudformation/serverless/aws-serverless-statemachine_cloudwatcheventevent.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package serverless | ||
|
||
import ( | ||
"github.com/awslabs/goformation/v4/cloudformation/policies" | ||
) | ||
|
||
// StateMachine_CloudWatchEventEvent AWS CloudFormation Resource (AWS::Serverless::StateMachine.CloudWatchEventEvent) | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-cloudwatchevent.html | ||
type StateMachine_CloudWatchEventEvent struct { | ||
|
||
// EventBusName AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-cloudwatchevent.html | ||
EventBusName string `json:"EventBusName,omitempty"` | ||
|
||
// Input AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-cloudwatchevent.html | ||
Input string `json:"Input,omitempty"` | ||
|
||
// InputPath AWS CloudFormation Property | ||
// Required: false | ||
// See: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-cloudwatchevent.html | ||
InputPath string `json:"InputPath,omitempty"` | ||
|
||
// Pattern AWS CloudFormation Property | ||
// Required: true | ||
// See: http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.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 *StateMachine_CloudWatchEventEvent) AWSCloudFormationType() string { | ||
return "AWS::Serverless::StateMachine.CloudWatchEventEvent" | ||
} |
35 changes: 35 additions & 0 deletions
35
cloudformation/serverless/aws-serverless-statemachine_cloudwatchlogsloggroup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package serverless | ||
|
||
import ( | ||
"github.com/awslabs/goformation/v4/cloudformation/policies" | ||
) | ||
|
||
// StateMachine_CloudWatchLogsLogGroup AWS CloudFormation Resource (AWS::Serverless::StateMachine.CloudWatchLogsLogGroup) | ||
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachine-logdestination-cloudwatchlogsloggroup.html | ||
type StateMachine_CloudWatchLogsLogGroup struct { | ||
|
||
// LogGroupArn AWS CloudFormation Property | ||
// Required: true | ||
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachine-logdestination-cloudwatchlogsloggroup.html | ||
LogGroupArn string `json:"LogGroupArn,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 *StateMachine_CloudWatchLogsLogGroup) AWSCloudFormationType() string { | ||
return "AWS::Serverless::StateMachine.CloudWatchLogsLogGroup" | ||
} |
Oops, something went wrong.