Skip to content

Commit

Permalink
fix(schema): CloudFormation Updates (awslabs#331)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Maddox <[email protected]>
  • Loading branch information
github-actions[bot] and PaulMaddox authored Nov 6, 2020
1 parent 5ee9a28 commit 12f9c83
Show file tree
Hide file tree
Showing 20 changed files with 2,543 additions and 10 deletions.
100 changes: 100 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func AllResources() map[string]Resource {
"AWS::CloudWatch::CompositeAlarm": &cloudwatch.CompositeAlarm{},
"AWS::CloudWatch::Dashboard": &cloudwatch.Dashboard{},
"AWS::CloudWatch::InsightRule": &cloudwatch.InsightRule{},
"AWS::CloudWatch::MetricStream": &cloudwatch.MetricStream{},
"AWS::CodeArtifact::Domain": &codeartifact.Domain{},
"AWS::CodeArtifact::Repository": &codeartifact.Repository{},
"AWS::CodeBuild::Project": &codebuild.Project{},
Expand Down Expand Up @@ -411,6 +412,7 @@ func AllResources() map[string]Resource {
"AWS::EventSchemas::Registry": &eventschemas.Registry{},
"AWS::EventSchemas::RegistryPolicy": &eventschemas.RegistryPolicy{},
"AWS::EventSchemas::Schema": &eventschemas.Schema{},
"AWS::Events::Archive": &events.Archive{},
"AWS::Events::EventBus": &events.EventBus{},
"AWS::Events::EventBusPolicy": &events.EventBusPolicy{},
"AWS::Events::Rule": &events.Rule{},
Expand Down Expand Up @@ -489,6 +491,7 @@ func AllResources() map[string]Resource {
"AWS::IoT1Click::Project": &iot1click.Project{},
"AWS::IoT::Authorizer": &iot.Authorizer{},
"AWS::IoT::Certificate": &iot.Certificate{},
"AWS::IoT::DomainConfiguration": &iot.DomainConfiguration{},
"AWS::IoT::Policy": &iot.Policy{},
"AWS::IoT::PolicyPrincipalAttachment": &iot.PolicyPrincipalAttachment{},
"AWS::IoT::ProvisioningTemplate": &iot.ProvisioningTemplate{},
Expand Down Expand Up @@ -609,6 +612,7 @@ func AllResources() map[string]Resource {
"AWS::RDS::DBSecurityGroupIngress": &rds.DBSecurityGroupIngress{},
"AWS::RDS::DBSubnetGroup": &rds.DBSubnetGroup{},
"AWS::RDS::EventSubscription": &rds.EventSubscription{},
"AWS::RDS::GlobalCluster": &rds.GlobalCluster{},
"AWS::RDS::OptionGroup": &rds.OptionGroup{},
"AWS::Redshift::Cluster": &redshift.Cluster{},
"AWS::Redshift::ClusterParameterGroup": &redshift.ClusterParameterGroup{},
Expand Down Expand Up @@ -3466,6 +3470,30 @@ func (t *Template) GetCloudWatchInsightRuleWithName(name string) (*cloudwatch.In
return nil, fmt.Errorf("resource %q of type cloudwatch.InsightRule not found", name)
}

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

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

// GetAllCodeArtifactDomainResources retrieves all codeartifact.Domain items from an AWS CloudFormation template
func (t *Template) GetAllCodeArtifactDomainResources() map[string]*codeartifact.Domain {
results := map[string]*codeartifact.Domain{}
Expand Down Expand Up @@ -7306,6 +7334,30 @@ func (t *Template) GetEventSchemasSchemaWithName(name string) (*eventschemas.Sch
return nil, fmt.Errorf("resource %q of type eventschemas.Schema not found", name)
}

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

// GetEventsArchiveWithName retrieves all events.Archive items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetEventsArchiveWithName(name string) (*events.Archive, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case *events.Archive:
return resource, nil
}
}
return nil, fmt.Errorf("resource %q of type events.Archive 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 @@ -9178,6 +9230,30 @@ func (t *Template) GetIoTCertificateWithName(name string) (*iot.Certificate, err
return nil, fmt.Errorf("resource %q of type iot.Certificate not found", name)
}

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

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

// GetAllIoTPolicyResources retrieves all iot.Policy items from an AWS CloudFormation template
func (t *Template) GetAllIoTPolicyResources() map[string]*iot.Policy {
results := map[string]*iot.Policy{}
Expand Down Expand Up @@ -12058,6 +12134,30 @@ func (t *Template) GetRDSEventSubscriptionWithName(name string) (*rds.EventSubsc
return nil, fmt.Errorf("resource %q of type rds.EventSubscription not found", name)
}

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

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

// GetAllRDSOptionGroupResources retrieves all rds.OptionGroup items from an AWS CloudFormation template
func (t *Template) GetAllRDSOptionGroupResources() map[string]*rds.OptionGroup {
results := map[string]*rds.OptionGroup{}
Expand Down
50 changes: 50 additions & 0 deletions cloudformation/batch/aws-batch-jobdefinition_evaluateonexit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package batch

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

// JobDefinition_EvaluateOnExit AWS CloudFormation Resource (AWS::Batch::JobDefinition.EvaluateOnExit)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-evaluateonexit.html
type JobDefinition_EvaluateOnExit struct {

// Action AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-evaluateonexit.html#cfn-batch-jobdefinition-evaluateonexit-action
Action string `json:"Action,omitempty"`

// OnExitCode AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-evaluateonexit.html#cfn-batch-jobdefinition-evaluateonexit-onexitcode
OnExitCode string `json:"OnExitCode,omitempty"`

// OnReason AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-evaluateonexit.html#cfn-batch-jobdefinition-evaluateonexit-onreason
OnReason string `json:"OnReason,omitempty"`

// OnStatusReason AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-evaluateonexit.html#cfn-batch-jobdefinition-evaluateonexit-onstatusreason
OnStatusReason string `json:"OnStatusReason,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 *JobDefinition_EvaluateOnExit) AWSCloudFormationType() string {
return "AWS::Batch::JobDefinition.EvaluateOnExit"
}
5 changes: 5 additions & 0 deletions cloudformation/batch/aws-batch-jobdefinition_retrystrategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ type JobDefinition_RetryStrategy struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-retrystrategy.html#cfn-batch-jobdefinition-retrystrategy-attempts
Attempts int `json:"Attempts,omitempty"`

// EvaluateOnExit AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-jobdefinition-retrystrategy.html#cfn-batch-jobdefinition-retrystrategy-evaluateonexit
EvaluateOnExit []JobDefinition_EvaluateOnExit `json:"EvaluateOnExit,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

Expand Down
132 changes: 132 additions & 0 deletions cloudformation/cloudwatch/aws-cloudwatch-metricstream.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package cloudwatch

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

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

// MetricStream AWS CloudFormation Resource (AWS::CloudWatch::MetricStream)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html
type MetricStream struct {

// ExcludeFilters AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-excludefilters
ExcludeFilters []MetricStream_MetricStreamFilter `json:"ExcludeFilters,omitempty"`

// FirehoseArn AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-firehosearn
FirehoseArn string `json:"FirehoseArn,omitempty"`

// IncludeFilters AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-includefilters
IncludeFilters []MetricStream_MetricStreamFilter `json:"IncludeFilters,omitempty"`

// Name AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-name
Name string `json:"Name,omitempty"`

// RoleArn AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-rolearn
RoleArn string `json:"RoleArn,omitempty"`

// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudwatch-metricstream.html#cfn-cloudwatch-metricstream-tags
Tags []tags.Tag `json:"Tags,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 *MetricStream) AWSCloudFormationType() string {
return "AWS::CloudWatch::MetricStream"
}

// 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 MetricStream) MarshalJSON() ([]byte, error) {
type Properties MetricStream
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 *MetricStream) UnmarshalJSON(b []byte) error {
type Properties MetricStream
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 = MetricStream(*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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package cloudwatch

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

// MetricStream_MetricStreamFilter AWS CloudFormation Resource (AWS::CloudWatch::MetricStream.MetricStreamFilter)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-metricstream-metricstreamfilter.html
type MetricStream_MetricStreamFilter struct {

// Namespace AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudwatch-metricstream-metricstreamfilter.html#cfn-cloudwatch-metricstream-metricstreamfilter-namespace
Namespace string `json:"Namespace,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 *MetricStream_MetricStreamFilter) AWSCloudFormationType() string {
return "AWS::CloudWatch::MetricStream.MetricStreamFilter"
}
Loading

0 comments on commit 12f9c83

Please sign in to comment.