Skip to content

Commit

Permalink
fix(schema): AWS::Serverless::Function S3 notification filters (awsla…
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMaddox committed Nov 30, 2019
1 parent 387676f commit a50ef92
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 46,723 deletions.
29 changes: 29 additions & 0 deletions cloudformation/serverless/aws-serverless-function_s3keyfilter.go
@@ -0,0 +1,29 @@
package serverless

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

// Function_S3KeyFilter AWS CloudFormation Resource (AWS::Serverless::Function.S3KeyFilter)
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html
type Function_S3KeyFilter struct {

// Rules AWS CloudFormation Property
// Required: true
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html
Rules []Function_S3KeyFilterRule `json:"Rules,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `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:"-"`
}

// AWSCloudFormationType returns the AWS CloudFormation resource type
func (r *Function_S3KeyFilter) AWSCloudFormationType() string {
return "AWS::Serverless::Function.S3KeyFilter"
}
@@ -0,0 +1,34 @@
package serverless

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

// Function_S3KeyFilterRule AWS CloudFormation Resource (AWS::Serverless::Function.S3KeyFilterRule)
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter-s3key-rules.html
type Function_S3KeyFilterRule struct {

// Name AWS CloudFormation Property
// Required: true
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter-s3key-rules.html
Name string `json:"Name,omitempty"`

// Value AWS CloudFormation Property
// Required: true
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter-s3key-rules.html
Value string `json:"Value,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `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:"-"`
}

// AWSCloudFormationType returns the AWS CloudFormation resource type
func (r *Function_S3KeyFilterRule) AWSCloudFormationType() string {
return "AWS::Serverless::Function.S3KeyFilterRule"
}
Expand Up @@ -11,7 +11,7 @@ type Function_S3NotificationFilter struct {
// S3Key AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html
S3Key string `json:"S3Key,omitempty"`
S3Key *Function_S3KeyFilter `json:"S3Key,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
Expand Down
46,718 changes: 0 additions & 46,718 deletions generate/cfn-2019-10-26.json

This file was deleted.

31 changes: 30 additions & 1 deletion generate/sam-2016-10-31.json
Expand Up @@ -479,7 +479,7 @@
"S3Key": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html",
"Required": true,
"PrimitiveType": "String",
"Type": "S3KeyFilter",
"UpdateType": "Immutable"
}
}
Expand Down Expand Up @@ -1072,6 +1072,35 @@
}
}
},
"AWS::Serverless::Function.S3KeyFilter": {
"Documentation": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html",
"Properties": {
"Rules": {
"Documentation": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html",
"Required": true,
"Type": "List",
"ItemType": "S3KeyFilterRule",
"UpdateType": "Immutable"
}
}
},
"AWS::Serverless::Function.S3KeyFilterRule": {
"Documentation": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter-s3key-rules.html",
"Properties": {
"Name": {
"Documentation": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter-s3key-rules.html",
"Required": true,
"PrimitiveType": "String",
"UpdateType": "Immutable"
},
"Value": {
"Documentation": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter-s3key-rules.html",
"Required": true,
"PrimitiveType": "String",
"UpdateType": "Immutable"
}
}
},
"AWS::Serverless::Api.S3Location": {
"Documentation": "https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#s3-location-object",
"Properties": {
Expand Down
15 changes: 15 additions & 0 deletions goformation_test.go
Expand Up @@ -196,6 +196,21 @@ var _ = Describe("Goformation", func() {

})

It("should correctly parse all of the function S3 event source", func() {
Expect(f.Events).ToNot(BeNil())
Expect(f.Events).To(HaveKey("TestS3"))
Expect(f.Events["TestS3"].Type).To(Equal("S3"))
Expect(f.Events["TestS3"].Properties.S3Event).ToNot(BeNil())

event := f.Events["TestS3"].Properties.S3Event
Expect(event.Bucket).To(Equal("my-photo-bucket"))
Expect(event.Events.String).To(PointTo(Equal("s3:ObjectCreated:*")))
Expect(event.Filter.S3Key.Rules).To(HaveLen(1))
Expect(event.Filter.S3Key.Rules[0].Name).To(Equal("prefix|suffix"))
Expect(event.Filter.S3Key.Rules[0].Value).To(Equal("my-prefix|my-suffix"))

})

})

Context("with a JSON template that contains a resource with tags", func() {
Expand Down
33 changes: 32 additions & 1 deletion schema/sam.go
Expand Up @@ -52878,6 +52878,37 @@ var SamSchema = `{
],
"type": "object"
},
"AWS::Serverless::Function.S3KeyFilter": {
"additionalProperties": false,
"properties": {
"Rules": {
"items": {
"$ref": "#/definitions/AWS::Serverless::Function.S3KeyFilterRule"
},
"type": "array"
}
},
"required": [
"Rules"
],
"type": "object"
},
"AWS::Serverless::Function.S3KeyFilterRule": {
"additionalProperties": false,
"properties": {
"Name": {
"type": "string"
},
"Value": {
"type": "string"
}
},
"required": [
"Name",
"Value"
],
"type": "object"
},
"AWS::Serverless::Function.S3Location": {
"additionalProperties": false,
"properties": {
Expand All @@ -52901,7 +52932,7 @@ var SamSchema = `{
"additionalProperties": false,
"properties": {
"S3Key": {
"type": "string"
"$ref": "#/definitions/AWS::Serverless::Function.S3KeyFilter"
}
},
"required": [
Expand Down
33 changes: 32 additions & 1 deletion schema/sam.schema.json
Expand Up @@ -52875,6 +52875,37 @@
],
"type": "object"
},
"AWS::Serverless::Function.S3KeyFilter": {
"additionalProperties": false,
"properties": {
"Rules": {
"items": {
"$ref": "#/definitions/AWS::Serverless::Function.S3KeyFilterRule"
},
"type": "array"
}
},
"required": [
"Rules"
],
"type": "object"
},
"AWS::Serverless::Function.S3KeyFilterRule": {
"additionalProperties": false,
"properties": {
"Name": {
"type": "string"
},
"Value": {
"type": "string"
}
},
"required": [
"Name",
"Value"
],
"type": "object"
},
"AWS::Serverless::Function.S3Location": {
"additionalProperties": false,
"properties": {
Expand All @@ -52898,7 +52929,7 @@
"additionalProperties": false,
"properties": {
"S3Key": {
"type": "string"
"$ref": "#/definitions/AWS::Serverless::Function.S3KeyFilter"
}
},
"required": [
Expand Down
12 changes: 11 additions & 1 deletion test/yaml/aws-serverless-function-2016-10-31.yaml
Expand Up @@ -27,4 +27,14 @@ Resources:
Type: Api
Properties:
Path: /testing
Method: any
Method: any
TestS3:
Type: S3
Properties:
Bucket: my-photo-bucket # bucket must be created in the same template
Events: s3:ObjectCreated:*
Filter:
S3Key:
Rules:
- Name: prefix|suffix
Value: my-prefix|my-suffix

0 comments on commit a50ef92

Please sign in to comment.