Skip to content

Commit

Permalink
fix(schema): AWS::CDK::Metadata resource should be automatically gene…
Browse files Browse the repository at this point in the history
…rated (awslabs#421)

* fix(schema): AWS::CDK::Metadata should be generated

In PR awslabs#418, the AWS::CDK::Metadata was kindly added, however the
resource was manually created, which lead to it being overwritten when
`go generate` was run to update the goformation schema from
CloudFormation/SAM specifications.

This change adds a new `generate/cdk.json` file that contains a manually
crafted version of the AWS::CDK::* specification (as I don't think an
automatically published one exists), and automatically generates the
`cdk/aws-cdk-metadata.go` resource from it.

One side effect of this is that the `AWS::CDK::Metadata` resource is no
longer in the main `cloudformation.schema.json` that some IDEs use for
autocompletion/intellisense, and it now lives in an autogenerated
`schema/cdk.schema.json` file (similar to how SAM is separate, as it's
generated from a separate resource definition file).

* Separate commit for generated CDK files

* Separate commit for all other CloudFormation updates
  • Loading branch information
PaulMaddox authored Jan 18, 2022
1 parent 14866bd commit 65569f7
Show file tree
Hide file tree
Showing 90 changed files with 269,574 additions and 2,731 deletions.
360 changes: 356 additions & 4 deletions cloudformation/all.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package appstream

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

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

// ApplicationEntitlementAssociation AWS CloudFormation Resource (AWS::AppStream::ApplicationEntitlementAssociation)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-applicationentitlementassociation.html
type ApplicationEntitlementAssociation struct {

// ApplicationIdentifier AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-applicationentitlementassociation.html#cfn-appstream-applicationentitlementassociation-applicationidentifier
ApplicationIdentifier string `json:"ApplicationIdentifier,omitempty"`

// EntitlementName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-applicationentitlementassociation.html#cfn-appstream-applicationentitlementassociation-entitlementname
EntitlementName string `json:"EntitlementName,omitempty"`

// StackName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-applicationentitlementassociation.html#cfn-appstream-applicationentitlementassociation-stackname
StackName string `json:"StackName,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 *ApplicationEntitlementAssociation) AWSCloudFormationType() string {
return "AWS::AppStream::ApplicationEntitlementAssociation"
}

// 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 ApplicationEntitlementAssociation) MarshalJSON() ([]byte, error) {
type Properties ApplicationEntitlementAssociation
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 *ApplicationEntitlementAssociation) UnmarshalJSON(b []byte) error {
type Properties ApplicationEntitlementAssociation
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 = ApplicationEntitlementAssociation(*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
}
126 changes: 126 additions & 0 deletions cloudformation/appstream/aws-appstream-entitlement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package appstream

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

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

// Entitlement AWS CloudFormation Resource (AWS::AppStream::Entitlement)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-entitlement.html
type Entitlement struct {

// AppVisibility AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-entitlement.html#cfn-appstream-entitlement-appvisibility
AppVisibility string `json:"AppVisibility,omitempty"`

// Attributes AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-entitlement.html#cfn-appstream-entitlement-attributes
Attributes []Entitlement_Attribute `json:"Attributes,omitempty"`

// Description AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-entitlement.html#cfn-appstream-entitlement-description
Description string `json:"Description,omitempty"`

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

// StackName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appstream-entitlement.html#cfn-appstream-entitlement-stackname
StackName string `json:"StackName,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 *Entitlement) AWSCloudFormationType() string {
return "AWS::AppStream::Entitlement"
}

// 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 Entitlement) MarshalJSON() ([]byte, error) {
type Properties Entitlement
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 *Entitlement) UnmarshalJSON(b []byte) error {
type Properties Entitlement
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 = Entitlement(*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
}
40 changes: 40 additions & 0 deletions cloudformation/appstream/aws-appstream-entitlement_attribute.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package appstream

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

// Entitlement_Attribute AWS CloudFormation Resource (AWS::AppStream::Entitlement.Attribute)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appstream-entitlement-attribute.html
type Entitlement_Attribute struct {

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

// Value AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appstream-entitlement-attribute.html#cfn-appstream-entitlement-attribute-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 *Entitlement_Attribute) AWSCloudFormationType() string {
return "AWS::AppStream::Entitlement.Attribute"
}
5 changes: 5 additions & 0 deletions cloudformation/appsync/aws-appsync-functionconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ type FunctionConfiguration struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-functionversion
FunctionVersion string `json:"FunctionVersion,omitempty"`

// MaxBatchSize AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-maxbatchsize
MaxBatchSize int `json:"MaxBatchSize,omitempty"`

// Name AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-functionconfiguration.html#cfn-appsync-functionconfiguration-name
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/appsync/aws-appsync-resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ type Resolver struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-kind
Kind string `json:"Kind,omitempty"`

// MaxBatchSize AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-maxbatchsize
MaxBatchSize int `json:"MaxBatchSize,omitempty"`

// PipelineConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-pipelineconfig
Expand Down
4 changes: 2 additions & 2 deletions cloudformation/appsync/aws-appsync-resolver_cachingconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ type Resolver_CachingConfig struct {
CachingKeys []string `json:"CachingKeys,omitempty"`

// Ttl AWS CloudFormation Property
// Required: false
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-cachingconfig.html#cfn-appsync-resolver-cachingconfig-ttl
Ttl float64 `json:"Ttl,omitempty"`
Ttl float64 `json:"Ttl"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/autoscaling/aws-autoscaling-warmpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type WarmPool struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-warmpool.html#cfn-autoscaling-warmpool-autoscalinggroupname
AutoScalingGroupName string `json:"AutoScalingGroupName,omitempty"`

// InstanceReusePolicy AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-warmpool.html#cfn-autoscaling-warmpool-instancereusepolicy
InstanceReusePolicy *WarmPool_InstanceReusePolicy `json:"InstanceReusePolicy,omitempty"`

// MaxGroupPreparedCapacity AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-warmpool.html#cfn-autoscaling-warmpool-maxgrouppreparedcapacity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package autoscaling

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

// WarmPool_InstanceReusePolicy AWS CloudFormation Resource (AWS::AutoScaling::WarmPool.InstanceReusePolicy)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-warmpool-instancereusepolicy.html
type WarmPool_InstanceReusePolicy struct {

// ReuseOnScaleIn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-warmpool-instancereusepolicy.html#cfn-autoscaling-warmpool-instancereusepolicy-reuseonscalein
ReuseOnScaleIn bool `json:"ReuseOnScaleIn,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 *WarmPool_InstanceReusePolicy) AWSCloudFormationType() string {
return "AWS::AutoScaling::WarmPool.InstanceReusePolicy"
}
Loading

0 comments on commit 65569f7

Please sign in to comment.