Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
fix(schema): CloudFormation Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMaddox committed Jul 17, 2021
1 parent a40b836 commit 3e6a28f
Show file tree
Hide file tree
Showing 17 changed files with 1,021 additions and 51 deletions.
25 changes: 25 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ func AllResources() map[string]Resource {
"AWS::Logs::LogStream": &logs.LogStream{},
"AWS::Logs::MetricFilter": &logs.MetricFilter{},
"AWS::Logs::QueryDefinition": &logs.QueryDefinition{},
"AWS::Logs::ResourcePolicy": &logs.ResourcePolicy{},
"AWS::Logs::SubscriptionFilter": &logs.SubscriptionFilter{},
"AWS::LookoutMetrics::Alert": &lookoutmetrics.Alert{},
"AWS::LookoutMetrics::AnomalyDetector": &lookoutmetrics.AnomalyDetector{},
Expand Down Expand Up @@ -13343,6 +13344,30 @@ func (t *Template) GetLogsQueryDefinitionWithName(name string) (*logs.QueryDefin
return nil, fmt.Errorf("resource %q of type logs.QueryDefinition not found", name)
}

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

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

// GetAllLogsSubscriptionFilterResources retrieves all logs.SubscriptionFilter items from an AWS CloudFormation template
func (t *Template) GetAllLogsSubscriptionFilterResources() map[string]*logs.SubscriptionFilter {
results := map[string]*logs.SubscriptionFilter{}
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/glue/aws-glue-crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ type Crawler struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-crawler.html#cfn-glue-crawler-name
Name string `json:"Name,omitempty"`

// RecrawlPolicy AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-crawler.html#cfn-glue-crawler-recrawlpolicy
RecrawlPolicy *Crawler_RecrawlPolicy `json:"RecrawlPolicy,omitempty"`

// Role AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-glue-crawler.html#cfn-glue-crawler-role
Expand Down
35 changes: 35 additions & 0 deletions cloudformation/glue/aws-glue-crawler_recrawlpolicy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package glue

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

// Crawler_RecrawlPolicy AWS CloudFormation Resource (AWS::Glue::Crawler.RecrawlPolicy)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-crawler-recrawlpolicy.html
type Crawler_RecrawlPolicy struct {

// RecrawlBehavior AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-crawler-recrawlpolicy.html#cfn-glue-crawler-recrawlpolicy-recrawlbehavior
RecrawlBehavior string `json:"RecrawlBehavior,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 *Crawler_RecrawlPolicy) AWSCloudFormationType() string {
return "AWS::Glue::Crawler.RecrawlPolicy"
}
5 changes: 5 additions & 0 deletions cloudformation/glue/aws-glue-database_databaseinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-database-databaseinput.html
type Database_DatabaseInput struct {

// CreateTableDefaultPermissions AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-database-databaseinput.html#cfn-glue-database-databaseinput-createtabledefaultpermissions
CreateTableDefaultPermissions []Database_PrincipalPrivileges `json:"CreateTableDefaultPermissions,omitempty"`

// Description AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-database-databaseinput.html#cfn-glue-database-databaseinput-description
Expand Down
10 changes: 5 additions & 5 deletions cloudformation/glue/aws-glue-partition_schemareference.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-partition-schemareference.html
type Partition_SchemaReference struct {

// SchameVersionId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-partition-schemareference.html#cfn-glue-partition-schemareference-schameversionid
SchameVersionId string `json:"SchameVersionId,omitempty"`

// SchemaId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-partition-schemareference.html#cfn-glue-partition-schemareference-schemaid
SchemaId *Partition_SchemaId `json:"SchemaId,omitempty"`

// SchemaVersionId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-partition-schemareference.html#cfn-glue-partition-schemareference-schemaversionid
SchemaVersionId string `json:"SchemaVersionId,omitempty"`

// SchemaVersionNumber AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-partition-schemareference.html#cfn-glue-partition-schemareference-schemaversionnumber
Expand Down
10 changes: 5 additions & 5 deletions cloudformation/glue/aws-glue-table_schemareference.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-table-schemareference.html
type Table_SchemaReference struct {

// SchameVersionId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-table-schemareference.html#cfn-glue-table-schemareference-schameversionid
SchameVersionId string `json:"SchameVersionId,omitempty"`

// SchemaId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-table-schemareference.html#cfn-glue-table-schemareference-schemaid
SchemaId *Table_SchemaId `json:"SchemaId,omitempty"`

// SchemaVersionId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-table-schemareference.html#cfn-glue-table-schemareference-schemaversionid
SchemaVersionId string `json:"SchemaVersionId,omitempty"`

// SchemaVersionNumber AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-glue-table-schemareference.html#cfn-glue-table-schemareference-schemaversionnumber
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/imagebuilder/aws-imagebuilder-imagerecipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html
type ImageRecipe struct {

// AdditionalInstanceConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html#cfn-imagebuilder-imagerecipe-additionalinstanceconfiguration
AdditionalInstanceConfiguration interface{} `json:"AdditionalInstanceConfiguration,omitempty"`

// BlockDeviceMappings AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-imagebuilder-imagerecipe.html#cfn-imagebuilder-imagerecipe-blockdevicemappings
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package imagebuilder

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

// ImageRecipe_AdditionalInstanceConfiguration AWS CloudFormation Resource (AWS::ImageBuilder::ImageRecipe.AdditionalInstanceConfiguration)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-additionalinstanceconfiguration.html
type ImageRecipe_AdditionalInstanceConfiguration struct {

// SystemsManagerAgent AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-additionalinstanceconfiguration.html#cfn-imagebuilder-imagerecipe-additionalinstanceconfiguration-systemsmanageragent
SystemsManagerAgent *ImageRecipe_SystemsManagerAgent `json:"SystemsManagerAgent,omitempty"`

// UserDataOverride AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-additionalinstanceconfiguration.html#cfn-imagebuilder-imagerecipe-additionalinstanceconfiguration-userdataoverride
UserDataOverride string `json:"UserDataOverride,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 *ImageRecipe_AdditionalInstanceConfiguration) AWSCloudFormationType() string {
return "AWS::ImageBuilder::ImageRecipe.AdditionalInstanceConfiguration"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ type ImageRecipe_ComponentConfiguration struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-componentconfiguration.html#cfn-imagebuilder-imagerecipe-componentconfiguration-componentarn
ComponentArn string `json:"ComponentArn,omitempty"`

// Parameters AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-componentconfiguration.html#cfn-imagebuilder-imagerecipe-componentconfiguration-parameters
Parameters []ImageRecipe_ComponentParameter `json:"Parameters,omitempty"`

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package imagebuilder

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

// ImageRecipe_ComponentParameter AWS CloudFormation Resource (AWS::ImageBuilder::ImageRecipe.ComponentParameter)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-componentparameter.html
type ImageRecipe_ComponentParameter struct {

// Name AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-componentparameter.html#cfn-imagebuilder-imagerecipe-componentparameter-name
Name string `json:"Name,omitempty"`

// Value AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-componentparameter.html#cfn-imagebuilder-imagerecipe-componentparameter-value
Value []string `json:"Value,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 *ImageRecipe_ComponentParameter) AWSCloudFormationType() string {
return "AWS::ImageBuilder::ImageRecipe.ComponentParameter"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package imagebuilder

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

// ImageRecipe_SystemsManagerAgent AWS CloudFormation Resource (AWS::ImageBuilder::ImageRecipe.SystemsManagerAgent)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-systemsmanageragent.html
type ImageRecipe_SystemsManagerAgent struct {

// UninstallAfterBuild AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-imagebuilder-imagerecipe-systemsmanageragent.html#cfn-imagebuilder-imagerecipe-systemsmanageragent-uninstallafterbuild
UninstallAfterBuild bool `json:"UninstallAfterBuild"`

// 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 *ImageRecipe_SystemsManagerAgent) AWSCloudFormationType() string {
return "AWS::ImageBuilder::ImageRecipe.SystemsManagerAgent"
}
111 changes: 111 additions & 0 deletions cloudformation/logs/aws-logs-resourcepolicy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package logs

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

"github.com/awslabs/goformation/v5/cloudformation/policies"
)

// ResourcePolicy AWS CloudFormation Resource (AWS::Logs::ResourcePolicy)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-resourcepolicy.html
type ResourcePolicy struct {

// PolicyDocument AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-resourcepolicy.html#cfn-logs-resourcepolicy-policydocument
PolicyDocument string `json:"PolicyDocument,omitempty"`

// PolicyName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-resourcepolicy.html#cfn-logs-resourcepolicy-policyname
PolicyName string `json:"PolicyName,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 *ResourcePolicy) AWSCloudFormationType() string {
return "AWS::Logs::ResourcePolicy"
}

// 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 ResourcePolicy) MarshalJSON() ([]byte, error) {
type Properties ResourcePolicy
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 *ResourcePolicy) UnmarshalJSON(b []byte) error {
type Properties ResourcePolicy
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 = ResourcePolicy(*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
}
Loading

0 comments on commit 3e6a28f

Please sign in to comment.