Skip to content

Commit

Permalink
fix(generator): updated resources that support update/creation policy
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfonseca committed Feb 11, 2022
1 parent 2236465 commit 18c08b9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cloudformation/appstream/aws-appstream-fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`

Expand Down Expand Up @@ -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),
Expand All @@ -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,
})
}

Expand All @@ -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))
Expand Down Expand Up @@ -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
}
10 changes: 10 additions & 0 deletions cloudformation/elasticache/aws-elasticache-replicationgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`

Expand Down Expand Up @@ -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),
Expand All @@ -229,6 +233,7 @@ func (r ReplicationGroup) MarshalJSON() ([]byte, error) {
DeletionPolicy: r.AWSCloudFormationDeletionPolicy,
UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy,
Condition: r.AWSCloudFormationCondition,
UpdatePolicy: r.AWSCloudFormationUpdatePolicy,
})
}

Expand All @@ -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))
Expand Down Expand Up @@ -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
}
10 changes: 10 additions & 0 deletions cloudformation/elasticsearch/aws-elasticsearch-domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`

Expand Down Expand Up @@ -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),
Expand All @@ -129,6 +133,7 @@ func (r Domain) MarshalJSON() ([]byte, error) {
DeletionPolicy: r.AWSCloudFormationDeletionPolicy,
UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy,
Condition: r.AWSCloudFormationCondition,
UpdatePolicy: r.AWSCloudFormationUpdatePolicy,
})
}

Expand All @@ -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))
Expand Down Expand Up @@ -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
}
10 changes: 10 additions & 0 deletions cloudformation/opensearchservice/aws-opensearchservice-domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`

Expand Down Expand Up @@ -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),
Expand All @@ -129,6 +133,7 @@ func (r Domain) MarshalJSON() ([]byte, error) {
DeletionPolicy: r.AWSCloudFormationDeletionPolicy,
UpdateReplacePolicy: r.AWSCloudFormationUpdateReplacePolicy,
Condition: r.AWSCloudFormationCondition,
UpdatePolicy: r.AWSCloudFormationUpdatePolicy,
})
}

Expand All @@ -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))
Expand Down Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 18c08b9

Please sign in to comment.