// awsGetKeyPairsHandler returns the list of EC2 key pairs.
awsGetKeyPairsHandler returns the list of EC2 key pairs.
// awsGetKeyPairsHandler returns the list of EC2 key pairs .
func awsGetKeyPairsHandler(w http.ResponseWriter, req *http.Request, _ *Context) error {
	awsSession, err := awsSessionFromRequest(req)
	if err != nil {
		return fromAWSErr(err)
	}
	ec2svc := ec2.New(awsSession)
	resp, err := ec2svc.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{})
	if err != nil {
		return fromAWSErr(err)
	}
	response := []labelValue{}
	for _, keypair := range resp.KeyPairs {
		response = append(response, labelValue{
			aws.StringValue(keypair.KeyName),
			aws.StringValue(keypair.KeyName),
		})
	}
	sort.Slice(response, func(i, j int) bool {
		return response[i].Label >= response[j].Label
	})
	return writeJSONResponse(w, req, http.StatusOK, response)
}
func awsGetKeyPairsHandler ( w http . ResponseWriter , req * http . Request , _ * Context ) error { awsSession , err := awsSessionFromRequest ( req ) if err != nil { return fromAWSErr ( err ) } ec2svc := ec2 . New ( awsSession ) resp , err := ec2svc . DescribeKeyPairs ( & ec2 . DescribeKeyPairsInput { } ) if err != nil { return fromAWSErr ( err ) } response := [ ] labelValue { } for _ , keypair := range resp . KeyPairs { response = append ( response , labelValue { aws . StringValue ( keypair . KeyName ) , aws . StringValue ( keypair . KeyName ) , } ) } sort . Slice ( response , func ( i , j int ) bool { return response [ i ] . Label >= response [ j ] . Label } ) return writeJSONResponse ( w , req , http . StatusOK , response ) }
awsGetKeyPairsHandler returns the list of EC2 key pairs.
awsGetKeyPairsHandler returns the list of EC2 key pairs .