Documentation
¶
Overview ¶
Package forecast looks at your account and tries to predict things that will go wrong when you attempt to CREATE, UPDATE, or DELETE a stack
Index ¶
- Constants
- Variables
- func FormatEstimate(total int) string
- func GetNode(prop *yaml.Node, name string) *yaml.Node
- func GetResourceEstimate(resourceType string, action StackAction) (int, error)
- func InitEstimates()
- func Predict(source cft.Template, stackName string, stack types.Stack, stackExists bool, ...) bool
- func PredictTotalEstimate(t cft.Template, stackExists bool) int
- type Check
- type Env
- type Forecast
- func CheckAutoScalingLaunchConfiguration(input PredictionInput) Forecast
- func CheckEC2Instance(input PredictionInput) Forecast
- func CheckEC2LaunchTemplate(input PredictionInput) Forecast
- func CheckEC2SecurityGroup(input PredictionInput) Forecast
- func CheckELBListener(input PredictionInput) Forecast
- func CheckELBTargetGroup(input PredictionInput) Forecast
- func CheckLambdaFunction(input PredictionInput) Forecast
- func CheckRDSDBCluster(input PredictionInput) Forecast
- func CheckS3Bucket(input PredictionInput) Forecast
- func CheckS3BucketPolicy(input PredictionInput) Forecast
- func CheckSNSTopic(input PredictionInput) Forecast
- func CheckSageMakerNotebook(input PredictionInput) Forecast
- type NotebookCode
- type PredictionInput
- type ResourceEstimate
- type StackAction
Constants ¶
const ( FG001 = "FG001" FG002 = "FG002" F0001 = "F0001" F0002 = "F0002" F0003 = "F0003" F0004 = "F0004" F0005 = "F0005" F0006 = "F0006" F0007 = "F0007" F0008 = "F0008" F0009 = "F0009" F0010 = "F0010" F0011 = "F0011" F0012 = "F0012" F0013 = "F0013" F0014 = "F0014" F0015 = "F0015" F0016 = "F0016" F0017 = "F0017" F0018 = "F0018" F0019 = "F0019" F0020 = "F0020" F0021 = "F0021" F0022 = "F0022" )
const ( ALL = "all" CREATE = "create" UPDATE = "update" DELETE = "delete" )
Variables ¶
var Cmd = &cobra.Command{ Use: "forecast --experimental <template> [stackName]", Short: "Predict deployment failures", Long: `Outputs warnings about potential deployment failures due to constraints in the account or misconfigurations in the template related to dependencies in the account. NOTE: This is an experimental feature! To use this command, add --experimental or -x as an argument. This command is not a linter! Use cfn-lint for that. The forecast command is concerned with things that could go wrong during deployment, after the template has been checked to make sure it has a valid syntax. This command checks for some common issues across all resources, and resource-specific checks. See the README for more details. `, Args: cobra.RangeArgs(1, 2), DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { fn := args[0] base := filepath.Base(fn) var suppliedStackName string if len(args) == 2 { suppliedStackName = args[1] } else { suppliedStackName = "" } if !Experimental { panic("Please add the --experimental arg to use this feature") } pkg.Experimental = Experimental config.Debugf("Generating forecast for %v", fn) source, err := pkg.File(fn) if err != nil { panic(err) } content := format.CftToYaml(source) source, err = parse.String(content) if err != nil { panic(err) } stackName := dc.GetStackName(suppliedStackName, base) spinner.Push(fmt.Sprintf("Checking current status of stack '%s'", stackName)) stack, stackExists := deploy.CheckStack(stackName) spinner.Pop() msg := "" if stackExists { msg = "exists" } else { msg = "does not exist" } config.Debugf("Stack %v %v", stackName, msg) if action == DELETE || action == UPDATE && !stackExists { panic(fmt.Sprintf("stack %v does not exist, action %s is not valid", stackName, action)) } if action == CREATE && stackExists { panic(fmt.Sprintf("stack %v already exists, action %s is not valid", stackName, action)) } dc, err := dc.GetDeployConfig(tags, params, configFilePath, base, source, stack, stackExists, true, false) if err != nil { panic(err) } if !Predict(source, stackName, stack, stackExists, dc) { os.Exit(1) } }, }
Cmd is the forecast command's entrypoint
var Estimates map[string]ResourceEstimate
Estimates is a map of resource type name to ResourceEstimates, which are based on historical averages
var Experimental bool
Experimental indicates that this is an experimental feature that might break between minor releases
var IncludeIAM bool
IncludeIAM indicates if we should perform permissions checks or not, to save time
var LineNumber int
LineNumber is the current line number in the template
var ResourceType string
ResourceType is the resource type to check (optional --type to limit checks to one type)
var RoleArn string
RoleArn is the role name to use for the IAM policy simulator (optional --role)
Functions ¶
func FormatEstimate ¶ added in v1.7.0
FormatEstimate returns a string in human readable format to represent the number of seconds. For example, 61 would return "0h, 1m, 1s"
func GetNode ¶ added in v1.13.1
func GetNode(prop *yaml.Node, name string) *yaml.Node
GetNode is a simplified version of s11n.GetMapValue that returns the value only
func GetResourceEstimate ¶ added in v1.7.0
func GetResourceEstimate(resourceType string, action StackAction) (int, error)
GetResourceEstimate returns the estimated time an action will take for the given resource type
func InitEstimates ¶ added in v1.7.0
func InitEstimates()
init initializes the Estimates map for all AWS resource types
Types ¶
type Forecast ¶
Forecast represents predictions for a single resource in the template
func CheckAutoScalingLaunchConfiguration ¶ added in v1.14.0
func CheckAutoScalingLaunchConfiguration(input PredictionInput) Forecast
func CheckEC2Instance ¶ added in v1.14.0
func CheckEC2Instance(input PredictionInput) Forecast
func CheckEC2LaunchTemplate ¶ added in v1.14.0
func CheckEC2LaunchTemplate(input PredictionInput) Forecast
func CheckEC2SecurityGroup ¶ added in v1.14.0
func CheckEC2SecurityGroup(input PredictionInput) Forecast
func CheckELBListener ¶ added in v1.14.0
func CheckELBListener(input PredictionInput) Forecast
func CheckELBTargetGroup ¶ added in v1.14.0
func CheckELBTargetGroup(input PredictionInput) Forecast
func CheckLambdaFunction ¶ added in v1.14.0
func CheckLambdaFunction(input PredictionInput) Forecast
checkLambdaFunction checks for potential stack failures related to functions
func CheckRDSDBCluster ¶ added in v1.14.0
func CheckRDSDBCluster(input PredictionInput) Forecast
Checks configuration issues with RDS clusters
func CheckS3Bucket ¶ added in v1.14.0
func CheckS3Bucket(input PredictionInput) Forecast
Check everything that could go wrong with an AWS::S3::Bucket resource
func CheckS3BucketPolicy ¶ added in v1.14.0
func CheckS3BucketPolicy(input PredictionInput) Forecast
Check everything that could go wrong with an AWS::S3::Bucket resource. Returns numFailed, numChecked
func CheckSNSTopic ¶ added in v1.14.0
func CheckSNSTopic(input PredictionInput) Forecast
func CheckSageMakerNotebook ¶ added in v1.14.0
func CheckSageMakerNotebook(input PredictionInput) Forecast
func (*Forecast) Add ¶
Add adds a pass or fail message, formatting it to include the type name and logical id
func (*Forecast) GetNumChecked ¶
func (*Forecast) GetNumFailed ¶
func (*Forecast) GetNumPassed ¶
type NotebookCode ¶ added in v1.13.1
func ParseNotebookCodes ¶ added in v1.13.1
func ParseNotebookCodes(jsonData string) ([]NotebookCode, error)
type PredictionInput ¶
type PredictionInput struct {
// contains filtered or unexported fields
}
PredictionInput is the input to forecast prediction functions
func (*PredictionInput) GetPropertyNode ¶ added in v1.9.0
func (input *PredictionInput) GetPropertyNode(name string) *yaml.Node
GetPropertyNode returns the node for the given property name
type ResourceEstimate ¶ added in v1.7.0
ResourceEstimate stores the estimated time, in seconds, to create, update, or delete a specific resource type. The Name is something like "AWS::S3::Bucket"
func NewResourceEstimate ¶ added in v1.7.0
func NewResourceEstimate(name string, create int, update int, del int) ResourceEstimate
NewResourceEstimate creates a new instance of ResourceEstimate
type StackAction ¶ added in v1.7.0
type StackAction string
const ( Create StackAction = "create" Update StackAction = "update" Delete StackAction = "delete" )