Skip to content

Commit

Permalink
fix(schema): CloudFormation Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfonseca committed Feb 11, 2022
1 parent f99a97c commit bbbbbed
Show file tree
Hide file tree
Showing 31 changed files with 3,417 additions and 71 deletions.
100 changes: 100 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func AllResources() map[string]Resource {
"AWS::AppMesh::VirtualRouter": &appmesh.VirtualRouter{},
"AWS::AppMesh::VirtualService": &appmesh.VirtualService{},
"AWS::AppRunner::Service": &apprunner.Service{},
"AWS::AppRunner::VpcConnector": &apprunner.VpcConnector{},
"AWS::AppStream::AppBlock": &appstream.AppBlock{},
"AWS::AppStream::Application": &appstream.Application{},
"AWS::AppStream::ApplicationEntitlementAssociation": &appstream.ApplicationEntitlementAssociation{},
Expand Down Expand Up @@ -319,6 +320,9 @@ func AllResources() map[string]Resource {
"AWS::Chatbot::SlackChannelConfiguration": &chatbot.SlackChannelConfiguration{},
"AWS::Cloud9::EnvironmentEC2": &cloud9.EnvironmentEC2{},
"AWS::CloudFormation::CustomResource": &cloudformation.CustomResource{},
"AWS::CloudFormation::HookDefaultVersion": &cloudformation.HookDefaultVersion{},
"AWS::CloudFormation::HookTypeConfig": &cloudformation.HookTypeConfig{},
"AWS::CloudFormation::HookVersion": &cloudformation.HookVersion{},
"AWS::CloudFormation::Macro": &cloudformation.Macro{},
"AWS::CloudFormation::ModuleDefaultVersion": &cloudformation.ModuleDefaultVersion{},
"AWS::CloudFormation::ModuleVersion": &cloudformation.ModuleVersion{},
Expand Down Expand Up @@ -2649,6 +2653,30 @@ func (t *Template) GetAppRunnerServiceWithName(name string) (*apprunner.Service,
return nil, fmt.Errorf("resource %q of type apprunner.Service not found", name)
}

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

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

// GetAllAppStreamAppBlockResources retrieves all appstream.AppBlock items from an AWS CloudFormation template
func (t *Template) GetAllAppStreamAppBlockResources() map[string]*appstream.AppBlock {
results := map[string]*appstream.AppBlock{}
Expand Down Expand Up @@ -4065,6 +4093,78 @@ func (t *Template) GetCloudFormationCustomResourceWithName(name string) (*cloudf
return nil, fmt.Errorf("resource %q of type cloudformation.CustomResource not found", name)
}

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

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

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

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

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

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

// GetAllCloudFormationMacroResources retrieves all cloudformation.Macro items from an AWS CloudFormation template
func (t *Template) GetAllCloudFormationMacroResources() map[string]*cloudformation.Macro {
results := map[string]*cloudformation.Macro{}
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/apprunner/aws-apprunner-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ type Service struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-service.html#cfn-apprunner-service-instanceconfiguration
InstanceConfiguration *Service_InstanceConfiguration `json:"InstanceConfiguration,omitempty"`

// NetworkConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-service.html#cfn-apprunner-service-networkconfiguration
NetworkConfiguration *Service_NetworkConfiguration `json:"NetworkConfiguration,omitempty"`

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

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

// Service_EgressConfiguration AWS CloudFormation Resource (AWS::AppRunner::Service.EgressConfiguration)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-egressconfiguration.html
type Service_EgressConfiguration struct {

// EgressType AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-egressconfiguration.html#cfn-apprunner-service-egressconfiguration-egresstype
EgressType string `json:"EgressType,omitempty"`

// VpcConnectorArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-egressconfiguration.html#cfn-apprunner-service-egressconfiguration-vpcconnectorarn
VpcConnectorArn string `json:"VpcConnectorArn,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 *Service_EgressConfiguration) AWSCloudFormationType() string {
return "AWS::AppRunner::Service.EgressConfiguration"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package apprunner

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

// Service_NetworkConfiguration AWS CloudFormation Resource (AWS::AppRunner::Service.NetworkConfiguration)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-networkconfiguration.html
type Service_NetworkConfiguration struct {

// EgressConfiguration AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-networkconfiguration.html#cfn-apprunner-service-networkconfiguration-egressconfiguration
EgressConfiguration *Service_EgressConfiguration `json:"EgressConfiguration,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 *Service_NetworkConfiguration) AWSCloudFormationType() string {
return "AWS::AppRunner::Service.NetworkConfiguration"
}
122 changes: 122 additions & 0 deletions cloudformation/apprunner/aws-apprunner-vpcconnector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package apprunner

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

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

// VpcConnector AWS CloudFormation Resource (AWS::AppRunner::VpcConnector)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-vpcconnector.html
type VpcConnector struct {

// SecurityGroups AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-vpcconnector.html#cfn-apprunner-vpcconnector-securitygroups
SecurityGroups []string `json:"SecurityGroups,omitempty"`

// Subnets AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-vpcconnector.html#cfn-apprunner-vpcconnector-subnets
Subnets []string `json:"Subnets,omitempty"`

// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-vpcconnector.html#cfn-apprunner-vpcconnector-tags
Tags []tags.Tag `json:"Tags,omitempty"`

// VpcConnectorName AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-vpcconnector.html#cfn-apprunner-vpcconnector-vpcconnectorname
VpcConnectorName string `json:"VpcConnectorName,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 *VpcConnector) AWSCloudFormationType() string {
return "AWS::AppRunner::VpcConnector"
}

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

Please sign in to comment.