From 58dc56beb3a58acc391a5b3020f8cf3fabc19d6b Mon Sep 17 00:00:00 2001 From: Ruben Fonseca Date: Tue, 22 Feb 2022 12:24:09 +0100 Subject: [PATCH] fix(schema): re-generate schema --- .../aws-ec2-instance_privatednsnameoptions.go | 2 +- .../ecr/aws-ecr-pullthroughcacherule.go | 2 +- ...e_customdocumentenrichmentconfiguration.go | 2 +- ...a-datasource_documentattributecondition.go | 2 +- ...ndra-datasource_documentattributetarget.go | 2 +- ...endra-datasource_documentattributevalue.go | 2 +- ...aws-kendra-datasource_hookconfiguration.go | 2 +- ...necustomdocumentenrichmentconfiguration.go | 2 +- .../aws-lambda-eventsourcemapping_filter.go | 2 +- ...ambda-eventsourcemapping_filtercriteria.go | 2 +- cloudformation/serverless/api_cors.go | 12 ++++++- .../serverless/api_definitionuri.go | 12 ++++++- .../serverless/application_location.go | 12 ++++++- cloudformation/serverless/function_codeuri.go | 12 ++++++- cloudformation/serverless/function_events.go | 7 ++++ .../serverless/function_policies.go | 12 ++++++- .../serverless/function_properties.go | 25 +++++++------- .../serverless/httpapi_corsconfiguration.go | 12 ++++++- .../serverless/httpapi_definitionuri.go | 12 ++++++- .../serverless/layerversion_contenturi.go | 12 ++++++- .../serverless/statemachine_definitionuri.go | 12 ++++++- .../serverless/statemachine_policies.go | 12 ++++++- .../serverless/statemachine_properties.go | 33 +++++++++++++++---- .../wafv2/aws-wafv2-webacl_fieldidentifier.go | 2 +- ...aws-wafv2-webacl_managedrulegroupconfig.go | 2 +- .../templates/polymorphic-property.template | 13 +++++++- 26 files changed, 180 insertions(+), 42 deletions(-) diff --git a/cloudformation/ec2/aws-ec2-instance_privatednsnameoptions.go b/cloudformation/ec2/aws-ec2-instance_privatednsnameoptions.go index 7ac4ef24ff..bda0af21f2 100644 --- a/cloudformation/ec2/aws-ec2-instance_privatednsnameoptions.go +++ b/cloudformation/ec2/aws-ec2-instance_privatednsnameoptions.go @@ -1,7 +1,7 @@ package ec2 import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // Instance_PrivateDnsNameOptions AWS CloudFormation Resource (AWS::EC2::Instance.PrivateDnsNameOptions) diff --git a/cloudformation/ecr/aws-ecr-pullthroughcacherule.go b/cloudformation/ecr/aws-ecr-pullthroughcacherule.go index 8599aa2ea9..9216b3b7c7 100644 --- a/cloudformation/ecr/aws-ecr-pullthroughcacherule.go +++ b/cloudformation/ecr/aws-ecr-pullthroughcacherule.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // PullThroughCacheRule AWS CloudFormation Resource (AWS::ECR::PullThroughCacheRule) diff --git a/cloudformation/kendra/aws-kendra-datasource_customdocumentenrichmentconfiguration.go b/cloudformation/kendra/aws-kendra-datasource_customdocumentenrichmentconfiguration.go index b24a60eb46..03001c4340 100644 --- a/cloudformation/kendra/aws-kendra-datasource_customdocumentenrichmentconfiguration.go +++ b/cloudformation/kendra/aws-kendra-datasource_customdocumentenrichmentconfiguration.go @@ -1,7 +1,7 @@ package kendra import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // DataSource_CustomDocumentEnrichmentConfiguration AWS CloudFormation Resource (AWS::Kendra::DataSource.CustomDocumentEnrichmentConfiguration) diff --git a/cloudformation/kendra/aws-kendra-datasource_documentattributecondition.go b/cloudformation/kendra/aws-kendra-datasource_documentattributecondition.go index d46aa71c87..353516d2aa 100644 --- a/cloudformation/kendra/aws-kendra-datasource_documentattributecondition.go +++ b/cloudformation/kendra/aws-kendra-datasource_documentattributecondition.go @@ -1,7 +1,7 @@ package kendra import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // DataSource_DocumentAttributeCondition AWS CloudFormation Resource (AWS::Kendra::DataSource.DocumentAttributeCondition) diff --git a/cloudformation/kendra/aws-kendra-datasource_documentattributetarget.go b/cloudformation/kendra/aws-kendra-datasource_documentattributetarget.go index 976148d206..72426e2c2c 100644 --- a/cloudformation/kendra/aws-kendra-datasource_documentattributetarget.go +++ b/cloudformation/kendra/aws-kendra-datasource_documentattributetarget.go @@ -1,7 +1,7 @@ package kendra import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // DataSource_DocumentAttributeTarget AWS CloudFormation Resource (AWS::Kendra::DataSource.DocumentAttributeTarget) diff --git a/cloudformation/kendra/aws-kendra-datasource_documentattributevalue.go b/cloudformation/kendra/aws-kendra-datasource_documentattributevalue.go index b341eff341..d19a63df56 100644 --- a/cloudformation/kendra/aws-kendra-datasource_documentattributevalue.go +++ b/cloudformation/kendra/aws-kendra-datasource_documentattributevalue.go @@ -1,7 +1,7 @@ package kendra import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // DataSource_DocumentAttributeValue AWS CloudFormation Resource (AWS::Kendra::DataSource.DocumentAttributeValue) diff --git a/cloudformation/kendra/aws-kendra-datasource_hookconfiguration.go b/cloudformation/kendra/aws-kendra-datasource_hookconfiguration.go index cc6ee2f545..4bcb7c3fb9 100644 --- a/cloudformation/kendra/aws-kendra-datasource_hookconfiguration.go +++ b/cloudformation/kendra/aws-kendra-datasource_hookconfiguration.go @@ -1,7 +1,7 @@ package kendra import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // DataSource_HookConfiguration AWS CloudFormation Resource (AWS::Kendra::DataSource.HookConfiguration) diff --git a/cloudformation/kendra/aws-kendra-datasource_inlinecustomdocumentenrichmentconfiguration.go b/cloudformation/kendra/aws-kendra-datasource_inlinecustomdocumentenrichmentconfiguration.go index 0540391007..3e0347942b 100644 --- a/cloudformation/kendra/aws-kendra-datasource_inlinecustomdocumentenrichmentconfiguration.go +++ b/cloudformation/kendra/aws-kendra-datasource_inlinecustomdocumentenrichmentconfiguration.go @@ -1,7 +1,7 @@ package kendra import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // DataSource_InlineCustomDocumentEnrichmentConfiguration AWS CloudFormation Resource (AWS::Kendra::DataSource.InlineCustomDocumentEnrichmentConfiguration) diff --git a/cloudformation/lambda/aws-lambda-eventsourcemapping_filter.go b/cloudformation/lambda/aws-lambda-eventsourcemapping_filter.go index 982ea0cdab..d5484eefcb 100644 --- a/cloudformation/lambda/aws-lambda-eventsourcemapping_filter.go +++ b/cloudformation/lambda/aws-lambda-eventsourcemapping_filter.go @@ -1,7 +1,7 @@ package lambda import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // EventSourceMapping_Filter AWS CloudFormation Resource (AWS::Lambda::EventSourceMapping.Filter) diff --git a/cloudformation/lambda/aws-lambda-eventsourcemapping_filtercriteria.go b/cloudformation/lambda/aws-lambda-eventsourcemapping_filtercriteria.go index c3f113542b..833e6e7bf1 100644 --- a/cloudformation/lambda/aws-lambda-eventsourcemapping_filtercriteria.go +++ b/cloudformation/lambda/aws-lambda-eventsourcemapping_filtercriteria.go @@ -1,7 +1,7 @@ package lambda import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // EventSourceMapping_FilterCriteria AWS CloudFormation Resource (AWS::Lambda::EventSourceMapping.FilterCriteria) diff --git a/cloudformation/serverless/api_cors.go b/cloudformation/serverless/api_cors.go index 01d7864d6d..cd6f17041b 100644 --- a/cloudformation/serverless/api_cors.go +++ b/cloudformation/serverless/api_cors.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *Api_Cors) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.CorsConfiguration) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.CorsConfiguration); err != nil { + r.CorsConfiguration = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/api_definitionuri.go b/cloudformation/serverless/api_definitionuri.go index e187b6acda..64a4fa29fd 100644 --- a/cloudformation/serverless/api_definitionuri.go +++ b/cloudformation/serverless/api_definitionuri.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *Api_DefinitionUri) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.S3Location) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.S3Location); err != nil { + r.S3Location = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/application_location.go b/cloudformation/serverless/application_location.go index f688e0de2f..cf1548bc1c 100644 --- a/cloudformation/serverless/application_location.go +++ b/cloudformation/serverless/application_location.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *Application_Location) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.ApplicationLocation) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.ApplicationLocation); err != nil { + r.ApplicationLocation = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/function_codeuri.go b/cloudformation/serverless/function_codeuri.go index 66493c8c64..b1036dfd89 100644 --- a/cloudformation/serverless/function_codeuri.go +++ b/cloudformation/serverless/function_codeuri.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *Function_CodeUri) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.S3Location) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.S3Location); err != nil { + r.S3Location = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/function_events.go b/cloudformation/serverless/function_events.go index ea9c470247..017f44aad8 100644 --- a/cloudformation/serverless/function_events.go +++ b/cloudformation/serverless/function_events.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -57,6 +59,11 @@ func (r *Function_Events) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + case []interface{}: json.Unmarshal(b, &r.StringArray) diff --git a/cloudformation/serverless/function_policies.go b/cloudformation/serverless/function_policies.go index 4921383d00..93c8395609 100644 --- a/cloudformation/serverless/function_policies.go +++ b/cloudformation/serverless/function_policies.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -74,7 +76,15 @@ func (r *Function_Policies) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.IAMPolicyDocument) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.IAMPolicyDocument); err != nil { + r.IAMPolicyDocument = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/function_properties.go b/cloudformation/serverless/function_properties.go index 39c9473d9a..33b932bd31 100644 --- a/cloudformation/serverless/function_properties.go +++ b/cloudformation/serverless/function_properties.go @@ -79,7 +79,6 @@ func (r Function_Properties) value() interface{} { sort.Sort(utils.ByJSONLength(ret)) // Heuristic to select best attribute if len(ret) > 0 { return ret[0] - // log.Fatalf("FunctionProperties matched more than one property. This is a bug. %+v", r) } return nil @@ -106,65 +105,67 @@ func (r *Function_Properties) UnmarshalJSON(b []byte) error { reader := bytes.NewReader(b) decoder := json.NewDecoder(reader) decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) if err := decoder.Decode(&r.S3Event); err != nil { r.S3Event = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.SNSEvent); err != nil { r.SNSEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.SQSEvent); err != nil { r.SQSEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.KinesisEvent); err != nil { r.KinesisEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.DynamoDBEvent); err != nil { r.DynamoDBEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.ApiEvent); err != nil { r.ApiEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.ScheduleEvent); err != nil { r.ScheduleEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.CloudWatchEventEvent); err != nil { r.CloudWatchEventEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.CloudWatchLogsEvent); err != nil { r.CloudWatchLogsEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.IoTRuleEvent); err != nil { r.IoTRuleEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.AlexaSkillEvent); err != nil { r.AlexaSkillEvent = nil } - reader.Seek(0, io.SeekStart) + if err := decoder.Decode(&r.EventBridgeRuleEvent); err != nil { r.EventBridgeRuleEvent = nil } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/httpapi_corsconfiguration.go b/cloudformation/serverless/httpapi_corsconfiguration.go index 13cb9e1b5e..8c96fb9176 100644 --- a/cloudformation/serverless/httpapi_corsconfiguration.go +++ b/cloudformation/serverless/httpapi_corsconfiguration.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *HttpApi_CorsConfiguration) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.CorsConfigurationObject) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.CorsConfigurationObject); err != nil { + r.CorsConfigurationObject = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/httpapi_definitionuri.go b/cloudformation/serverless/httpapi_definitionuri.go index 0586fac876..6c3b21a2df 100644 --- a/cloudformation/serverless/httpapi_definitionuri.go +++ b/cloudformation/serverless/httpapi_definitionuri.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *HttpApi_DefinitionUri) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.S3Location) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.S3Location); err != nil { + r.S3Location = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/layerversion_contenturi.go b/cloudformation/serverless/layerversion_contenturi.go index 1ef81de853..40536f896e 100644 --- a/cloudformation/serverless/layerversion_contenturi.go +++ b/cloudformation/serverless/layerversion_contenturi.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *LayerVersion_ContentUri) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.S3Location) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.S3Location); err != nil { + r.S3Location = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/statemachine_definitionuri.go b/cloudformation/serverless/statemachine_definitionuri.go index 871362dbf9..4f9a135c6c 100644 --- a/cloudformation/serverless/statemachine_definitionuri.go +++ b/cloudformation/serverless/statemachine_definitionuri.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -54,7 +56,15 @@ func (r *StateMachine_DefinitionUri) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.S3Location) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.S3Location); err != nil { + r.S3Location = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/statemachine_policies.go b/cloudformation/serverless/statemachine_policies.go index f479b9b8ce..2ce6173e3e 100644 --- a/cloudformation/serverless/statemachine_policies.go +++ b/cloudformation/serverless/statemachine_policies.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -74,7 +76,15 @@ func (r *StateMachine_Policies) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.IAMPolicyDocument) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.IAMPolicyDocument); err != nil { + r.IAMPolicyDocument = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/serverless/statemachine_properties.go b/cloudformation/serverless/statemachine_properties.go index f58e7fcb29..8aa114be60 100644 --- a/cloudformation/serverless/statemachine_properties.go +++ b/cloudformation/serverless/statemachine_properties.go @@ -1,7 +1,9 @@ package serverless import ( + "bytes" "encoding/json" + "io" "sort" "github.com/awslabs/goformation/v6/cloudformation/utils" @@ -60,13 +62,30 @@ func (r *StateMachine_Properties) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error - json.Unmarshal(b, &r.CloudWatchEventEvent) - - json.Unmarshal(b, &r.EventBridgeRuleEvent) - - json.Unmarshal(b, &r.ScheduleEvent) - - json.Unmarshal(b, &r.ApiEvent) + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.CloudWatchEventEvent); err != nil { + r.CloudWatchEventEvent = nil + } + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.EventBridgeRuleEvent); err != nil { + r.EventBridgeRuleEvent = nil + } + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.ScheduleEvent); err != nil { + r.ScheduleEvent = nil + } + reader.Seek(0, io.SeekStart) + + if err := decoder.Decode(&r.ApiEvent); err != nil { + r.ApiEvent = nil + } + reader.Seek(0, io.SeekStart) case []interface{}: diff --git a/cloudformation/wafv2/aws-wafv2-webacl_fieldidentifier.go b/cloudformation/wafv2/aws-wafv2-webacl_fieldidentifier.go index a370a3ad0f..8179005b7c 100644 --- a/cloudformation/wafv2/aws-wafv2-webacl_fieldidentifier.go +++ b/cloudformation/wafv2/aws-wafv2-webacl_fieldidentifier.go @@ -1,7 +1,7 @@ package wafv2 import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // WebACL_FieldIdentifier AWS CloudFormation Resource (AWS::WAFv2::WebACL.FieldIdentifier) diff --git a/cloudformation/wafv2/aws-wafv2-webacl_managedrulegroupconfig.go b/cloudformation/wafv2/aws-wafv2-webacl_managedrulegroupconfig.go index 463ea3250f..734cab9bf5 100644 --- a/cloudformation/wafv2/aws-wafv2-webacl_managedrulegroupconfig.go +++ b/cloudformation/wafv2/aws-wafv2-webacl_managedrulegroupconfig.go @@ -1,7 +1,7 @@ package wafv2 import ( - "github.com/awslabs/goformation/v5/cloudformation/policies" + "github.com/awslabs/goformation/v6/cloudformation/policies" ) // WebACL_ManagedRuleGroupConfig AWS CloudFormation Resource (AWS::WAFv2::WebACL.ManagedRuleGroupConfig) diff --git a/generate/templates/polymorphic-property.template b/generate/templates/polymorphic-property.template index 369dade359..c6b6faae9e 100644 --- a/generate/templates/polymorphic-property.template +++ b/generate/templates/polymorphic-property.template @@ -1,8 +1,10 @@ package {{.PackageName}} import ( + "bytes" "sort" "encoding/json" + "io" "github.com/awslabs/goformation/v6/cloudformation/utils" ) @@ -86,8 +88,17 @@ func (r *{{.Name}}) UnmarshalJSON(b []byte) error { case map[string]interface{}: val = val // This ensures val is used to stop an error + + reader := bytes.NewReader(b) + decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() + reader.Seek(0, io.SeekStart) + {{range $type := $.Property.Types}} - json.Unmarshal(b, &r.{{$type}}) + if err := decoder.Decode(&r.{{$type}}); err != nil { + r.{{$type}} = nil + } + reader.Seek(0, io.SeekStart) {{end}} case []interface{}: