Skip to content

Commit

Permalink
fix(schema): CloudFormation Updates (awslabs#375)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Maddox <[email protected]>
  • Loading branch information
github-actions[bot] and PaulMaddox authored May 31, 2021
1 parent 703460b commit 5d0d4f2
Show file tree
Hide file tree
Showing 15 changed files with 969 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ type CertificateAuthority_CrlConfiguration struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-acmpca-certificateauthority-crlconfiguration.html#cfn-acmpca-certificateauthority-crlconfiguration-s3bucketname
S3BucketName string `json:"S3BucketName,omitempty"`

// S3ObjectAcl AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-acmpca-certificateauthority-crlconfiguration.html#cfn-acmpca-certificateauthority-crlconfiguration-s3objectacl
S3ObjectAcl string `json:"S3ObjectAcl,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

Expand Down
26 changes: 26 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/awslabs/goformation/v4/cloudformation/codestarnotifications"
"github.com/awslabs/goformation/v4/cloudformation/cognito"
"github.com/awslabs/goformation/v4/cloudformation/config"
"github.com/awslabs/goformation/v4/cloudformation/cur"
"github.com/awslabs/goformation/v4/cloudformation/customerprofiles"
"github.com/awslabs/goformation/v4/cloudformation/databrew"
"github.com/awslabs/goformation/v4/cloudformation/datapipeline"
Expand Down Expand Up @@ -266,6 +267,7 @@ func AllResources() map[string]Resource {
"AWS::CE::AnomalyMonitor": &ce.AnomalyMonitor{},
"AWS::CE::AnomalySubscription": &ce.AnomalySubscription{},
"AWS::CE::CostCategory": &ce.CostCategory{},
"AWS::CUR::ReportDefinition": &cur.ReportDefinition{},
"AWS::Cassandra::Keyspace": &cassandra.Keyspace{},
"AWS::Cassandra::Table": &cassandra.Table{},
"AWS::CertificateManager::Account": &certificatemanager.Account{},
Expand Down Expand Up @@ -3289,6 +3291,30 @@ func (t *Template) GetCECostCategoryWithName(name string) (*ce.CostCategory, err
return nil, fmt.Errorf("resource %q of type ce.CostCategory not found", name)
}

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

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

// GetAllCassandraKeyspaceResources retrieves all cassandra.Keyspace items from an AWS CloudFormation template
func (t *Template) GetAllCassandraKeyspaceResources() map[string]*cassandra.Keyspace {
results := map[string]*cassandra.Keyspace{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Application_ComponentMonitoringSetting struct {
ComponentARN string `json:"ComponentARN,omitempty"`

// ComponentConfigurationMode AWS CloudFormation Property
// Required: false
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-applicationinsights-application-componentmonitoringsetting.html#cfn-applicationinsights-application-componentmonitoringsetting-componentconfigurationmode
ComponentConfigurationMode string `json:"ComponentConfigurationMode,omitempty"`

Expand All @@ -34,7 +34,7 @@ type Application_ComponentMonitoringSetting struct {
DefaultOverwriteComponentConfiguration *Application_ComponentConfiguration `json:"DefaultOverwriteComponentConfiguration,omitempty"`

// Tier AWS CloudFormation Property
// Required: false
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-applicationinsights-application-componentmonitoringsetting.html#cfn-applicationinsights-application-componentmonitoringsetting-tier
Tier string `json:"Tier,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
type Function_FunctionMetadata struct {

// FunctionARN AWS CloudFormation Property
// Required: true
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-function-functionmetadata.html#cfn-cloudfront-function-functionmetadata-functionarn
FunctionARN string `json:"FunctionARN,omitempty"`

Expand Down
161 changes: 161 additions & 0 deletions cloudformation/cur/aws-cur-reportdefinition.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package cur

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

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

// ReportDefinition AWS CloudFormation Resource (AWS::CUR::ReportDefinition)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html
type ReportDefinition struct {

// AdditionalArtifacts AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-additionalartifacts
AdditionalArtifacts []string `json:"AdditionalArtifacts,omitempty"`

// AdditionalSchemaElements AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-additionalschemaelements
AdditionalSchemaElements []string `json:"AdditionalSchemaElements,omitempty"`

// BillingViewArn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-billingviewarn
BillingViewArn string `json:"BillingViewArn,omitempty"`

// Compression AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-compression
Compression string `json:"Compression,omitempty"`

// Format AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-format
Format string `json:"Format,omitempty"`

// RefreshClosedReports AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-refreshclosedreports
RefreshClosedReports bool `json:"RefreshClosedReports"`

// ReportName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-reportname
ReportName string `json:"ReportName,omitempty"`

// ReportVersioning AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-reportversioning
ReportVersioning string `json:"ReportVersioning,omitempty"`

// S3Bucket AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-s3bucket
S3Bucket string `json:"S3Bucket,omitempty"`

// S3Prefix AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-s3prefix
S3Prefix string `json:"S3Prefix,omitempty"`

// S3Region AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-s3region
S3Region string `json:"S3Region,omitempty"`

// TimeUnit AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cur-reportdefinition.html#cfn-cur-reportdefinition-timeunit
TimeUnit string `json:"TimeUnit,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 *ReportDefinition) AWSCloudFormationType() string {
return "AWS::CUR::ReportDefinition"
}

// 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 ReportDefinition) MarshalJSON() ([]byte, error) {
type Properties ReportDefinition
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 *ReportDefinition) UnmarshalJSON(b []byte) error {
type Properties ReportDefinition
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 = ReportDefinition(*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
}
4 changes: 2 additions & 2 deletions cloudformation/ecr/aws-ecr-repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ type Repository struct {
// EncryptionConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-encryptionconfiguration
EncryptionConfiguration interface{} `json:"EncryptionConfiguration,omitempty"`
EncryptionConfiguration *Repository_EncryptionConfiguration `json:"EncryptionConfiguration,omitempty"`

// ImageScanningConfiguration AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-imagescanningconfiguration
ImageScanningConfiguration interface{} `json:"ImageScanningConfiguration,omitempty"`
ImageScanningConfiguration *Repository_ImageScanningConfiguration `json:"ImageScanningConfiguration,omitempty"`

// ImageTagMutability AWS CloudFormation Property
// Required: false
Expand Down
40 changes: 40 additions & 0 deletions cloudformation/ecr/aws-ecr-repository_encryptionconfiguration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ecr

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

// Repository_EncryptionConfiguration AWS CloudFormation Resource (AWS::ECR::Repository.EncryptionConfiguration)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-encryptionconfiguration.html
type Repository_EncryptionConfiguration struct {

// EncryptionType AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-encryptionconfiguration.html#cfn-ecr-repository-encryptionconfiguration-encryptiontype
EncryptionType string `json:"EncryptionType,omitempty"`

// KmsKey AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-encryptionconfiguration.html#cfn-ecr-repository-encryptionconfiguration-kmskey
KmsKey string `json:"KmsKey,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 *Repository_EncryptionConfiguration) AWSCloudFormationType() string {
return "AWS::ECR::Repository.EncryptionConfiguration"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package ecr

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

// Repository_ImageScanningConfiguration AWS CloudFormation Resource (AWS::ECR::Repository.ImageScanningConfiguration)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-imagescanningconfiguration.html
type Repository_ImageScanningConfiguration struct {

// ScanOnPush AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecr-repository-imagescanningconfiguration.html#cfn-ecr-repository-imagescanningconfiguration-scanonpush
ScanOnPush bool `json:"ScanOnPush,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 *Repository_ImageScanningConfiguration) AWSCloudFormationType() string {
return "AWS::ECR::Repository.ImageScanningConfiguration"
}
5 changes: 5 additions & 0 deletions cloudformation/frauddetector/aws-frauddetector-detector.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-frauddetector-detector.html
type Detector struct {

// AssociatedModels AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-frauddetector-detector.html#cfn-frauddetector-detector-associatedmodels
AssociatedModels []Detector_Model `json:"AssociatedModels,omitempty"`

// Description AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-frauddetector-detector.html#cfn-frauddetector-detector-description
Expand Down
35 changes: 35 additions & 0 deletions cloudformation/frauddetector/aws-frauddetector-detector_model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package frauddetector

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

// Detector_Model AWS CloudFormation Resource (AWS::FraudDetector::Detector.Model)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-frauddetector-detector-model.html
type Detector_Model struct {

// Arn AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-frauddetector-detector-model.html#cfn-frauddetector-detector-model-arn
Arn string `json:"Arn,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 *Detector_Model) AWSCloudFormationType() string {
return "AWS::FraudDetector::Detector.Model"
}
5 changes: 5 additions & 0 deletions cloudformation/fsx/aws-fsx-filesystem_lustreconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ type FileSystem_LustreConfiguration struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-fsx-filesystem-lustreconfiguration.html#cfn-fsx-filesystem-lustreconfiguration-dailyautomaticbackupstarttime
DailyAutomaticBackupStartTime string `json:"DailyAutomaticBackupStartTime,omitempty"`

// DataCompressionType AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-fsx-filesystem-lustreconfiguration.html#cfn-fsx-filesystem-lustreconfiguration-datacompressiontype
DataCompressionType string `json:"DataCompressionType,omitempty"`

// DeploymentType AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-fsx-filesystem-lustreconfiguration.html#cfn-fsx-filesystem-lustreconfiguration-deploymenttype
Expand Down
Loading

0 comments on commit 5d0d4f2

Please sign in to comment.