EC2

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AwsxEc2ConfigCmd = &cobra.Command{
	Use:   "getEc2Config",
	Short: "getEc2Config command gets ec2 configuration",
	Long:  `getEc2Config command gets ec2 configuration`,

	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("executing getEc2Config command")
		var authFlag, clientAuth, err = authenticate.AuthenticateCommand(cmd)
		if err != nil {
			log.Printf("error during authentication: %v\n", err)
			err := cmd.Help()
			if err != nil {
				return
			}
			return
		}
		if authFlag {
			tagName, _ := cmd.Flags().GetString("tagName")
			instanceId, _ := cmd.Flags().GetString("instanceId")
			if tagName == "" && instanceId == "" {
				log.Printf("ec2 instance-id or tag missing")
				err := cmd.Help()
				if err != nil {
					return
				}
				return
			}
			if tagName != "" {
				instances, err := GetEc2InstanceByTagName(tagName, clientAuth, nil)
				if err != nil {
					log.Println("error getting getEc2Config by tag name: ", err)
					return
				}
				fmt.Println(instances)
			}
			if instanceId != "" {
				instances, err := GetEc2InstanceById(instanceId, clientAuth, nil)
				if err != nil {
					log.Println("error getting getEc2Config by instance id: ", err)
					return
				}
				fmt.Println(instances)
			}
		}
	},
}
View Source
var AwsxEc2ListCmd = &cobra.Command{
	Use:   "getEc2List",
	Short: "getEc2List command gets list of ec2 instances of an aws account",
	Long:  `getEc2List command gets list of ec2 instances of an aws account`,

	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("executing getEc2List command")
		var authFlag, clientAuth, err = authenticate.AuthenticateCommand(cmd)
		if err != nil {
			log.Printf("error during authentication: %v\n", err)
			err := cmd.Help()
			if err != nil {
				return
			}
			return
		}
		if authFlag {
			resp, err := ListEc2Instances(clientAuth, nil)
			if err != nil {
				log.Println("error getting getEc2List: ", err)
				return
			}
			fmt.Println(resp)
		}
	},
}

Functions

func GetEc2InstanceById

func GetEc2InstanceById(instanceId string, clientAuth *model.Auth, client *ec2.EC2) (*ec2.DescribeInstancesOutput, error)

func GetEc2InstanceByTagName

func GetEc2InstanceByTagName(tagName string, clientAuth *model.Auth, ec2Client *ec2.EC2) (*ec2.DescribeInstancesOutput, error)

func ListEc2Instances

func ListEc2Instances(clientAuth *model.Auth, client *ec2.EC2) (*ec2.DescribeInstancesOutput, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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