From 18c08b988d0ae39d07bfc3e653bddb2621db8276 Mon Sep 17 00:00:00 2001 From: Ruben Fonseca Date: Fri, 11 Feb 2022 08:03:20 +0100 Subject: [PATCH] fix(generator): updated resources that support update/creation policy --- .../appstream/aws-appstream-fleet.go | 20 +++++++++++++++++++ .../aws-elasticache-replicationgroup.go | 10 ++++++++++ .../elasticsearch/aws-elasticsearch-domain.go | 10 ++++++++++ .../aws-opensearchservice-domain.go | 10 ++++++++++ generate/generate.go | 5 +++++ 5 files changed, 55 insertions(+) diff --git a/cloudformation/appstream/aws-appstream-fleet.go b/cloudformation/appstream/aws-appstream-fleet.go index f51fad1490..b1a75edc3b 100644 --- a/cloudformation/appstream/aws-appstream-fleet.go +++ b/cloudformation/appstream/aws-appstream-fleet.go @@ -113,6 +113,12 @@ type Fleet struct { // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-fleet.html#cfn-appstream-fleet-vpcconfig VpcConfig *Fleet_VpcConfig `json:"VpcConfig,omitempty"` + // AWSCloudFormationUpdatePolicy represents a CloudFormation UpdatePolicy + AWSCloudFormationUpdatePolicy *policies.UpdatePolicy `json:"-"` + + // AWSCloudFormationCreationPolicy represents a CloudFormation CreationPolicy + AWSCloudFormationCreationPolicy *policies.CreationPolicy `json:"-"` + // AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"` @@ -146,6 +152,8 @@ func (r Fleet) MarshalJSON() ([]byte, error) { DeletionPolicy policies.DeletionPolicy `json:"DeletionPolicy,omitempty"` UpdateReplacePolicy policies.UpdateReplacePolicy `json:"UpdateReplacePolicy,omitempty"` Condition string `json:"Condition,omitempty"` + UpdatePolicy *policies.UpdatePolicy `json:"UpdatePolicy,omitempty"` + CreationPolicy *policies.CreationPolicy `json:"CreationPolicy,omitempty"` }{ Type: r.AWSCloudFormationType(), Properties: (Properties)(r), @@ -154,6 +162,8 @@ func (r Fleet) MarshalJSON() ([]byte, error) { DeletionPolicy: r.AWSCloudFormationDeletionPolicy, UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy, Condition: r.AWSCloudFormationCondition, + UpdatePolicy: r.AWSCloudFormationUpdatePolicy, + CreationPolicy: r.AWSCloudFormationCreationPolicy, }) } @@ -169,6 +179,8 @@ func (r *Fleet) UnmarshalJSON(b []byte) error { DeletionPolicy string UpdateReplacePolicy string Condition string + UpdatePolicy *policies.UpdatePolicy + CreationPolicy *policies.CreationPolicy }{} dec := json.NewDecoder(bytes.NewReader(b)) @@ -198,5 +210,13 @@ func (r *Fleet) UnmarshalJSON(b []byte) error { if res.Condition != "" { r.AWSCloudFormationCondition = res.Condition } + if res.UpdatePolicy != nil { + r.AWSCloudFormationUpdatePolicy = res.UpdatePolicy + } + + if res.CreationPolicy != nil { + r.AWSCloudFormationCreationPolicy = res.CreationPolicy + } + return nil } diff --git a/cloudformation/elasticache/aws-elasticache-replicationgroup.go b/cloudformation/elasticache/aws-elasticache-replicationgroup.go index 4004a1829c..6bf5f0093e 100644 --- a/cloudformation/elasticache/aws-elasticache-replicationgroup.go +++ b/cloudformation/elasticache/aws-elasticache-replicationgroup.go @@ -188,6 +188,9 @@ type ReplicationGroup struct { // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-replicationgroup.html#cfn-elasticache-replicationgroup-usergroupids UserGroupIds []string `json:"UserGroupIds,omitempty"` + // AWSCloudFormationUpdatePolicy represents a CloudFormation UpdatePolicy + AWSCloudFormationUpdatePolicy *policies.UpdatePolicy `json:"-"` + // AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"` @@ -221,6 +224,7 @@ func (r ReplicationGroup) MarshalJSON() ([]byte, error) { DeletionPolicy policies.DeletionPolicy `json:"DeletionPolicy,omitempty"` UpdateReplacePolicy policies.UpdateReplacePolicy `json:"UpdateReplacePolicy,omitempty"` Condition string `json:"Condition,omitempty"` + UpdatePolicy *policies.UpdatePolicy `json:"UpdatePolicy,omitempty"` }{ Type: r.AWSCloudFormationType(), Properties: (Properties)(r), @@ -229,6 +233,7 @@ func (r ReplicationGroup) MarshalJSON() ([]byte, error) { DeletionPolicy: r.AWSCloudFormationDeletionPolicy, UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy, Condition: r.AWSCloudFormationCondition, + UpdatePolicy: r.AWSCloudFormationUpdatePolicy, }) } @@ -244,6 +249,7 @@ func (r *ReplicationGroup) UnmarshalJSON(b []byte) error { DeletionPolicy string UpdateReplacePolicy string Condition string + UpdatePolicy *policies.UpdatePolicy }{} dec := json.NewDecoder(bytes.NewReader(b)) @@ -273,5 +279,9 @@ func (r *ReplicationGroup) UnmarshalJSON(b []byte) error { if res.Condition != "" { r.AWSCloudFormationCondition = res.Condition } + if res.UpdatePolicy != nil { + r.AWSCloudFormationUpdatePolicy = res.UpdatePolicy + } + return nil } diff --git a/cloudformation/elasticsearch/aws-elasticsearch-domain.go b/cloudformation/elasticsearch/aws-elasticsearch-domain.go index 55c3d67cd5..62def6af2c 100644 --- a/cloudformation/elasticsearch/aws-elasticsearch-domain.go +++ b/cloudformation/elasticsearch/aws-elasticsearch-domain.go @@ -88,6 +88,9 @@ type Domain struct { // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticsearch-domain.html#cfn-elasticsearch-domain-vpcoptions VPCOptions *Domain_VPCOptions `json:"VPCOptions,omitempty"` + // AWSCloudFormationUpdatePolicy represents a CloudFormation UpdatePolicy + AWSCloudFormationUpdatePolicy *policies.UpdatePolicy `json:"-"` + // AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"` @@ -121,6 +124,7 @@ func (r Domain) MarshalJSON() ([]byte, error) { DeletionPolicy policies.DeletionPolicy `json:"DeletionPolicy,omitempty"` UpdateReplacePolicy policies.UpdateReplacePolicy `json:"UpdateReplacePolicy,omitempty"` Condition string `json:"Condition,omitempty"` + UpdatePolicy *policies.UpdatePolicy `json:"UpdatePolicy,omitempty"` }{ Type: r.AWSCloudFormationType(), Properties: (Properties)(r), @@ -129,6 +133,7 @@ func (r Domain) MarshalJSON() ([]byte, error) { DeletionPolicy: r.AWSCloudFormationDeletionPolicy, UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy, Condition: r.AWSCloudFormationCondition, + UpdatePolicy: r.AWSCloudFormationUpdatePolicy, }) } @@ -144,6 +149,7 @@ func (r *Domain) UnmarshalJSON(b []byte) error { DeletionPolicy string UpdateReplacePolicy string Condition string + UpdatePolicy *policies.UpdatePolicy }{} dec := json.NewDecoder(bytes.NewReader(b)) @@ -173,5 +179,9 @@ func (r *Domain) UnmarshalJSON(b []byte) error { if res.Condition != "" { r.AWSCloudFormationCondition = res.Condition } + if res.UpdatePolicy != nil { + r.AWSCloudFormationUpdatePolicy = res.UpdatePolicy + } + return nil } diff --git a/cloudformation/opensearchservice/aws-opensearchservice-domain.go b/cloudformation/opensearchservice/aws-opensearchservice-domain.go index e27fc56573..2cfe61fb9c 100644 --- a/cloudformation/opensearchservice/aws-opensearchservice-domain.go +++ b/cloudformation/opensearchservice/aws-opensearchservice-domain.go @@ -88,6 +88,9 @@ type Domain struct { // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-opensearchservice-domain.html#cfn-opensearchservice-domain-vpcoptions VPCOptions *Domain_VPCOptions `json:"VPCOptions,omitempty"` + // AWSCloudFormationUpdatePolicy represents a CloudFormation UpdatePolicy + AWSCloudFormationUpdatePolicy *policies.UpdatePolicy `json:"-"` + // AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"` @@ -121,6 +124,7 @@ func (r Domain) MarshalJSON() ([]byte, error) { DeletionPolicy policies.DeletionPolicy `json:"DeletionPolicy,omitempty"` UpdateReplacePolicy policies.UpdateReplacePolicy `json:"UpdateReplacePolicy,omitempty"` Condition string `json:"Condition,omitempty"` + UpdatePolicy *policies.UpdatePolicy `json:"UpdatePolicy,omitempty"` }{ Type: r.AWSCloudFormationType(), Properties: (Properties)(r), @@ -129,6 +133,7 @@ func (r Domain) MarshalJSON() ([]byte, error) { DeletionPolicy: r.AWSCloudFormationDeletionPolicy, UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy, Condition: r.AWSCloudFormationCondition, + UpdatePolicy: r.AWSCloudFormationUpdatePolicy, }) } @@ -144,6 +149,7 @@ func (r *Domain) UnmarshalJSON(b []byte) error { DeletionPolicy string UpdateReplacePolicy string Condition string + UpdatePolicy *policies.UpdatePolicy }{} dec := json.NewDecoder(bytes.NewReader(b)) @@ -173,5 +179,9 @@ func (r *Domain) UnmarshalJSON(b []byte) error { if res.Condition != "" { r.AWSCloudFormationCondition = res.Condition } + if res.UpdatePolicy != nil { + r.AWSCloudFormationUpdatePolicy = res.UpdatePolicy + } + return nil } diff --git a/generate/generate.go b/generate/generate.go index 87fba9828d..31d59b8983 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -44,13 +44,18 @@ var ( // ResourcesThatSupportUpdatePolicies defines which CloudFormation resources support UpdatePolicies // see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html ResourcesThatSupportUpdatePolicies = []string{ + "AWS::AppStream::Fleet", "AWS::AutoScaling::AutoScalingGroup", + "AWS::ElastiCache::ReplicationGroup", + "AWS::OpenSearchService::Domain", + "AWS::Elasticsearch::Domain", "AWS::Lambda::Alias", } // ResourcesThatSupportCreationPolicies defines which CloudFormation resources support CreationPolicies // see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html ResourcesThatSupportCreationPolicies = []string{ + "AWS::AppStream::Fleet", "AWS::AutoScaling::AutoScalingGroup", "AWS::EC2::Instance", "AWS::CloudFormation::WaitCondition",