chanute

package module
v0.0.0-...-3878f25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: MIT Imports: 22 Imported by: 0

README

Chanute

A library that makes dealing with AWS Trusted Advisor less bad.

Who is Chanute?

Octave Chanute was the Wright Brothers' trusted advisor and the father of aviation.

Examples

View the cmd directory for more complex usage.

sess := session.Must(session.NewSession(&aws.Config{Region: aws.String("us-east-1")}))
r, err := chanute.GenerateReport(sess)
if err != nil {
    panic(err)
}
fmt.Println(r.AsciiReport())
Outputs
EC2
+-----------------------------+----+----------------------+---------------------------+
|            NAME             | ID | LOW UTILIZATION DAYS | ESTIMATED MONTHLY SAVINGS |
+-----------------------------+----+----------------------+---------------------------+
| cloud engineering           |    |                      | $2,792                    |
| sct                         |    |                      | $303                      |
+-----------------------------+----+----------------------+---------------------------+

Load Balancers
+----------------------------------+--------+--------+--------------+
|               NAME               | REGION | REASON | MONTHLY COST |
+----------------------------------+--------+--------+--------------+
| Production-Backend-LoadBalancer  |        |        | $18          |
+----------------------------------+--------+--------+--------------+

EBS
+-------------------------------------------------------------+-------------+--------------+--------------+
|                          VOLUME ID                          | VOLUME NAME | SIZE (IN GB) | MONTHLY COST |
+-------------------------------------------------------------+-------------+--------------+--------------+
| site reliability                                            |             |          112 | $10          |
+-------------------------------------------------------------+-------------+--------------+--------------+

RDS
+----------------------+---------+-----------------------+----------------------+--------------+
|         NAME         | MULTIAZ | DAYS SINCE CONNECTION | STORAGE SIZE (IN GB) | MONTHLY COST |
+----------------------+---------+-----------------------+----------------------+--------------+
| cloud engineering    |         |                       |                    2 | $60          |
+----------------------+---------+-----------------------+----------------------+--------------+

Redshift
+-------------------+--------+--------+--------------+
|       NAME        | STATUS | REASON | MONTHLY COST |
+-------------------+--------+--------+--------------+
| cloud engineering |        |        | $180         |
+-------------------+--------+--------+--------------+

Documentation

Index

Constants

View Source
const (
	CheckAmazonAuroraDBInstanceAccessibility                       = "Amazon Aurora DB Instance Accessibility"
	CheckAmazonEBSProvisionedIOPSSSDVolumeAttachmentConfiguration  = "Amazon EBS Provisioned IOPS (SSD) Volume Attachment Configuration"
	CheckAmazonEBSPublicSnapshots                                  = "Amazon EBS Public Snapshots"
	CheckAmazonEBSSnapshots                                        = "Amazon EBS Snapshots"
	CheckAmazonEC2AvailabilityZoneBalance                          = "Amazon EC2 Availability Zone Balance"
	CheckAmazonEC2ReservedInstanceLeaseExpiration                  = "Amazon EC2 Reserved Instance Lease Expiration"
	CheckAmazonEC2ReservedInstancesOptimization                    = "Amazon EC2 Reserved Instances Optimization"
	CheckAmazonEC2toEBSThroughputOptimization                      = "Amazon EC2 to EBS Throughput Optimization"
	CheckAmazonRDSBackups                                          = "Amazon RDS Backups"
	CheckAmazonRDSIdleDBInstances                                  = "Amazon RDS Idle DB Instances"
	CheckAmazonRDSMultiAZ                                          = "Amazon RDS Multi-AZ"
	CheckAmazonRDSPublicSnapshots                                  = "Amazon RDS Public Snapshots"
	CheckAmazonRDSSecurityGroupAccessRisk                          = "Amazon RDS Security Group Access Risk"
	CheckAmazonRoute53AliasResourceRecordSets                      = "Amazon Route 53 Alias Resource Record Sets"
	CheckAmazonRoute53DeletedHealthChecks                          = "Amazon Route 53 Deleted Health Checks"
	CheckAmazonRoute53FailoverResourceRecordSets                   = "Amazon Route 53 Failover Resource Record Sets"
	CheckAmazonRoute53HighTTLResourceRecordSets                    = "Amazon Route 53 High TTL Resource Record Sets"
	CheckAmazonRoute53LatencyResourceRecordSets                    = "Amazon Route 53 Latency Resource Record Sets"
	CheckAmazonRoute53MXResourceRecordSetsandSenderPolicyFramework = "Amazon Route 53 MX Resource Record Sets and Sender Policy Framework"
	CheckAmazonRoute53NameServerDelegations                        = "Amazon Route 53 Name Server Delegations"
	CheckAmazonS3BucketLogging                                     = "Amazon S3 Bucket Logging"
	CheckAmazonS3BucketPermissions                                 = "Amazon S3 Bucket Permissions"
	CheckAmazonS3BucketVersioning                                  = "Amazon S3 Bucket Versioning"
	CheckAutoScalingGroupHealthCheck                               = "Auto Scaling Group Health Check"
	CheckAutoScalingGroupResources                                 = "Auto Scaling Group Resources"
	CheckAutoScalingGroups                                         = "Auto Scaling Groups"
	CheckAutoScalingLaunchConfigurations                           = "Auto Scaling Launch Configurations"
	CheckAWSCloudTrailLogging                                      = "AWS CloudTrail Logging"
	CheckAWSDirectConnectConnectionRedundancy                      = "AWS Direct Connect Connection Redundancy"
	CheckAWSDirectConnectLocationRedundancy                        = "AWS Direct Connect Location Redundancy"
	CheckAWSDirectConnectVirtualInterfaceRedundancy                = "AWS Direct Connect Virtual Interface Redundancy"
	CheckCloudFormationStacks                                      = "CloudFormation Stacks"
	CheckCloudFrontAlternateDomainNames                            = "CloudFront Alternate Domain Names"
	CheckCloudFrontContentDeliveryOptimization                     = "CloudFront Content Delivery Optimization"
	CheckCloudFrontCustomSSLCertificatesintheIAMCertificateStore   = "CloudFront Custom SSL Certificates in the IAM Certificate Store"
	CheckCloudFrontHeaderForwardingandCacheHitRatio                = "CloudFront Header Forwarding and Cache Hit Ratio"
	CheckCloudFrontSSLCertificateontheOriginServer                 = "CloudFront SSL Certificate on the Origin Server"
	CheckDynamoDBReadCapacity                                      = "DynamoDB Read Capacity"
	CheckDynamoDBWriteCapacity                                     = "DynamoDB Write Capacity"
	CheckEBSActiveSnapshots                                        = "EBS Active Snapshots"
	CheckEBSActiveVolumes                                          = "EBS Active Volumes"
	CheckEBSColdHDDSC1VolumeStorage                                = "EBS Cold HDD (sc1) Volume Storage"
	CheckEBSGeneralPurposeSSDGP2VolumeStorage                      = "EBS General Purpose SSD (gp2) Volume Storage"
	CheckEBSMagneticStandardVolumeStorage                          = "EBS Magnetic (standard) Volume Storage"
	CheckEBSProvisionedIOPSSSSDVolumeAggregateIOPS                 = "EBS Provisioned IOPS (SSD) Volume Aggregate IOPS"
	CheckEBSProvisionedIOPSSSDIO1VolumeStorage                     = "EBS Provisioned IOPS SSD (io1) Volume Storage"
	CheckEBSThroughputOptimizedHDDST1VolumeStorage                 = "EBS Throughput Optimized HDD (st1) Volume Storage"
	CheckEC2ElasticIPAddresses                                     = "EC2 Elastic IP Addresses"
	CheckEC2OnDemandInstances                                      = "EC2 On-Demand Instances"
	CheckEC2ReservedInstanceLeases                                 = "EC2 Reserved Instance Leases"
	CheckEC2ConfigServiceforEC2WindowsInstances                    = "EC2Config Service for EC2 Windows Instances"
	CheckELBApplicationLoadBalancers                               = "ELB Application Load Balancers"
	CheckELBClassicLoadBalancers                                   = "ELB Classic Load Balancers"
	CheckELBConnectionDraining                                     = "ELB Connection Draining"
	CheckELBCrossZoneLoadBalancing                                 = "ELB Cross-Zone Load Balancing"
	CheckELBListenerSecurity                                       = "ELB Listener Security"
	CheckELBNetworkLoadBalancers                                   = "ELB Network Load Balancers"
	CheckELBSecurityGroups                                         = "ELB Security Groups"
	CheckENADriverVersionforEC2WindowsInstances                    = "ENA Driver Version for EC2 Windows Instances"
	CheckExposedAccessKeys                                         = "Exposed Access Keys"
	CheckHighUtilizationAmazonEC2Instances                         = "High Utilization Amazon EC2 Instances"
	CheckIAMAccessKeyRotation                                      = "IAM Access Key Rotation"
	CheckIAMGroup                                                  = "IAM Group"
	CheckIAMInstanceProfiles                                       = "IAM Instance Profiles"
	CheckIAMPasswordPolicy                                         = "IAM Password Policy"
	CheckIAMPolicies                                               = "IAM Policies"
	CheckIAMRoles                                                  = "IAM Roles"
	CheckIAMServerCertificates                                     = "IAM Server Certificates"
	CheckIAMUse                                                    = "IAM Use"
	CheckIAMUsers                                                  = "IAM Users"
	CheckIdleLoadBalancers                                         = "Idle Load Balancers"
	CheckKinesisShardsperRegion                                    = "Kinesis Shards per Region"
	CheckLargeNumberofEC2SecurityGroupRulesAppliedtoanInstance     = "Large Number of EC2 Security Group Rules Applied to an Instance"
	CheckLargeNumberofRulesinanEC2SecurityGroup                    = "Large Number of Rules in an EC2 Security Group"
	CheckLoadBalancerOptimization                                  = "Load Balancer Optimization"
	CheckLowUtilizationAmazonEC2Instances                          = "Low Utilization Amazon EC2 Instances"
	CheckMFAonRootAccount                                          = "MFA on Root Account"
	CheckNVMeDriverVersionforEC2WindowsInstances                   = "NVMe Driver Version for EC2 Windows Instances"
	CheckOverutilizedAmazonEBSMagneticVolumes                      = "Overutilized Amazon EBS Magnetic Volumes"
	CheckPVDriverVersionforEC2WindowsInstances                     = "PV Driver Version for EC2 Windows Instances"
	CheckRDSClusterParameterGroups                                 = "RDS Cluster Parameter Groups"
	CheckRDSClusterRoles                                           = "RDS Cluster Roles"
	CheckRDSClusters                                               = "RDS Clusters"
	CheckRDSDBInstances                                            = "RDS DB Instances"
	CheckRDSDBManualSnapshots                                      = "RDS DB Manual Snapshots"
	CheckRDSDBParameterGroups                                      = "RDS DB Parameter Groups"
	CheckRDSDBSecurityGroups                                       = "RDS DB Security Groups"
	CheckRDSEventSubscriptions                                     = "RDS Event Subscriptions"
	CheckRDSMaxAuthsperSecurityGroup                               = "RDS Max Auths per Security Group"
	CheckRDSOptionGroups                                           = "RDS Option Groups"
	CheckRDSReadReplicasperMaster                                  = "RDS Read Replicas per Master"
	CheckRDSReservedInstances                                      = "RDS Reserved Instances"
	CheckRDSSubnetGroups                                           = "RDS Subnet Groups"
	CheckRDSSubnetsperSubnetGroup                                  = "RDS Subnets per Subnet Group"
	CheckRDSTotalStorageQuota                                      = "RDS Total Storage Quota"
	CheckRoute53HostedZones                                        = "Route 53 Hosted Zones"
	CheckRoute53MaxHealthChecks                                    = "Route 53 Max Health Checks"
	CheckRoute53ReusableDelegationSets                             = "Route 53 Reusable Delegation Sets"
	CheckRoute53TrafficPolicies                                    = "Route 53 Traffic Policies"
	CheckRoute53TrafficPolicyInstances                             = "Route 53 Traffic Policy Instances"
	CheckSecurityGroupsSpecificPortsUnrestricted                   = "Security Groups - Specific Ports Unrestricted"
	CheckSecurityGroupsUnrestrictedAccess                          = "Security Groups - Unrestricted Access"
	CheckSESDailySendingQuota                                      = "SES Daily Sending Quota"
	CheckUnassociatedElasticIPAddresses                            = "Unassociated Elastic IP Addresses"
	CheckUnderutilizedAmazonEBSVolumes                             = "Underutilized Amazon EBS Volumes"
	CheckUnderutilizedAmazonRedshiftClusters                       = "Underutilized Amazon Redshift Clusters"
	CheckVPC                                                       = "VPC"
	CheckVPCElasticIPAddress                                       = "VPC Elastic IP Address"
	CheckVPCInternetGateways                                       = "VPC Internet Gateways"
	CheckVPNTunnelRedundancy                                       = "VPN Tunnel Redundancy"
)

Variables

This section is empty.

Functions

func PrintDollars

func PrintDollars(i int) string

func Table

func Table(o io.Writer, headers []string, rows [][]string)

func TableString

func TableString(headers []string, rows [][]string) string

Types

type AggregateByKey

type AggregateByKey struct {
	Key       string
	Total     int
	Resources []*string
}

type AggregateDetail

type AggregateDetail struct {
	Key string
}

func (*AggregateDetail) CSV

func (d *AggregateDetail) CSV() string

type AggregateReport

type AggregateReport struct {
	Config       *Config
	Reports      []*Report
	LimitReports map[string]*LimitReport
	CostReports  map[string]*CostReport
}

func GenerateAggregateReport

func GenerateAggregateReport(envs []*Environment, options ...Option) (*AggregateReport, error)

func (*AggregateReport) AggregatedCostSummary

func (r *AggregateReport) AggregatedCostSummary(a Aggregator) *AggregateSummary

type AggregateRow

type AggregateRow struct {
	Service, Key, Env string
	MonthlySavings    int
}

type AggregateSummary

type AggregateSummary struct {
	TotalSavings int
	// contains filtered or unexported fields
}

func (*AggregateSummary) Details

func (s *AggregateSummary) Details() []*AggregateDetail

func (*AggregateSummary) SummaryHeaders

func (s *AggregateSummary) SummaryHeaders() []string

func (*AggregateSummary) SummaryRows

func (s *AggregateSummary) SummaryRows() [][]string

type Aggregator

type Aggregator func(map[string]string) string

type Check

type Check string

type CheckType

type CheckType string
const (
	CheckTypeCost           CheckType = "CheckTypeCost"
	CheckTypeFaultTolerance CheckType = "CheckTypeFaultTolerance"
	CheckTypePerformance    CheckType = "CheckTypePerformance"
	CheckTypeSecurity       CheckType = "CheckTypeSecurity"
	CheckTypeServiceLimit   CheckType = "CheckTypeServiceLimit"
)

type Config

type Config struct {
	GetTags             bool
	HideResourceDetails bool
	Aggregator          Aggregator
	Checks              []Check
}

type CostReport

type CostReport struct {
	EC2           *EC2Report
	LoadBalancers *LoadBalancerReport
	EBS           *EBSReport
	RDS           *RDSReport
	Redshift      *RedshiftReport
	EIPs          *UnassociatedElasticIPAddressesReport
}

func (*CostReport) AggregateRows

func (r *CostReport) AggregateRows(a Aggregator) []*AggregateRow

func (*CostReport) AsciiReport

func (r *CostReport) AsciiReport() string

type CostReporter

type CostReporter interface {
	AggregateRow() *AggregateRow
	Detail() *AggregateDetail
}

type EBSAggregate

type EBSAggregate struct {
	Key                string
	Volumes            []*EBSVolume
	Size               int
	MonthlyStorageCost int
}

type EBSReport

type EBSReport struct {
	Volumes    []*EBSVolume
	Aggregated []*EBSAggregate
	Errors     []string
}

func (*EBSReport) AggregateRows

func (r *EBSReport) AggregateRows(a Aggregator) []*AggregateRow

func (*EBSReport) AsciiReport

func (r *EBSReport) AsciiReport() string

type EBSVolume

type EBSVolume struct {
	ID                 string
	Name               string
	Type               string
	Region             string
	MonthlyStorageCost int
	Size               int

	SnapshotID   string
	SnapshotName string
	SnapshotAge  string

	Tags map[string]string
}

func (*EBSVolume) AggregateRow

func (v *EBSVolume) AggregateRow(a Aggregator) *AggregateRow

type EC2Aggregate

type EC2Aggregate struct {
	Key                     string
	Instances               []*EC2Instance
	EstimatedMonthlySavings int
}

type EC2Instance

type EC2Instance struct {
	Name     string
	ID       string
	Type     string
	RegionAZ string

	EstimatedMonthlySavings int

	LowUtilizationDays  int
	Network14DayAverage string
	CPU14DayAverage     string

	Day1, Day2, Day3, Day4, Day5, Day6, Day7, Day8, Day9, Day10, Day11, Day12, Day13, Day14 string

	Tags map[string]string
}

func (*EC2Instance) AggregateRow

func (i *EC2Instance) AggregateRow(a Aggregator) *AggregateRow

type EC2Report

type EC2Report struct {
	Instances  []*EC2Instance
	Aggregated []*EC2Aggregate
	Errors     []string
}

func (*EC2Report) AggregateRows

func (r *EC2Report) AggregateRows(a Aggregator) []*AggregateRow

func (*EC2Report) AsciiReport

func (r *EC2Report) AsciiReport() string

type Environment

type Environment struct {
	Name    string
	Session *session.Session
}

type LimitReport

type LimitReport struct {
	Limits []*ServiceLimit
}

func (*LimitReport) AsciiReport

func (r *LimitReport) AsciiReport() string

func (*LimitReport) Headers

func (r *LimitReport) Headers(includeEnv ...bool) []string

func (*LimitReport) Rows

func (r *LimitReport) Rows(env ...string) [][]string

func (*LimitReport) Title

func (r *LimitReport) Title() string

type LoadBalancer

type LoadBalancer struct {
	Region                  string
	Name                    string
	Reason                  string
	EstimatedMonthlySavings int

	Tags map[string]string
}

func (*LoadBalancer) AggregateRow

func (l *LoadBalancer) AggregateRow(a Aggregator) *AggregateRow

type LoadBalancerAggregate

type LoadBalancerAggregate struct {
	Key                     string
	LoadBalancers           []*LoadBalancer
	EstimatedMonthlySavings int
}

type LoadBalancerReport

type LoadBalancerReport struct {
	LoadBalancers []*LoadBalancer
	Aggregated    []*LoadBalancerAggregate
}

func (*LoadBalancerReport) AggregateRows

func (r *LoadBalancerReport) AggregateRows(a Aggregator) []*AggregateRow

func (*LoadBalancerReport) AsciiReport

func (r *LoadBalancerReport) AsciiReport() string

type Option

type Option func(*Config)

func WithAggregationByTag

func WithAggregationByTag(t string) Option

func WithChecks

func WithChecks(checks ...Check) Option

func WithCostOptimizationChecks

func WithCostOptimizationChecks() Option

func WithCustomTagAggregator

func WithCustomTagAggregator(a Aggregator) Option

func WithFaultToleranceChecks

func WithFaultToleranceChecks() Option

func WithPerformanceChecks

func WithPerformanceChecks() Option

func WithSecurityChecks

func WithSecurityChecks() Option

func WithServiceLimitChecks

func WithServiceLimitChecks() Option

func WithoutResourceDetails

func WithoutResourceDetails() Option

type RDSAggregate

type RDSAggregate struct {
	Key                     string
	Instances               []*RDSInstance
	StorageProvisionedGB    int
	EstimatedMonthlySavings int
}

type RDSInstance

type RDSInstance struct {
	Region                  string
	Name                    string
	Type                    string
	MultiAZ                 bool
	StorageProvisionedGB    int
	DaysSinceLastConnection int
	EstimatedMonthlySavings int
	Tags                    map[string]string
}

func (*RDSInstance) AggregateRow

func (i *RDSInstance) AggregateRow(a Aggregator) *AggregateRow

type RDSReport

type RDSReport struct {
	Instances  []*RDSInstance
	Aggregated []*RDSAggregate
}

func (*RDSReport) AggregateRows

func (r *RDSReport) AggregateRows(a Aggregator) []*AggregateRow

func (*RDSReport) AsciiReport

func (r *RDSReport) AsciiReport() string

type RedShiftCluster

type RedShiftCluster struct {
	Type                    string
	Reason                  string
	EstimatedMonthlySavings int
	Status                  string
	Region                  string
	Name                    string
	Tags                    map[string]string
}

func (*RedShiftCluster) AggregateRow

func (r *RedShiftCluster) AggregateRow(a Aggregator) *AggregateRow

type RedshiftAggregate

type RedshiftAggregate struct {
	Key                     string
	EstimatedMonthlySavings int
	Clusters                []*RedShiftCluster
}

type RedshiftReport

type RedshiftReport struct {
	Clusters   []*RedShiftCluster
	Aggregated []*RedshiftAggregate
}

func (*RedshiftReport) AggregateRows

func (r *RedshiftReport) AggregateRows(a Aggregator) []*AggregateRow

func (*RedshiftReport) AsciiReport

func (r *RedshiftReport) AsciiReport() string

type Report

type Report struct {
	Config *Config

	CostOptimization *CostReport
	ServiceLimits    *LimitReport
}

func GenerateReport

func GenerateReport(sess *session.Session, options ...Option) (*Report, error)

func (*Report) AsciiReport

func (r *Report) AsciiReport() string

type ServiceLimit

type ServiceLimit struct {
	Service, Region, Status, LimitName string
	LimitAmount, CurrentUsage          int
}

type TagMap

type TagMap map[string]map[string]string

func GetEBSTags

func GetEBSTags(sess *session.Session, ids []*string) (TagMap, error)

func GetEC2Tags

func GetEC2Tags(sess *session.Session, ids []*string) (TagMap, error)

func GetLBTagsFromARNs

func GetLBTagsFromARNs(sess *session.Session, arns []*string) (TagMap, error)

func GetLBTagsFromNames

func GetLBTagsFromNames(sess *session.Session, names []*string) (TagMap, error)

func GetRDSTags

func GetRDSTags(sess *session.Session, names []*string) (TagMap, error)

func GetRedshiftTags

func GetRedshiftTags(sess *session.Session) (TagMap, error)

type TrustedAdvisorCheck

type TrustedAdvisorCheck struct {
	Name               string
	ID                 string
	Status             string
	Description        string
	Flagged, Processed int64

	// Check is used to get the high-level description of a check
	Check *support.TrustedAdvisorCheckDescription
	// Result is used to get detailed information about which resources are failing a check
	Result *support.TrustedAdvisorCheckResult
}

func ListNonOKTrustedAdvisorChecks

func ListNonOKTrustedAdvisorChecks(sess *session.Session, activeChecks map[Check]bool) ([]*TrustedAdvisorCheck, error)

ListNonOKTrustedAdvisorChecks queries Trusted Advisor and only returns checks that have a status of error or warning These are typically worth review, and opening a ticket to increase limits.

type UnassociatedElasticIPAddresses

type UnassociatedElasticIPAddresses struct {
	Region    string
	IPAddress string
}

func (*UnassociatedElasticIPAddresses) AggregateRow

type UnassociatedElasticIPAddressesReport

type UnassociatedElasticIPAddressesReport struct {
	IPs []*UnassociatedElasticIPAddresses
}

func (*UnassociatedElasticIPAddressesReport) AggregateRows

func (*UnassociatedElasticIPAddressesReport) AsciiReport

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL