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 21, 2022
1 parent 233ca04 commit 2f3e802
Show file tree
Hide file tree
Showing 30 changed files with 2,337 additions and 76 deletions.
25 changes: 25 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ func AllResources() map[string]Resource {
"AWS::EC2::Volume": &ec2.Volume{},
"AWS::EC2::VolumeAttachment": &ec2.VolumeAttachment{},
"AWS::ECR::PublicRepository": &ecr.PublicRepository{},
"AWS::ECR::PullThroughCacheRule": &ecr.PullThroughCacheRule{},
"AWS::ECR::RegistryPolicy": &ecr.RegistryPolicy{},
"AWS::ECR::ReplicationConfiguration": &ecr.ReplicationConfiguration{},
"AWS::ECR::Repository": &ecr.Repository{},
Expand Down Expand Up @@ -8869,6 +8870,30 @@ func (t *Template) GetECRPublicRepositoryWithName(name string) (*ecr.PublicRepos
return nil, fmt.Errorf("resource %q of type ecr.PublicRepository not found", name)
}

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

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

// GetAllECRRegistryPolicyResources retrieves all ecr.RegistryPolicy items from an AWS CloudFormation template
func (t *Template) GetAllECRRegistryPolicyResources() map[string]*ecr.RegistryPolicy {
results := map[string]*ecr.RegistryPolicy{}
Expand Down
2 changes: 1 addition & 1 deletion cloudformation/batch/aws-batch-computeenvironment.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ComputeEnvironment struct {
// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-batch-computeenvironment.html#cfn-batch-computeenvironment-tags
Tags interface{} `json:"Tags,omitempty"`
Tags map[string]string `json:"Tags,omitempty"`

// Type AWS CloudFormation Property
// Required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type ComputeEnvironment_ComputeResources struct {
// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-tags
Tags interface{} `json:"Tags,omitempty"`
Tags map[string]string `json:"Tags,omitempty"`

// Type AWS CloudFormation Property
// Required: true
Expand Down
2 changes: 1 addition & 1 deletion cloudformation/batch/aws-batch-jobqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type JobQueue struct {
// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-batch-jobqueue.html#cfn-batch-jobqueue-tags
Tags interface{} `json:"Tags,omitempty"`
Tags map[string]string `json:"Tags,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
Expand Down
4 changes: 2 additions & 2 deletions cloudformation/docdb/aws-docdb-dbcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ type DBCluster struct {
KmsKeyId string `json:"KmsKeyId,omitempty"`

// MasterUserPassword AWS CloudFormation Property
// Required: true
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-docdb-dbcluster.html#cfn-docdb-dbcluster-masteruserpassword
MasterUserPassword string `json:"MasterUserPassword,omitempty"`

// MasterUsername AWS CloudFormation Property
// Required: true
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-docdb-dbcluster.html#cfn-docdb-dbcluster-masterusername
MasterUsername string `json:"MasterUsername,omitempty"`

Expand Down
5 changes: 5 additions & 0 deletions cloudformation/ec2/aws-ec2-instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ type Instance struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-placementgroupname
PlacementGroupName string `json:"PlacementGroupName,omitempty"`

// PrivateDnsNameOptions AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-privatednsnameoptions
PrivateDnsNameOptions *Instance_PrivateDnsNameOptions `json:"PrivateDnsNameOptions,omitempty"`

// PrivateIpAddress AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-privateipaddress
Expand Down
45 changes: 45 additions & 0 deletions cloudformation/ec2/aws-ec2-instance_privatednsnameoptions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ec2

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

// Instance_PrivateDnsNameOptions AWS CloudFormation Resource (AWS::EC2::Instance.PrivateDnsNameOptions)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance-privatednsnameoptions.html
type Instance_PrivateDnsNameOptions struct {

// EnableResourceNameDnsAAAARecord AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance-privatednsnameoptions.html#cfn-ec2-instance-privatednsnameoptions-enableresourcenamednsaaaarecord
EnableResourceNameDnsAAAARecord bool `json:"EnableResourceNameDnsAAAARecord,omitempty"`

// EnableResourceNameDnsARecord AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance-privatednsnameoptions.html#cfn-ec2-instance-privatednsnameoptions-enableresourcenamednsarecord
EnableResourceNameDnsARecord bool `json:"EnableResourceNameDnsARecord,omitempty"`

// HostnameType AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance-privatednsnameoptions.html#cfn-ec2-instance-privatednsnameoptions-hostnametype
HostnameType string `json:"HostnameType,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 *Instance_PrivateDnsNameOptions) AWSCloudFormationType() string {
return "AWS::EC2::Instance.PrivateDnsNameOptions"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ type SpotFleet_LaunchTemplateOverrides struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-launchtemplateoverrides.html#cfn-ec2-spotfleet-launchtemplateoverrides-instancetype
InstanceType string `json:"InstanceType,omitempty"`

// Priority AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-launchtemplateoverrides.html#cfn-ec2-spotfleet-launchtemplateoverrides-priority
Priority float64 `json:"Priority,omitempty"`

// SpotPrice AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-launchtemplateoverrides.html#cfn-ec2-spotfleet-launchtemplateoverrides-spotprice
Expand Down
111 changes: 111 additions & 0 deletions cloudformation/ecr/aws-ecr-pullthroughcacherule.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package ecr

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

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

// PullThroughCacheRule AWS CloudFormation Resource (AWS::ECR::PullThroughCacheRule)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-pullthroughcacherule.html
type PullThroughCacheRule struct {

// EcrRepositoryPrefix AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-pullthroughcacherule.html#cfn-ecr-pullthroughcacherule-ecrrepositoryprefix
EcrRepositoryPrefix string `json:"EcrRepositoryPrefix,omitempty"`

// UpstreamRegistryUrl AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-pullthroughcacherule.html#cfn-ecr-pullthroughcacherule-upstreamregistryurl
UpstreamRegistryUrl string `json:"UpstreamRegistryUrl,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 *PullThroughCacheRule) AWSCloudFormationType() string {
return "AWS::ECR::PullThroughCacheRule"
}

// 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 PullThroughCacheRule) MarshalJSON() ([]byte, error) {
type Properties PullThroughCacheRule
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 *PullThroughCacheRule) UnmarshalJSON(b []byte) error {
type Properties PullThroughCacheRule
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 = PullThroughCacheRule(*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/iot/aws-iot-authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ type Authorizer struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-authorizer.html#cfn-iot-authorizer-authorizername
AuthorizerName string `json:"AuthorizerName,omitempty"`

// EnableCachingForHttp AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-authorizer.html#cfn-iot-authorizer-enablecachingforhttp
EnableCachingForHttp bool `json:"EnableCachingForHttp,omitempty"`

// SigningDisabled AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-authorizer.html#cfn-iot-authorizer-signingdisabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
type Dataset_RetentionPeriod struct {

// NumberOfDays AWS CloudFormation Property
// Required: true
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iotanalytics-dataset-retentionperiod.html#cfn-iotanalytics-dataset-retentionperiod-numberofdays
NumberOfDays int `json:"NumberOfDays"`
NumberOfDays int `json:"NumberOfDays,omitempty"`

// Unlimited AWS CloudFormation Property
// Required: true
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iotanalytics-dataset-retentionperiod.html#cfn-iotanalytics-dataset-retentionperiod-unlimited
Unlimited bool `json:"Unlimited"`
Unlimited bool `json:"Unlimited,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/kendra/aws-kendra-datasource.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-kendra-datasource.html
type DataSource struct {

// CustomDocumentEnrichmentConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kendra-datasource.html#cfn-kendra-datasource-customdocumentenrichmentconfiguration
CustomDocumentEnrichmentConfiguration *DataSource_CustomDocumentEnrichmentConfiguration `json:"CustomDocumentEnrichmentConfiguration,omitempty"`

// DataSourceConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kendra-datasource.html#cfn-kendra-datasource-datasourceconfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package kendra

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

// DataSource_CustomDocumentEnrichmentConfiguration AWS CloudFormation Resource (AWS::Kendra::DataSource.CustomDocumentEnrichmentConfiguration)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kendra-datasource-customdocumentenrichmentconfiguration.html
type DataSource_CustomDocumentEnrichmentConfiguration struct {

// InlineConfigurations AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kendra-datasource-customdocumentenrichmentconfiguration.html#cfn-kendra-datasource-customdocumentenrichmentconfiguration-inlineconfigurations
InlineConfigurations []DataSource_InlineCustomDocumentEnrichmentConfiguration `json:"InlineConfigurations,omitempty"`

// PostExtractionHookConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kendra-datasource-customdocumentenrichmentconfiguration.html#cfn-kendra-datasource-customdocumentenrichmentconfiguration-postextractionhookconfiguration
PostExtractionHookConfiguration *DataSource_HookConfiguration `json:"PostExtractionHookConfiguration,omitempty"`

// PreExtractionHookConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kendra-datasource-customdocumentenrichmentconfiguration.html#cfn-kendra-datasource-customdocumentenrichmentconfiguration-preextractionhookconfiguration
PreExtractionHookConfiguration *DataSource_HookConfiguration `json:"PreExtractionHookConfiguration,omitempty"`

// RoleArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-kendra-datasource-customdocumentenrichmentconfiguration.html#cfn-kendra-datasource-customdocumentenrichmentconfiguration-rolearn
RoleArn string `json:"RoleArn,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 *DataSource_CustomDocumentEnrichmentConfiguration) AWSCloudFormationType() string {
return "AWS::Kendra::DataSource.CustomDocumentEnrichmentConfiguration"
}

0 comments on commit 2f3e802

Please sign in to comment.