Skip to content

Commit

Permalink
fix(schema): CloudFormation Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMaddox committed Oct 9, 2021
1 parent 36cc848 commit 9021651
Show file tree
Hide file tree
Showing 10 changed files with 788 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ func AllResources() map[string]Resource {
"AWS::IoT::Dimension": &iot.Dimension{},
"AWS::IoT::DomainConfiguration": &iot.DomainConfiguration{},
"AWS::IoT::FleetMetric": &iot.FleetMetric{},
"AWS::IoT::JobTemplate": &iot.JobTemplate{},
"AWS::IoT::MitigationAction": &iot.MitigationAction{},
"AWS::IoT::Policy": &iot.Policy{},
"AWS::IoT::PolicyPrincipalAttachment": &iot.PolicyPrincipalAttachment{},
Expand Down Expand Up @@ -11821,6 +11822,30 @@ func (t *Template) GetIoTFleetMetricWithName(name string) (*iot.FleetMetric, err
return nil, fmt.Errorf("resource %q of type iot.FleetMetric not found", name)
}

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

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

// GetAllIoTMitigationActionResources retrieves all iot.MitigationAction items from an AWS CloudFormation template
func (t *Template) GetAllIoTMitigationActionResources() map[string]*iot.MitigationAction {
results := map[string]*iot.MitigationAction{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ import (
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html
type NotificationRule struct {

// CreatedBy AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-createdby
CreatedBy string `json:"CreatedBy,omitempty"`

// DetailType AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-detailtype
DetailType string `json:"DetailType,omitempty"`

// EventTypeId AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-eventtypeid
EventTypeId string `json:"EventTypeId,omitempty"`

// EventTypeIds AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-eventtypeids
Expand All @@ -42,6 +52,11 @@ type NotificationRule struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-tags
Tags interface{} `json:"Tags,omitempty"`

// TargetAddress AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-targetaddress
TargetAddress string `json:"TargetAddress,omitempty"`

// Targets AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-targets
Expand Down
152 changes: 152 additions & 0 deletions cloudformation/iot/aws-iot-jobtemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package iot

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

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

// JobTemplate AWS CloudFormation Resource (AWS::IoT::JobTemplate)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html
type JobTemplate struct {

// AbortConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-abortconfig
AbortConfig interface{} `json:"AbortConfig,omitempty"`

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

// Document AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-document
Document string `json:"Document,omitempty"`

// DocumentSource AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-documentsource
DocumentSource string `json:"DocumentSource,omitempty"`

// JobArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-jobarn
JobArn string `json:"JobArn,omitempty"`

// JobExecutionsRolloutConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-jobexecutionsrolloutconfig
JobExecutionsRolloutConfig interface{} `json:"JobExecutionsRolloutConfig,omitempty"`

// JobTemplateId AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-jobtemplateid
JobTemplateId string `json:"JobTemplateId,omitempty"`

// PresignedUrlConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-presignedurlconfig
PresignedUrlConfig interface{} `json:"PresignedUrlConfig,omitempty"`

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

// TimeoutConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-jobtemplate.html#cfn-iot-jobtemplate-timeoutconfig
TimeoutConfig interface{} `json:"TimeoutConfig,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 *JobTemplate) AWSCloudFormationType() string {
return "AWS::IoT::JobTemplate"
}

// 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 JobTemplate) MarshalJSON() ([]byte, error) {
type Properties JobTemplate
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 *JobTemplate) UnmarshalJSON(b []byte) error {
type Properties JobTemplate
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 = JobTemplate(*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
}
5 changes: 5 additions & 0 deletions cloudformation/synthetics/aws-synthetics-canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html
type Canary struct {

// ArtifactConfig AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-artifactconfig
ArtifactConfig *Canary_ArtifactConfig `json:"ArtifactConfig,omitempty"`

// ArtifactS3Location AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-artifacts3location
Expand Down
35 changes: 35 additions & 0 deletions cloudformation/synthetics/aws-synthetics-canary_artifactconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package synthetics

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

// Canary_ArtifactConfig AWS CloudFormation Resource (AWS::Synthetics::Canary.ArtifactConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-artifactconfig.html
type Canary_ArtifactConfig struct {

// S3Encryption AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-artifactconfig.html#cfn-synthetics-canary-artifactconfig-s3encryption
S3Encryption interface{} `json:"S3Encryption,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 *Canary_ArtifactConfig) AWSCloudFormationType() string {
return "AWS::Synthetics::Canary.ArtifactConfig"
}
40 changes: 40 additions & 0 deletions cloudformation/synthetics/aws-synthetics-canary_s3encryption.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package synthetics

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

// Canary_S3Encryption AWS CloudFormation Resource (AWS::Synthetics::Canary.S3Encryption)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-s3encryption.html
type Canary_S3Encryption struct {

// EncryptionMode AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-s3encryption.html#cfn-synthetics-canary-s3encryption-encryptionmode
EncryptionMode string `json:"EncryptionMode,omitempty"`

// KmsKeyArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-s3encryption.html#cfn-synthetics-canary-s3encryption-kmskeyarn
KmsKeyArn string `json:"KmsKeyArn,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 *Canary_S3Encryption) AWSCloudFormationType() string {
return "AWS::Synthetics::Canary.S3Encryption"
}
Loading

0 comments on commit 9021651

Please sign in to comment.