forked from classmethod/gradle-aws-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
78 lines (62 loc) · 1.8 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// -*- coding: utf-8; mode: groovy -*-
import com.amazonaws.services.lambda.model.InvocationType;
import jp.classmethod.aws.gradle.lambda.AWSLambdaDeleteFunctionTask;
import jp.classmethod.aws.gradle.lambda.AWSLambdaInvokeTask;
import jp.classmethod.aws.gradle.lambda.AWSLambdaMigrateFunctionTask;
import jp.classmethod.aws.gradle.lambda.VpcConfigWrapper
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "jp.classmethod.aws:gradle-aws-plugin:0.+"
}
}
apply plugin:'base'
apply plugin: "jp.classmethod.aws.lambda"
aws {
profileName = "default"
region = "ap-northeast-1"
}
lambda {
region = "us-east-1"
}
task zip(type: Zip) {
from "function/"
destinationDir file("build")
}
task migrateFunction(type: AWSLambdaMigrateFunctionTask, dependsOn: zip) {
functionName = "foobar"
role = "arn:aws:iam::${aws.accountId}:role/lambda-poweruser"
zipFile = zip.archivePath
handler = "DecodeBase64.handler"
runtime = "Nodejs43"
environment = [
TARGET: "ascii"
]
// optional publish value
publish = true
}
task migrateFunctionWithVpc(type: AWSLambdaMigrateFunctionTask, dependsOn: zip) {
functionName = "foobar"
role = "arn:aws:iam::${aws.accountId}:role/lambda-poweruser"
zipFile = zip.archivePath
handler = "DecodeBase64.handler"
runtime = "Nodejs43"
// optional VPC config
vpc = new VpcConfigWrapper()
vpc.subnetIds = ["subnet-A", "subnet-B"]
vpc.securityGroupIds = ["sg-A", "sg-B"]
}
task invokeFunction(type: AWSLambdaInvokeTask) {
functionName = "foobar"
invocationType = InvocationType.RequestResponse
payload = file("sample-input/input.txt")
doLast {
println "Lambda function result: " + new String(invokeResult.payload.array(), "UTF-8")
}
}
task deleteFunction(type: AWSLambdaDeleteFunctionTask) {
functionName = "foobar"
}