Skip to content

Commit

Permalink
fix(schema): CloudFormation Updates (awslabs#372)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Maddox <paul.maddox@gmail.com>
  • Loading branch information
github-actions[bot] and PaulMaddox committed May 21, 2021
1 parent 796f930 commit 95c8bf5
Show file tree
Hide file tree
Showing 28 changed files with 3,059 additions and 0 deletions.
77 changes: 77 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/awslabs/goformation/v4/cloudformation/applicationautoscaling"
"github.com/awslabs/goformation/v4/cloudformation/applicationinsights"
"github.com/awslabs/goformation/v4/cloudformation/appmesh"
"github.com/awslabs/goformation/v4/cloudformation/apprunner"
"github.com/awslabs/goformation/v4/cloudformation/appstream"
"github.com/awslabs/goformation/v4/cloudformation/appsync"
"github.com/awslabs/goformation/v4/cloudformation/ask"
Expand Down Expand Up @@ -89,6 +90,7 @@ import (
"github.com/awslabs/goformation/v4/cloudformation/iot"
"github.com/awslabs/goformation/v4/cloudformation/iot1click"
"github.com/awslabs/goformation/v4/cloudformation/iotanalytics"
"github.com/awslabs/goformation/v4/cloudformation/iotcoredeviceadvisor"
"github.com/awslabs/goformation/v4/cloudformation/iotevents"
"github.com/awslabs/goformation/v4/cloudformation/iotfleethub"
"github.com/awslabs/goformation/v4/cloudformation/iotsitewise"
Expand Down Expand Up @@ -224,6 +226,7 @@ func AllResources() map[string]Resource {
"AWS::AppMesh::VirtualNode": &appmesh.VirtualNode{},
"AWS::AppMesh::VirtualRouter": &appmesh.VirtualRouter{},
"AWS::AppMesh::VirtualService": &appmesh.VirtualService{},
"AWS::AppRunner::Service": &apprunner.Service{},
"AWS::AppStream::DirectoryConfig": &appstream.DirectoryConfig{},
"AWS::AppStream::Fleet": &appstream.Fleet{},
"AWS::AppStream::ImageBuilder": &appstream.ImageBuilder{},
Expand Down Expand Up @@ -425,6 +428,7 @@ func AllResources() map[string]Resource {
"AWS::EC2::TransitGatewayMulticastDomainAssociation": &ec2.TransitGatewayMulticastDomainAssociation{},
"AWS::EC2::TransitGatewayMulticastGroupMember": &ec2.TransitGatewayMulticastGroupMember{},
"AWS::EC2::TransitGatewayMulticastGroupSource": &ec2.TransitGatewayMulticastGroupSource{},
"AWS::EC2::TransitGatewayPeeringAttachment": &ec2.TransitGatewayPeeringAttachment{},
"AWS::EC2::TransitGatewayRoute": &ec2.TransitGatewayRoute{},
"AWS::EC2::TransitGatewayRouteTable": &ec2.TransitGatewayRouteTable{},
"AWS::EC2::TransitGatewayRouteTableAssociation": &ec2.TransitGatewayRouteTableAssociation{},
Expand Down Expand Up @@ -615,6 +619,7 @@ func AllResources() map[string]Resource {
"AWS::IoTAnalytics::Dataset": &iotanalytics.Dataset{},
"AWS::IoTAnalytics::Datastore": &iotanalytics.Datastore{},
"AWS::IoTAnalytics::Pipeline": &iotanalytics.Pipeline{},
"AWS::IoTCoreDeviceAdvisor::SuiteDefinition": &iotcoredeviceadvisor.SuiteDefinition{},
"AWS::IoTEvents::DetectorModel": &iotevents.DetectorModel{},
"AWS::IoTEvents::Input": &iotevents.Input{},
"AWS::IoTFleetHub::Application": &iotfleethub.Application{},
Expand Down Expand Up @@ -2324,6 +2329,30 @@ func (t *Template) GetAppMeshVirtualServiceWithName(name string) (*appmesh.Virtu
return nil, fmt.Errorf("resource %q of type appmesh.VirtualService not found", name)
}

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

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

// GetAllAppStreamDirectoryConfigResources retrieves all appstream.DirectoryConfig items from an AWS CloudFormation template
func (t *Template) GetAllAppStreamDirectoryConfigResources() map[string]*appstream.DirectoryConfig {
results := map[string]*appstream.DirectoryConfig{}
Expand Down Expand Up @@ -7148,6 +7177,30 @@ func (t *Template) GetEC2TransitGatewayMulticastGroupSourceWithName(name string)
return nil, fmt.Errorf("resource %q of type ec2.TransitGatewayMulticastGroupSource not found", name)
}

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

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

// GetAllEC2TransitGatewayRouteResources retrieves all ec2.TransitGatewayRoute items from an AWS CloudFormation template
func (t *Template) GetAllEC2TransitGatewayRouteResources() map[string]*ec2.TransitGatewayRoute {
results := map[string]*ec2.TransitGatewayRoute{}
Expand Down Expand Up @@ -11708,6 +11761,30 @@ func (t *Template) GetIoTAnalyticsPipelineWithName(name string) (*iotanalytics.P
return nil, fmt.Errorf("resource %q of type iotanalytics.Pipeline not found", name)
}

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

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

// GetAllIoTEventsDetectorModelResources retrieves all iotevents.DetectorModel items from an AWS CloudFormation template
func (t *Template) GetAllIoTEventsDetectorModelResources() map[string]*iotevents.DetectorModel {
results := map[string]*iotevents.DetectorModel{}
Expand Down
137 changes: 137 additions & 0 deletions cloudformation/apprunner/aws-apprunner-service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package apprunner

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

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

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

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

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

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

// InstanceConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-service.html#cfn-apprunner-service-instanceconfiguration
InstanceConfiguration *Service_InstanceConfiguration `json:"InstanceConfiguration,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
ServiceName string `json:"ServiceName,omitempty"`

// SourceConfiguration AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-service.html#cfn-apprunner-service-sourceconfiguration
SourceConfiguration *Service_SourceConfiguration `json:"SourceConfiguration,omitempty"`

// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apprunner-service.html#cfn-apprunner-service-tags
Tags []tags.Tag `json:"Tags,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) AWSCloudFormationType() string {
return "AWS::AppRunner::Service"
}

// 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 Service) MarshalJSON() ([]byte, error) {
type Properties Service
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 *Service) UnmarshalJSON(b []byte) error {
type Properties Service
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 = Service(*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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package apprunner

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

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

// AccessRoleArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-authenticationconfiguration.html#cfn-apprunner-service-authenticationconfiguration-accessrolearn
AccessRoleArn string `json:"AccessRoleArn,omitempty"`

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

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

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

// CodeConfigurationValues AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-codeconfiguration.html#cfn-apprunner-service-codeconfiguration-codeconfigurationvalues
CodeConfigurationValues *Service_CodeConfigurationValues `json:"CodeConfigurationValues,omitempty"`

// ConfigurationSource AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apprunner-service-codeconfiguration.html#cfn-apprunner-service-codeconfiguration-configurationsource
ConfigurationSource string `json:"ConfigurationSource,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_CodeConfiguration) AWSCloudFormationType() string {
return "AWS::AppRunner::Service.CodeConfiguration"
}

0 comments on commit 95c8bf5

Please sign in to comment.