Skip to content

Commit

Permalink
feat(schema): CloudFormation Updates (2019-12-09) (awslabs#251)
Browse files Browse the repository at this point in the history
Updated the following AWS CloudFormation resources:

 - AWS::ApiGatewayV2::Stage
 - AWS::ApiGatewayV2::Api
 - AWS::S3::AccessPoint
 - AWS::EventSchemas::Schema
 - AWS::GuardDuty::Filter
 - AWS::WAFv2::RuleGroup
 - AWS::StepFunctions::StateMachine
 - AWS::ApiGatewayV2::Integration
 - AWS::WAFv2::RegexPatternSet
 - AWS::EventSchemas::Registry
 - AWS::Lambda::Alias
 - AWS::EventSchemas::Discoverer
 - AWS::Lambda::Version
 - AWS::ApiGatewayV2::Authorizer
 - AWS::WAFv2::WebACL
 - AWS::AccessAnalyzer::Analyzer
 - AWS::WAFv2::IPSet
 - AWS::EventSchemas::Registry.TagsEntry
 - AWS::StepFunctions::StateMachine.LoggingConfiguration
 - AWS::WAFv2::RuleGroup.IPSetReferenceStatement
 - AWS::Lambda::Alias.ProvisionedConcurrencyConfiguration
 - AWS::FSx::FileSystem.WindowsConfiguration
 - AWS::WAFv2::WebACL.IPSetReferenceStatement
 - AWS::S3::AccessPoint.VpcConfiguration
 - AWS::AccessAnalyzer::Analyzer.Filter
 - AWS::S3::AccessPoint.PublicAccessBlockConfiguration
 - AWS::WAFv2::WebACL.RuleGroupReferenceStatement
 - AWS::WAFv2::RuleGroup.RegexPatternSetReferenceStatement
 - AWS::ApiGatewayV2::Api.Cors
 - AWS::EventSchemas::Schema.TagsEntry
 - AWS::ApiGatewayV2::Authorizer.JWTConfiguration
 - AWS::EventSchemas::Discoverer.TagsEntry
 - AWS::StepFunctions::StateMachine.LogDestination
 - AWS::Lambda::Version.ProvisionedConcurrencyConfiguration
 - AWS::StepFunctions::StateMachine.CloudWatchLogsLogGroup
 - AWS::AccessAnalyzer::Analyzer.ArchiveRule
 - AWS::ApiGatewayV2::Api.BodyS3Location
 - AWS::WAFv2::WebACL.RegexPatternSetReferenceStatement
  • Loading branch information
PaulMaddox authored Dec 9, 2019
1 parent e52b3b3 commit a23ba41
Show file tree
Hide file tree
Showing 43 changed files with 4,209 additions and 1,815 deletions.
104 changes: 104 additions & 0 deletions cloudformation/accessanalyzer/aws-accessanalyzer-analyzer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package accessanalyzer

import (
"bytes"
"encoding/json"
"fmt"

"github.com/awslabs/goformation/v4/cloudformation/policies"
"github.com/awslabs/goformation/v4/cloudformation/tags"
)

// Analyzer AWS CloudFormation Resource (AWS::AccessAnalyzer::Analyzer)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-accessanalyzer-analyzer.html
type Analyzer struct {

// AnalyzerName AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-accessanalyzer-analyzer.html#cfn-accessanalyzer-analyzer-analyzername
AnalyzerName string `json:"AnalyzerName,omitempty"`

// ArchiveRules AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-accessanalyzer-analyzer.html#cfn-accessanalyzer-analyzer-archiverules
ArchiveRules []Analyzer_ArchiveRule `json:"ArchiveRules,omitempty"`

// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-accessanalyzer-analyzer.html#cfn-accessanalyzer-analyzer-tags
Tags []tags.Tag `json:"Tags,omitempty"`

// Type AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-accessanalyzer-analyzer.html#cfn-accessanalyzer-analyzer-type
Type string `json:"Type,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 *Analyzer) AWSCloudFormationType() string {
return "AWS::AccessAnalyzer::Analyzer"
}

// 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 Analyzer) MarshalJSON() ([]byte, error) {
type Properties Analyzer
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"`
}{
Type: r.AWSCloudFormationType(),
Properties: (Properties)(r),
DependsOn: r.AWSCloudFormationDependsOn,
Metadata: r.AWSCloudFormationMetadata,
DeletionPolicy: r.AWSCloudFormationDeletionPolicy,
})
}

// UnmarshalJSON is a custom JSON unmarshalling hook that strips the outer
// AWS CloudFormation resource object, and just keeps the 'Properties' field.
func (r *Analyzer) UnmarshalJSON(b []byte) error {
type Properties Analyzer
res := &struct {
Type string
Properties *Properties
DependsOn []string
Metadata map[string]interface{}
DeletionPolicy 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 = Analyzer(*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)
}
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package accessanalyzer

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

// Analyzer_ArchiveRule AWS CloudFormation Resource (AWS::AccessAnalyzer::Analyzer.ArchiveRule)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-archiverule.html
type Analyzer_ArchiveRule struct {

// Filter AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-archiverule.html#cfn-accessanalyzer-analyzer-archiverule-filter
Filter []Analyzer_Filter `json:"Filter,omitempty"`

// RuleName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-archiverule.html#cfn-accessanalyzer-analyzer-archiverule-rulename
RuleName string `json:"RuleName,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 *Analyzer_ArchiveRule) AWSCloudFormationType() string {
return "AWS::AccessAnalyzer::Analyzer.ArchiveRule"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package accessanalyzer

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

// Analyzer_Filter AWS CloudFormation Resource (AWS::AccessAnalyzer::Analyzer.Filter)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-filter.html
type Analyzer_Filter struct {

// Contains AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-filter.html#cfn-accessanalyzer-analyzer-filter-contains
Contains []string `json:"Contains,omitempty"`

// Eq AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-filter.html#cfn-accessanalyzer-analyzer-filter-eq
Eq []string `json:"Eq,omitempty"`

// Exists AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-filter.html#cfn-accessanalyzer-analyzer-filter-exists
Exists bool `json:"Exists,omitempty"`

// Neq AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-filter.html#cfn-accessanalyzer-analyzer-filter-neq
Neq []string `json:"Neq,omitempty"`

// Property AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-accessanalyzer-analyzer-filter.html#cfn-accessanalyzer-analyzer-filter-property
Property string `json:"Property,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 *Analyzer_Filter) AWSCloudFormationType() string {
return "AWS::AccessAnalyzer::Analyzer.Filter"
}
127 changes: 127 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloudformation

import (
"fmt"
"github.com/awslabs/goformation/v4/cloudformation/accessanalyzer"
"github.com/awslabs/goformation/v4/cloudformation/amazonmq"
"github.com/awslabs/goformation/v4/cloudformation/amplify"
"github.com/awslabs/goformation/v4/cloudformation/apigateway"
Expand Down Expand Up @@ -50,6 +51,7 @@ import (
"github.com/awslabs/goformation/v4/cloudformation/elasticsearch"
"github.com/awslabs/goformation/v4/cloudformation/emr"
"github.com/awslabs/goformation/v4/cloudformation/events"
"github.com/awslabs/goformation/v4/cloudformation/eventschemas"
"github.com/awslabs/goformation/v4/cloudformation/fsx"
"github.com/awslabs/goformation/v4/cloudformation/gamelift"
"github.com/awslabs/goformation/v4/cloudformation/glue"
Expand Down Expand Up @@ -110,6 +112,7 @@ import (
// AllResources fetches an iterable map all CloudFormation and SAM resources
func AllResources() map[string]Resource {
return map[string]Resource{
"AWS::AccessAnalyzer::Analyzer": &accessanalyzer.Analyzer{},
"AWS::AmazonMQ::Broker": &amazonmq.Broker{},
"AWS::AmazonMQ::Configuration": &amazonmq.Configuration{},
"AWS::AmazonMQ::ConfigurationAssociation": &amazonmq.ConfigurationAssociation{},
Expand Down Expand Up @@ -334,6 +337,9 @@ func AllResources() map[string]Resource {
"AWS::ElasticLoadBalancingV2::LoadBalancer": &elasticloadbalancingv2.LoadBalancer{},
"AWS::ElasticLoadBalancingV2::TargetGroup": &elasticloadbalancingv2.TargetGroup{},
"AWS::Elasticsearch::Domain": &elasticsearch.Domain{},
"AWS::EventSchemas::Discoverer": &eventschemas.Discoverer{},
"AWS::EventSchemas::Registry": &eventschemas.Registry{},
"AWS::EventSchemas::Schema": &eventschemas.Schema{},
"AWS::Events::EventBus": &events.EventBus{},
"AWS::Events::EventBusPolicy": &events.EventBusPolicy{},
"AWS::Events::Rule": &events.Rule{},
Expand Down Expand Up @@ -510,6 +516,7 @@ func AllResources() map[string]Resource {
"AWS::Route53Resolver::ResolverEndpoint": &route53resolver.ResolverEndpoint{},
"AWS::Route53Resolver::ResolverRule": &route53resolver.ResolverRule{},
"AWS::Route53Resolver::ResolverRuleAssociation": &route53resolver.ResolverRuleAssociation{},
"AWS::S3::AccessPoint": &s3.AccessPoint{},
"AWS::S3::Bucket": &s3.Bucket{},
"AWS::S3::BucketPolicy": &s3.BucketPolicy{},
"AWS::SDB::Domain": &sdb.Domain{},
Expand Down Expand Up @@ -599,6 +606,30 @@ func AllResources() map[string]Resource {
}
}

// GetAllAccessAnalyzerAnalyzerResources retrieves all accessanalyzer.Analyzer items from an AWS CloudFormation template
func (t *Template) GetAllAccessAnalyzerAnalyzerResources() map[string]*accessanalyzer.Analyzer {
results := map[string]*accessanalyzer.Analyzer{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case *accessanalyzer.Analyzer:
results[name] = resource
}
}
return results
}

// GetAccessAnalyzerAnalyzerWithName retrieves all accessanalyzer.Analyzer items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetAccessAnalyzerAnalyzerWithName(name string) (*accessanalyzer.Analyzer, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case *accessanalyzer.Analyzer:
return resource, nil
}
}
return nil, fmt.Errorf("resource %q of type accessanalyzer.Analyzer not found", name)
}

// GetAllAmazonMQBrokerResources retrieves all amazonmq.Broker items from an AWS CloudFormation template
func (t *Template) GetAllAmazonMQBrokerResources() map[string]*amazonmq.Broker {
results := map[string]*amazonmq.Broker{}
Expand Down Expand Up @@ -5975,6 +6006,78 @@ func (t *Template) GetElasticsearchDomainWithName(name string) (*elasticsearch.D
return nil, fmt.Errorf("resource %q of type elasticsearch.Domain not found", name)
}

// GetAllEventSchemasDiscovererResources retrieves all eventschemas.Discoverer items from an AWS CloudFormation template
func (t *Template) GetAllEventSchemasDiscovererResources() map[string]*eventschemas.Discoverer {
results := map[string]*eventschemas.Discoverer{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case *eventschemas.Discoverer:
results[name] = resource
}
}
return results
}

// GetEventSchemasDiscovererWithName retrieves all eventschemas.Discoverer items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetEventSchemasDiscovererWithName(name string) (*eventschemas.Discoverer, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case *eventschemas.Discoverer:
return resource, nil
}
}
return nil, fmt.Errorf("resource %q of type eventschemas.Discoverer not found", name)
}

// GetAllEventSchemasRegistryResources retrieves all eventschemas.Registry items from an AWS CloudFormation template
func (t *Template) GetAllEventSchemasRegistryResources() map[string]*eventschemas.Registry {
results := map[string]*eventschemas.Registry{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case *eventschemas.Registry:
results[name] = resource
}
}
return results
}

// GetEventSchemasRegistryWithName retrieves all eventschemas.Registry items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetEventSchemasRegistryWithName(name string) (*eventschemas.Registry, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case *eventschemas.Registry:
return resource, nil
}
}
return nil, fmt.Errorf("resource %q of type eventschemas.Registry not found", name)
}

// GetAllEventSchemasSchemaResources retrieves all eventschemas.Schema items from an AWS CloudFormation template
func (t *Template) GetAllEventSchemasSchemaResources() map[string]*eventschemas.Schema {
results := map[string]*eventschemas.Schema{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case *eventschemas.Schema:
results[name] = resource
}
}
return results
}

// GetEventSchemasSchemaWithName retrieves all eventschemas.Schema items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetEventSchemasSchemaWithName(name string) (*eventschemas.Schema, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case *eventschemas.Schema:
return resource, nil
}
}
return nil, fmt.Errorf("resource %q of type eventschemas.Schema not found", name)
}

// GetAllEventsEventBusResources retrieves all events.EventBus items from an AWS CloudFormation template
func (t *Template) GetAllEventsEventBusResources() map[string]*events.EventBus {
results := map[string]*events.EventBus{}
Expand Down Expand Up @@ -10199,6 +10302,30 @@ func (t *Template) GetRoute53ResolverResolverRuleAssociationWithName(name string
return nil, fmt.Errorf("resource %q of type route53resolver.ResolverRuleAssociation not found", name)
}

// GetAllS3AccessPointResources retrieves all s3.AccessPoint items from an AWS CloudFormation template
func (t *Template) GetAllS3AccessPointResources() map[string]*s3.AccessPoint {
results := map[string]*s3.AccessPoint{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case *s3.AccessPoint:
results[name] = resource
}
}
return results
}

// GetS3AccessPointWithName retrieves all s3.AccessPoint items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetS3AccessPointWithName(name string) (*s3.AccessPoint, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case *s3.AccessPoint:
return resource, nil
}
}
return nil, fmt.Errorf("resource %q of type s3.AccessPoint not found", name)
}

// GetAllS3BucketResources retrieves all s3.Bucket items from an AWS CloudFormation template
func (t *Template) GetAllS3BucketResources() map[string]*s3.Bucket {
results := map[string]*s3.Bucket{}
Expand Down
Loading

0 comments on commit a23ba41

Please sign in to comment.