// awsGetVPCsHandler responds with the list of AWS VPC instances. An AWS
// Session is read from the context.
awsGetVPCsHandler responds with the list of AWS VPC instances. An AWS
Session is read from the context.
// awsGetVPCsHandler responds with the list of AWS VPC instances . An AWS // Session is read from the context .
func awsGetVPCsHandler(w http.ResponseWriter, req *http.Request, _ *Context) error {
	awsSession, err := awsSessionFromRequest(req)
	if err != nil {
		return fromAWSErr(err)
	}
	ec2svc := ec2.New(awsSession)
	vpcs, err := ec2svc.DescribeVpcs(&ec2.DescribeVpcsInput{})
	if err != nil {
		return fromAWSErr(err)
	}
	response := []labelValue{}
	for _, vpc := range vpcs.Vpcs {
		if vpc.VpcId == nil {
			continue
		}
		label := aws.StringValue(vpc.VpcId)
		for _, tag := range vpc.Tags {
			if aws.StringValue(tag.Key) == "Name" {
				label = fmt.Sprintf("%s - %s", aws.StringValue(tag.Value), label)
				break
			}
		}
		response = append(response, labelValue{label, aws.StringValue(vpc.VpcId)})
	}
	sort.Slice(response, func(i, j int) bool {
		return response[i].Label >= response[j].Label
	})
	return writeJSONResponse(w, req, http.StatusOK, response)
}
func awsGetVPCsHandler ( w http . ResponseWriter , req * http . Request , _ * Context ) error { awsSession , err := awsSessionFromRequest ( req ) if err != nil { return fromAWSErr ( err ) } ec2svc := ec2 . New ( awsSession ) vpcs , err := ec2svc . DescribeVpcs ( & ec2 . DescribeVpcsInput { } ) if err != nil { return fromAWSErr ( err ) } response := [ ] labelValue { } for _ , vpc := range vpcs . Vpcs { if vpc . VpcId == nil { continue } label := aws . StringValue ( vpc . VpcId ) for _ , tag := range vpc . Tags { if aws . StringValue ( tag . Key ) == " " { label = fmt . Sprintf ( " " , aws . StringValue ( tag . Value ) , label ) break } } response = append ( response , labelValue { label , aws . StringValue ( vpc . VpcId ) } ) } sort . Slice ( response , func ( i , j int ) bool { return response [ i ] . Label >= response [ j ] . Label } ) return writeJSONResponse ( w , req , http . StatusOK , response ) }
awsGetVPCsHandler responds with the list of AWS VPC instances.
awsGetVPCsHandler responds with the list of AWS VPC instances .