ec2cmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetCostDataCmd = &cobra.Command{
	Use:   "getEC2CostData",
	Short: "Get cost of EC2 services",
	Long:  `Get cost of EC2 services`,
	Run: func(cmd *cobra.Command, args []string) {
		authFlag, clientAuth, err := authenticate.SubCommandAuth(cmd)
		if err != nil {
			cmd.Help()
			return
		}
		if authFlag {
			instanceName, _ := cmd.Flags().GetString("instanceName")
			if instanceName != "" {
				getClusterCostDetail(*clientAuth)
			} else {
				log.Fatalln("instanceName not provided. Program exit")
			}
		}
	},
}
View Source
var GetCostSpikeCmd = &cobra.Command{
	Use:   "GetEC2CostSpike",
	Short: "Get ec2 cost Spike",
	Long:  `Retrieve ec2 cost spike data from AWS Cost Explorer`,
	Run: func(cmd *cobra.Command, args []string) {

		granularity, err := cmd.Flags().GetString("granularity")
		if err != nil {
			log.Fatalln("Error: in getting granularity flag value", err)
			return
		}

		startDate, err := cmd.Flags().GetString("startDate")
		if err != nil {
			log.Fatalln("Error: in getting startDate flag value", err)
			return
		}
		endDate, err := cmd.Flags().GetString("endDate")
		if err != nil {
			log.Fatalln("Error: in getting endDate flag value", err)
			return
		}

		authFlag, clientAuth, err := authenticate.SubCommandAuth(cmd)
		if err != nil {
			cmd.Help()
			return
		}

		if authFlag {

			wrapperCostSpike(*clientAuth, granularity, startDate, endDate, "Amazon Elastic Compute Cloud - Compute")

		}
	},
}
View Source
var GetEC2ConfigCmd = &cobra.Command{
	Use:   "getEC2Config",
	Short: "GetEC2Config command gets resource Arn",
	Long:  `GetEC2Config command gets resource Arn details of an AWS account`,

	Run: func(cmd *cobra.Command, args []string) {
		log.Println("Command getEC2Config started")
		authFlag, clientAuth, err := authenticate.SubCommandAuth(cmd)
		if err != nil {
			cmd.Help()
			return
		}
		if authFlag {
			instanceName, _ := cmd.Flags().GetString("instanceName")
			if instanceName != "" {
				describeInstances(instanceName, *clientAuth)
			} else {
				log.Fatalln("instanceName not provided. Program exit")
			}
		}
	},
}

Functions

func CostSpikes

func CostSpikes(costClient *costexplorer.CostExplorer, granularity string, startDateTime string, endDateTime string, service string) (string, error)

Function to do the cost comparison.

func ServiceCostDetails

func ServiceCostDetails(costClient *costexplorer.CostExplorer, granularity string, startDateTime string, endingDateTime string, service string) (string, error)

Function to get cost for a given service for given time period.

Types

This section is empty.

Jump to

Keyboard shortcuts

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