Java Code Examples for com.amazonaws.services.lambda.AWSLambda#listFunctions()
The following examples show how to use
com.amazonaws.services.lambda.AWSLambda#listFunctions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListFunctions.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // snippet-start:[lambda.java1.list.main] ListFunctionsResult functionResult = null; try { AWSLambda awsLambda = AWSLambdaClientBuilder.standard() .withCredentials(new ProfileCredentialsProvider()) .withRegion(Regions.US_WEST_2).build(); functionResult = awsLambda.listFunctions(); List<FunctionConfiguration> list = functionResult.getFunctions(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { FunctionConfiguration config = (FunctionConfiguration)iter.next(); System.out.println("The function name is "+config.getFunctionName()); } } catch (ServiceException e) { System.out.println(e); } // snippet-end:[lambda.java1.list.main] }
Example 2
Source File: InventoryUtil.java From pacbot with Apache License 2.0 | 4 votes |
/** * Fetch lambda info. * * @param temporaryCredentials the temporary credentials * @param skipRegions the skip regions * @param accountId the accountId * @param accountName the account name * @return the map */ public static Map<String,List<LambdaVH>> fetchLambdaInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){ Map<String,List<LambdaVH>> functions = new LinkedHashMap<>(); String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Lambda\" , \"region\":\"" ; for(Region region : RegionUtils.getRegions()){ try{ if(!skipRegions.contains(region.getName())){ AWSLambda lamdaClient = AWSLambdaClientBuilder.standard(). withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build(); ListFunctionsResult listFnRslt ; List<FunctionConfiguration> functionsTemp ; List<LambdaVH> lambdaList = new ArrayList<>(); String nextMarker = null; do{ listFnRslt = lamdaClient.listFunctions(new ListFunctionsRequest().withMarker(nextMarker)); functionsTemp = listFnRslt.getFunctions(); if( !functionsTemp.isEmpty() ) { functionsTemp.forEach( function -> { Map<String,String> tags = lamdaClient.listTags(new ListTagsRequest().withResource(function.getFunctionArn())).getTags(); LambdaVH lambda = new LambdaVH(function, tags); lambdaList.add(lambda); }); } nextMarker = listFnRslt.getNextMarker(); }while(nextMarker!=null); if( !lambdaList.isEmpty() ) { log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Lambda " +region.getName() + " >> "+lambdaList.size()); functions.put(accountId+delimiter+accountName+delimiter+region.getName(),lambdaList); } } }catch(Exception e){ if(region.isServiceSupported(AWSLambda.ENDPOINT_PREFIX)){ log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,region.getName(),"lambda",e.getMessage()); } } } return functions ; }