Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
fix(schema): CloudFormation Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulMaddox committed Mar 13, 2021
1 parent 8ccf34c commit 3dee257
Show file tree
Hide file tree
Showing 30 changed files with 3,346 additions and 74 deletions.
125 changes: 125 additions & 0 deletions cloudformation/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ func AllResources() map[string]Resource {
"AWS::Batch::JobDefinition": &batch.JobDefinition{},
"AWS::Batch::JobQueue": &batch.JobQueue{},
"AWS::Budgets::Budget": &budgets.Budget{},
"AWS::CE::AnomalyMonitor": &ce.AnomalyMonitor{},
"AWS::CE::AnomalySubscription": &ce.AnomalySubscription{},
"AWS::CE::CostCategory": &ce.CostCategory{},
"AWS::Cassandra::Keyspace": &cassandra.Keyspace{},
"AWS::Cassandra::Table": &cassandra.Table{},
"AWS::CertificateManager::Account": &certificatemanager.Account{},
"AWS::CertificateManager::Certificate": &certificatemanager.Certificate{},
"AWS::Chatbot::SlackChannelConfiguration": &chatbot.SlackChannelConfiguration{},
"AWS::Cloud9::EnvironmentEC2": &cloud9.EnvironmentEC2{},
Expand Down Expand Up @@ -425,6 +428,7 @@ func AllResources() map[string]Resource {
"AWS::ECR::Repository": &ecr.Repository{},
"AWS::ECS::CapacityProvider": &ecs.CapacityProvider{},
"AWS::ECS::Cluster": &ecs.Cluster{},
"AWS::ECS::ClusterCapacityProviderAssociations": &ecs.ClusterCapacityProviderAssociations{},
"AWS::ECS::PrimaryTaskSet": &ecs.PrimaryTaskSet{},
"AWS::ECS::Service": &ecs.Service{},
"AWS::ECS::TaskDefinition": &ecs.TaskDefinition{},
Expand Down Expand Up @@ -709,6 +713,7 @@ func AllResources() map[string]Resource {
"AWS::RDS::DBInstance": &rds.DBInstance{},
"AWS::RDS::DBParameterGroup": &rds.DBParameterGroup{},
"AWS::RDS::DBProxy": &rds.DBProxy{},
"AWS::RDS::DBProxyEndpoint": &rds.DBProxyEndpoint{},
"AWS::RDS::DBProxyTargetGroup": &rds.DBProxyTargetGroup{},
"AWS::RDS::DBSecurityGroup": &rds.DBSecurityGroup{},
"AWS::RDS::DBSecurityGroupIngress": &rds.DBSecurityGroupIngress{},
Expand Down Expand Up @@ -3053,6 +3058,54 @@ func (t *Template) GetBudgetsBudgetWithName(name string) (*budgets.Budget, error
return nil, fmt.Errorf("resource %q of type budgets.Budget not found", name)
}

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

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

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

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

// GetAllCECostCategoryResources retrieves all ce.CostCategory items from an AWS CloudFormation template
func (t *Template) GetAllCECostCategoryResources() map[string]*ce.CostCategory {
results := map[string]*ce.CostCategory{}
Expand Down Expand Up @@ -3125,6 +3178,30 @@ func (t *Template) GetCassandraTableWithName(name string) (*cassandra.Table, err
return nil, fmt.Errorf("resource %q of type cassandra.Table not found", name)
}

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

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

// GetAllCertificateManagerCertificateResources retrieves all certificatemanager.Certificate items from an AWS CloudFormation template
func (t *Template) GetAllCertificateManagerCertificateResources() map[string]*certificatemanager.Certificate {
results := map[string]*certificatemanager.Certificate{}
Expand Down Expand Up @@ -7397,6 +7474,30 @@ func (t *Template) GetECSClusterWithName(name string) (*ecs.Cluster, error) {
return nil, fmt.Errorf("resource %q of type ecs.Cluster not found", name)
}

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

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

// GetAllECSPrimaryTaskSetResources retrieves all ecs.PrimaryTaskSet items from an AWS CloudFormation template
func (t *Template) GetAllECSPrimaryTaskSetResources() map[string]*ecs.PrimaryTaskSet {
results := map[string]*ecs.PrimaryTaskSet{}
Expand Down Expand Up @@ -14213,6 +14314,30 @@ func (t *Template) GetRDSDBProxyWithName(name string) (*rds.DBProxy, error) {
return nil, fmt.Errorf("resource %q of type rds.DBProxy not found", name)
}

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

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

// GetAllRDSDBProxyTargetGroupResources retrieves all rds.DBProxyTargetGroup items from an AWS CloudFormation template
func (t *Template) GetAllRDSDBProxyTargetGroupResources() map[string]*rds.DBProxyTargetGroup {
results := map[string]*rds.DBProxyTargetGroup{}
Expand Down
5 changes: 5 additions & 0 deletions cloudformation/appsync/aws-appsync-graphqlapi.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package appsync

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

// GraphQLApi_LambdaAuthorizerConfig AWS CloudFormation Resource (AWS::AppSync::GraphQLApi.LambdaAuthorizerConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html
type GraphQLApi_LambdaAuthorizerConfig struct {

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

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

// IdentityValidationExpression AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-graphqlapi-lambdaauthorizerconfig.html#cfn-appsync-graphqlapi-lambdaauthorizerconfig-identityvalidationexpression
IdentityValidationExpression string `json:"IdentityValidationExpression,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 *GraphQLApi_LambdaAuthorizerConfig) AWSCloudFormationType() string {
return "AWS::AppSync::GraphQLApi.LambdaAuthorizerConfig"
}
2 changes: 1 addition & 1 deletion cloudformation/backup/aws-backup-backupplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type BackupPlan struct {
// BackupPlanTags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-backup-backupplan.html#cfn-backup-backupplan-backupplantags
BackupPlanTags interface{} `json:"BackupPlanTags,omitempty"`
BackupPlanTags map[string]string `json:"BackupPlanTags,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type BackupPlan_BackupRuleResourceType struct {
// RecoveryPointTags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupplan-backupruleresourcetype.html#cfn-backup-backupplan-backupruleresourcetype-recoverypointtags
RecoveryPointTags interface{} `json:"RecoveryPointTags,omitempty"`
RecoveryPointTags map[string]string `json:"RecoveryPointTags,omitempty"`

// RuleName AWS CloudFormation Property
// Required: true
Expand Down
121 changes: 121 additions & 0 deletions cloudformation/ce/aws-ce-anomalymonitor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package ce

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

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

// AnomalyMonitor AWS CloudFormation Resource (AWS::CE::AnomalyMonitor)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ce-anomalymonitor.html
type AnomalyMonitor struct {

// MonitorDimension AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ce-anomalymonitor.html#cfn-ce-anomalymonitor-monitordimension
MonitorDimension string `json:"MonitorDimension,omitempty"`

// MonitorName AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ce-anomalymonitor.html#cfn-ce-anomalymonitor-monitorname
MonitorName string `json:"MonitorName,omitempty"`

// MonitorSpecification AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ce-anomalymonitor.html#cfn-ce-anomalymonitor-monitorspecification
MonitorSpecification string `json:"MonitorSpecification,omitempty"`

// MonitorType AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ce-anomalymonitor.html#cfn-ce-anomalymonitor-monitortype
MonitorType string `json:"MonitorType,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 *AnomalyMonitor) AWSCloudFormationType() string {
return "AWS::CE::AnomalyMonitor"
}

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

0 comments on commit 3dee257

Please sign in to comment.