Java 类com.amazonaws.services.lambda.model.CreateFunctionResult 实例源码

项目:java-translatebot    文件:OauthHandlerDeployer.java   
private CreateFunctionResult createFunction() {

        final String executionRole = initExecutionRole();
        final FunctionCode fcod = loadCode();

        final CreateFunctionRequest cfrq = new CreateFunctionRequest().withCode(fcod)
                .withDescription("Translator Slack event handler")
                .withFunctionName(FunctionName)
                .withHandler(HandlerSpec)
                .withMemorySize(256)
                .withPublish(true)
                .withRole(executionRole)
                .withRuntime(Runtime.Java8);

        return this.awsLambdaClient.createFunction(cfrq);

    }
项目:java-translatebot    文件:EventHandlerDeployer.java   
private CreateFunctionResult createFunction() {

        final String executionRole = initExecutionRole();
        final FunctionCode fcod = loadCode();

        final CreateFunctionRequest cfrq = new CreateFunctionRequest().withCode(fcod)
                .withDescription("Translator Slack event handler")
                .withFunctionName(FunctionName)
                .withHandler("com.banjocreek.translatebot.EventHandler::handle")
                .withMemorySize(1024)
                .withTimeout(30)
                .withPublish(true)
                .withRole(executionRole)
                .withRuntime(Runtime.Java8);

        return this.awsLambdaClient.createFunction(cfrq);

    }
项目:java-translatebot    文件:CommandHandlerDeployer.java   
private CreateFunctionResult createFunction() {

        final String executionRole = initExecutionRole();
        final FunctionCode fcod = loadCode();

        final CreateFunctionRequest cfrq = new CreateFunctionRequest().withCode(fcod)
                .withDescription("Translator Slack event handler")
                .withFunctionName(FunctionName)
                .withHandler(EntryPoint)
                .withMemorySize(1024)
                .withTimeout(30)
                .withPublish(true)
                .withRole(executionRole)
                .withRuntime(Runtime.Java8);

        return this.awsLambdaClient.createFunction(cfrq);

    }
项目:aws-lambda-deploy    文件:AWSLambdaDeployer.java   
private String createLambda(AWSLambdaClient lambdaClient, String handler,
        String name, String description) {
    CreateFunctionRequest request = new CreateFunctionRequest();
    request.setCode(buildFunctionCode());
    request.setDescription(description);
    request.setFunctionName(name);
    request.setHandler(handler);
    request.setMemorySize(memory);
    request.setPublish(true);
    // assume or create a role?
    request.setRole(lambdaRoleARN);
    request.setRuntime("java8");
    request.setTimeout(handlerTimeout);

    CreateFunctionResult result = lambdaClient.createFunction(request);

    return result.getFunctionArn();
}
项目:java-translatebot    文件:OauthHandlerDeployer.java   
private String iarn(final CreateFunctionResult function) {
    final String rval = this.awsLambdaClient.listFunctions()
            .getFunctions()
            .stream()
            .filter(f -> f.getFunctionName().equals(function.getFunctionName()))
            .findAny()
            .map(f -> f.getFunctionArn())
            .map(farn -> "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/" + farn + "/invocations")
            .get();
    System.out.println("farn: " + rval);
    return rval;
}
项目:java-translatebot    文件:OauthHandlerDeployer.java   
private void permitInvokeLambda(final String accountId, final CreateRestApiResult createApiResult,
        final CreateFunctionResult function) {
    final String sourceArn = "arn:aws:execute-api:us-east-1:" + accountId + ":" + createApiResult.getId() + "/*/"
            + HttpMethod + "/" + Path;
    System.out.println(sourceArn);

    // allow api to invoke lambda function
    final AddPermissionRequest aprq = new AddPermissionRequest().withFunctionName(function.getFunctionName())
            .withAction("lambda:InvokeFunction")
            .withPrincipal("apigateway.amazonaws.com")
            .withStatementId("sid" + Math.abs(rng.nextLong()))
            .withSourceArn(sourceArn);
    this.awsLambdaClient.addPermission(aprq);

}
项目:java-translatebot    文件:EventHandlerDeployer.java   
private String iarn(final CreateFunctionResult function) {
    final String rval = this.awsLambdaClient.listFunctions()
            .getFunctions()
            .stream()
            .filter(f -> f.getFunctionName().equals(function.getFunctionName()))
            .findAny()
            .map(f -> f.getFunctionArn())
            .map(farn -> "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/" + farn + "/invocations")
            .get();
    System.out.println("farn: " + rval);
    return rval;
}
项目:java-translatebot    文件:EventHandlerDeployer.java   
private void permitInvokeLambda(final String accountId, final CreateRestApiResult createApiResult,
        final CreateFunctionResult function) {
    final String sourceArn = "arn:aws:execute-api:us-east-1:" + accountId + ":" + createApiResult.getId()
            + "/*/POST/" + Path;
    System.out.println(sourceArn);

    // allow api to invoke lambda function
    final AddPermissionRequest aprq = new AddPermissionRequest().withFunctionName(function.getFunctionName())
            .withAction("lambda:InvokeFunction")
            .withPrincipal("apigateway.amazonaws.com")
            .withStatementId("sid" + Math.abs(rng.nextLong()))
            .withSourceArn(sourceArn);
    this.awsLambdaClient.addPermission(aprq);

}
项目:java-translatebot    文件:CommandHandlerDeployer.java   
private String iarn(final CreateFunctionResult function) {
    final String rval = this.awsLambdaClient.listFunctions()
            .getFunctions()
            .stream()
            .filter(f -> f.getFunctionName().equals(function.getFunctionName()))
            .findAny()
            .map(f -> f.getFunctionArn())
            .map(farn -> "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/" + farn + "/invocations")
            .get();
    System.out.println("farn: " + rval);
    return rval;
}
项目:java-translatebot    文件:CommandHandlerDeployer.java   
private void permitInvokeLambda(final String accountId, final CreateRestApiResult createApiResult,
        final CreateFunctionResult function) {
    final String sourceArn = "arn:aws:execute-api:us-east-1:" + accountId + ":" + createApiResult.getId()
            + "/*/POST/" + Path;
    System.out.println(sourceArn);

    // allow api to invoke lambda function
    final AddPermissionRequest aprq = new AddPermissionRequest().withFunctionName(function.getFunctionName())
            .withAction("lambda:InvokeFunction")
            .withPrincipal("apigateway.amazonaws.com")
            .withStatementId("sid" + Math.abs(rng.nextLong()))
            .withSourceArn(sourceArn);
    this.awsLambdaClient.addPermission(aprq);

}
项目:aws-lambda-jenkins-plugin    文件:LambdaDeployServiceTest.java   
@Before
public void setUp() throws Exception {
    description = "description";
    functionName = "function";
    handler = "function.handler";
    memory = 1024;
    role = "role";
    runtime = "nodejs";
    publish = Boolean.FALSE;
    functionVersion = null;
    createAlias = Boolean.FALSE;
    alias = null;
    timeout = 30;
    subnets = new ArrayList<>();
    securityGroups = new ArrayList<>();
    kmsArn = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012";
    environment = new HashMap<>();
    environment.put("key", "value");
    deadLetterQueueArn = "arn:aws:sqs:us-east-1:123456789012:queueName";
    lambdaDeployService = new LambdaDeployService(awsLambdaClient, jenkinsLogger);
    when(awsLambdaClient.updateFunctionConfiguration(any(UpdateFunctionConfigurationRequest.class)))
            .thenReturn(new UpdateFunctionConfigurationResult());
    when(awsLambdaClient.updateFunctionCode(any(UpdateFunctionCodeRequest.class)))
            .thenReturn(new UpdateFunctionCodeResult());
    when(awsLambdaClient.createFunction(any(CreateFunctionRequest.class)))
            .thenReturn(new CreateFunctionResult());
}
项目:aws-lambda-jenkins-plugin    文件:LambdaDeployServiceTest.java   
private void setPublishVersion(String version){
    this.functionVersion = version;
    this.publish = true;
    CreateFunctionResult createFunctionResult = new CreateFunctionResult()
            .withVersion(version);
    when(awsLambdaClient.createFunction(any(CreateFunctionRequest.class)))
            .thenReturn(createFunctionResult);
    UpdateFunctionCodeResult updateFunctionCodeResult = new UpdateFunctionCodeResult()
            .withVersion(version);
    when(awsLambdaClient.updateFunctionCode(any(UpdateFunctionCodeRequest.class)))
            .thenReturn(updateFunctionCodeResult);
}
项目:java-translatebot    文件:OauthHandlerDeployer.java   
private void createApi(final CreateFunctionResult function) {

        final CreateRestApiResult createApiResult = createApi();
        final CreateResourceResult crrs = createResource(createApiResult);

        final String iarn = iarn(function);

        createMethod(createApiResult, crrs, iarn);

        stageApi(createApiResult);

        final String accountId = accountId(iarn);

        permitInvokeLambda(accountId, createApiResult, function);

    }
项目:java-translatebot    文件:EventHandlerDeployer.java   
private void createApi(final CreateFunctionResult function) {

        final CreateRestApiResult createApiResult = createApi();
        final CreateResourceResult crrs = createResource(createApiResult);
        createPostMethod(createApiResult, crrs);

        final String iarn = iarn(function);

        integratePostMethod(createApiResult, crrs, iarn);
        stageApi(createApiResult);

        final String accountId = accountId(iarn);

        permitInvokeLambda(accountId, createApiResult, function);

    }
项目:java-translatebot    文件:CommandHandlerDeployer.java   
private void createApi(final CreateFunctionResult function) {

        final CreateRestApiResult createApiResult = createApi();
        final CreateResourceResult crrs = createResource(createApiResult);
        createPostMethod(createApiResult, crrs);

        final String iarn = iarn(function);

        integratePostMethod(createApiResult, crrs, iarn);
        stageApi(createApiResult);

        final String accountId = accountId(iarn);

        permitInvokeLambda(accountId, createApiResult, function);

    }
项目:java-translatebot    文件:OauthHandlerDeployer.java   
public void deploy() {

        final CreateFunctionResult function = createFunction();

        createApi(function);

    }
项目:java-translatebot    文件:EventHandlerDeployer.java   
public void deploy() {

        final CreateFunctionResult function = createFunction();

        createApi(function);

    }
项目:java-translatebot    文件:CommandHandlerDeployer.java   
public void deploy() {

        final CreateFunctionResult function = createFunction();

        createApi(function);

    }