software.amazon.awssdk.services.lambda.model.FunctionConfiguration Java Examples
The following examples show how to use
software.amazon.awssdk.services.lambda.model.FunctionConfiguration.
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: ListLambdaFunctions.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // snippet-start:[lambda.java2.list.main] ListFunctionsResponse functionResult = null ; try { Region region = Region.US_WEST_2; LambdaClient awsLambda = LambdaClient.builder().region(region).build(); //Get a list of all functions functionResult = awsLambda.listFunctions(); List<FunctionConfiguration> list = functionResult.functions(); for (Iterator iter = list.iterator(); iter.hasNext(); ) { FunctionConfiguration config = (FunctionConfiguration)iter.next(); System.out.println("The function name is "+config.functionName()); } } catch(ServiceException e) { e.getStackTrace(); } // snippet-end:[lambda.java2.list.main] }
Example #2
Source File: AwsLambdaScanner.java From clouditor with Apache License 2.0 | 5 votes |
@Override protected Asset transform(FunctionConfiguration function) throws ScanException { var asset = super.transform(function); enrichSimple( asset, "policy", this.api::getPolicy, GetPolicyResponse::policy, GetPolicyRequest.builder().functionName(function.functionName()).build()); return asset; }
Example #3
Source File: AwsLambdaScannerTest.java From clouditor with Apache License 2.0 | 5 votes |
@BeforeAll static void setUpOnce() { discoverAssets( LambdaClient.class, AwsLambdaScanner::new, api -> { when(api.listFunctions()) .thenReturn( ListFunctionsResponse.builder() .functions( FunctionConfiguration.builder() .functionArn( "arn:aws:lambda:eu-central-1:123456789:function:function-1") .functionName("function-1") .kmsKeyArn("some-key") .build(), FunctionConfiguration.builder() .functionArn( "arn:aws:lambda:eu-central-1:123456789:function:function-2") .functionName("function-2") .build()) .build()); when(api.getPolicy(GetPolicyRequest.builder().functionName("function-1").build())) .thenReturn(GetPolicyResponse.builder().policy("*").build()); when(api.getPolicy(GetPolicyRequest.builder().functionName("function-2").build())) .thenReturn(GetPolicyResponse.builder().policy("no-wildcard").build()); }); }
Example #4
Source File: ServiceIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private static void checkValid_GetFunctionResponse(GetFunctionResponse result) { Assert.assertNotNull(result); Assert.assertNotNull(result.code()); Assert.assertNotNull(result.code().location()); Assert.assertNotNull(result.code().repositoryType()); FunctionConfiguration config = result.configuration(); checkValid_FunctionConfiguration(config); }
Example #5
Source File: ServiceIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private static void checkValid_FunctionConfiguration(FunctionConfiguration config) { Assert.assertNotNull(config); Assert.assertNotNull(config.codeSize()); Assert.assertNotNull(config.description()); Assert.assertNotNull(config.functionArn()); Assert.assertNotNull(config.functionName()); Assert.assertNotNull(config.handler()); Assert.assertNotNull(config.lastModified()); Assert.assertNotNull(config.memorySize()); Assert.assertNotNull(config.role()); Assert.assertNotNull(config.runtime()); Assert.assertNotNull(config.timeout()); }
Example #6
Source File: ServiceIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Test public void testFunctionOperations() throws IOException { // Get function GetFunctionResponse getFunc = lambda.getFunction(r -> r.functionName(FUNCTION_NAME)).join(); checkValid_GetFunctionResponse(getFunc); // Get function configuration GetFunctionConfigurationResponse getConfig = lambda.getFunctionConfiguration(r -> r.functionName(FUNCTION_NAME)).join(); checkValid_GetFunctionConfigurationResponse(getConfig); // List functions ListFunctionsResponse listFunc = lambda.listFunctions(ListFunctionsRequest.builder().build()).join(); Assert.assertFalse(listFunc.functions().isEmpty()); for (FunctionConfiguration funcConfig : listFunc.functions()) { checkValid_FunctionConfiguration(funcConfig); } // Invoke the function InvokeResponse invokeResult = lambda.invoke(InvokeRequest.builder().functionName(FUNCTION_NAME) .invocationType(InvocationType.EVENT).payload(SdkBytes.fromUtf8String("{}")).build()).join(); Assert.assertEquals(202, invokeResult.statusCode().intValue()); Assert.assertNull(invokeResult.logResult()); Assert.assertEquals(0, invokeResult.payload().asByteBuffer().remaining()); invokeResult = lambda.invoke(InvokeRequest.builder().functionName(FUNCTION_NAME) .invocationType(InvocationType.REQUEST_RESPONSE).logType(LogType.TAIL) .payload(SdkBytes.fromUtf8String("{}")).build()).join(); Assert.assertEquals(200, invokeResult.statusCode().intValue()); System.out.println(new String(BinaryUtils.fromBase64(invokeResult.logResult()), StandardCharsets.UTF_8)); Assert.assertEquals("\"Hello World\"", invokeResult.payload().asUtf8String()); }
Example #7
Source File: AwsLambdaScanner.java From clouditor with Apache License 2.0 | 4 votes |
public AwsLambdaScanner() { super( LambdaClient::builder, FunctionConfiguration::functionArn, FunctionConfiguration::functionName); }
Example #8
Source File: AwsLambdaScanner.java From clouditor with Apache License 2.0 | 4 votes |
@Override protected List<FunctionConfiguration> list() { return this.api.listFunctions().functions(); }