Skip to content

Commit

Permalink
fix(schema): CloudFormation Updates (awslabs#385)
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 Jun 25, 2021
1 parent 36a485c commit 8b5b816
Show file tree
Hide file tree
Showing 25 changed files with 2,751 additions and 7 deletions.
101 changes: 101 additions & 0 deletions cloudformation/all.go
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/awslabs/goformation/v5/cloudformation/codestarnotifications"
"github.com/awslabs/goformation/v5/cloudformation/cognito"
"github.com/awslabs/goformation/v5/cloudformation/config"
"github.com/awslabs/goformation/v5/cloudformation/connect"
"github.com/awslabs/goformation/v5/cloudformation/cur"
"github.com/awslabs/goformation/v5/cloudformation/customerprofiles"
"github.com/awslabs/goformation/v5/cloudformation/databrew"
Expand Down Expand Up @@ -281,10 +282,13 @@ func AllResources() map[string]Resource {
"AWS::CloudFormation::Macro": &cloudformation.Macro{},
"AWS::CloudFormation::ModuleDefaultVersion": &cloudformation.ModuleDefaultVersion{},
"AWS::CloudFormation::ModuleVersion": &cloudformation.ModuleVersion{},
"AWS::CloudFormation::PublicTypeVersion": &cloudformation.PublicTypeVersion{},
"AWS::CloudFormation::Publisher": &cloudformation.Publisher{},
"AWS::CloudFormation::ResourceDefaultVersion": &cloudformation.ResourceDefaultVersion{},
"AWS::CloudFormation::ResourceVersion": &cloudformation.ResourceVersion{},
"AWS::CloudFormation::Stack": &cloudformation.Stack{},
"AWS::CloudFormation::StackSet": &cloudformation.StackSet{},
"AWS::CloudFormation::TypeActivation": &cloudformation.TypeActivation{},
"AWS::CloudFormation::WaitCondition": &cloudformation.WaitCondition{},
"AWS::CloudFormation::WaitConditionHandle": &cloudformation.WaitConditionHandle{},
"AWS::CloudFront::CachePolicy": &cloudfront.CachePolicy{},
Expand Down Expand Up @@ -342,6 +346,7 @@ func AllResources() map[string]Resource {
"AWS::Config::OrganizationConformancePack": &config.OrganizationConformancePack{},
"AWS::Config::RemediationConfiguration": &config.RemediationConfiguration{},
"AWS::Config::StoredQuery": &config.StoredQuery{},
"AWS::Connect::QuickConnect": &connect.QuickConnect{},
"AWS::CustomerProfiles::Domain": &customerprofiles.Domain{},
"AWS::CustomerProfiles::Integration": &customerprofiles.Integration{},
"AWS::CustomerProfiles::ObjectType": &customerprofiles.ObjectType{},
Expand Down Expand Up @@ -3570,6 +3575,54 @@ func (t *Template) GetCloudFormationModuleVersionWithName(name string) (*cloudfo
return nil, fmt.Errorf("resource %q of type cloudformation.ModuleVersion not found", name)
}

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

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

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

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

// GetAllCloudFormationResourceDefaultVersionResources retrieves all cloudformation.ResourceDefaultVersion items from an AWS CloudFormation template
func (t *Template) GetAllCloudFormationResourceDefaultVersionResources() map[string]*cloudformation.ResourceDefaultVersion {
results := map[string]*cloudformation.ResourceDefaultVersion{}
Expand Down Expand Up @@ -3666,6 +3719,30 @@ func (t *Template) GetCloudFormationStackSetWithName(name string) (*cloudformati
return nil, fmt.Errorf("resource %q of type cloudformation.StackSet not found", name)
}

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

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

// GetAllCloudFormationWaitConditionResources retrieves all cloudformation.WaitCondition items from an AWS CloudFormation template
func (t *Template) GetAllCloudFormationWaitConditionResources() map[string]*cloudformation.WaitCondition {
results := map[string]*cloudformation.WaitCondition{}
Expand Down Expand Up @@ -5034,6 +5111,30 @@ func (t *Template) GetConfigStoredQueryWithName(name string) (*config.StoredQuer
return nil, fmt.Errorf("resource %q of type config.StoredQuery not found", name)
}

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

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

// GetAllCustomerProfilesDomainResources retrieves all customerprofiles.Domain items from an AWS CloudFormation template
func (t *Template) GetAllCustomerProfilesDomainResources() map[string]*customerprofiles.Domain {
results := map[string]*customerprofiles.Domain{}
Expand Down
Expand Up @@ -23,6 +23,11 @@ type DomainName_DomainNameConfiguration struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-endpointtype
EndpointType string `json:"EndpointType,omitempty"`

// OwnershipVerificationCertificateArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-ownershipverificationcertificatearn
OwnershipVerificationCertificateArn string `json:"OwnershipVerificationCertificateArn,omitempty"`

// SecurityPolicy AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-domainname-domainnameconfiguration.html#cfn-apigatewayv2-domainname-domainnameconfiguration-securitypolicy
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/appsync/aws-appsync-graphqlapi.go
Expand Up @@ -22,6 +22,11 @@ type GraphQLApi struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-authenticationtype
AuthenticationType string `json:"AuthenticationType,omitempty"`

// LambdaAuthorizerConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-lambdaauthorizerconfig
LambdaAuthorizerConfig *GraphQLApi_LambdaAuthorizerConfig `json:"LambdaAuthorizerConfig,omitempty"`

// LogConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-graphqlapi.html#cfn-appsync-graphqlapi-logconfig
Expand Down
Expand Up @@ -13,6 +13,11 @@ type GraphQLApi_AdditionalAuthenticationProvider struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html#cfn-appsync-graphqlapi-additionalauthenticationprovider-authenticationtype
AuthenticationType string `json:"AuthenticationType,omitempty"`

// LambdaAuthorizerConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html#cfn-appsync-graphqlapi-additionalauthenticationprovider-lambdaauthorizerconfig
LambdaAuthorizerConfig *GraphQLApi_LambdaAuthorizerConfig `json:"LambdaAuthorizerConfig,omitempty"`

// OpenIDConnectConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-additionalauthenticationprovider.html#cfn-appsync-graphqlapi-additionalauthenticationprovider-openidconnectconfig
Expand Down
126 changes: 126 additions & 0 deletions cloudformation/cloudformation/aws-cloudformation-publictypeversion.go
@@ -0,0 +1,126 @@
package cloudformation

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

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

// PublicTypeVersion AWS CloudFormation Resource (AWS::CloudFormation::PublicTypeVersion)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-publictypeversion.html
type PublicTypeVersion struct {

// Arn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-publictypeversion.html#cfn-cloudformation-publictypeversion-arn
Arn string `json:"Arn,omitempty"`

// LogDeliveryBucket AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-publictypeversion.html#cfn-cloudformation-publictypeversion-logdeliverybucket
LogDeliveryBucket string `json:"LogDeliveryBucket,omitempty"`

// PublicVersionNumber AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-publictypeversion.html#cfn-cloudformation-publictypeversion-publicversionnumber
PublicVersionNumber string `json:"PublicVersionNumber,omitempty"`

// Type AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-publictypeversion.html#cfn-cloudformation-publictypeversion-type
Type string `json:"Type,omitempty"`

// TypeName AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-publictypeversion.html#cfn-cloudformation-publictypeversion-typename
TypeName string `json:"TypeName,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 *PublicTypeVersion) AWSCloudFormationType() string {
return "AWS::CloudFormation::PublicTypeVersion"
}

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

0 comments on commit 8b5b816

Please sign in to comment.