-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
61 lines (48 loc) · 1.51 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
plugins {
id 'java'
}
group 'io.nuvalence'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.amazonaws', name: 'aws-lambda-java-events', version: '2.2.7'
compile group: 'com.amazonaws', name: 'aws-lambda-java-core', version: '1.1.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
version '1.0.1'
ext.s3Bucket = 'examplefunctionbucket'
def prefix = project.hasProperty("stackPrefix") ? project.property("stackPrefix") : "local"
ext.s3Prefix = "ExampleLambda/${prefix}/"
ext.stackName = "${prefix}-ExampleLambdaDeployment"
def zipName = "${project.name}-${project.version}.zip"
task buildZip(type: Zip) {
from compileJava
from processResources
archiveFileName=zipName
into('lib') {
from configurations.runtimeClasspath
}
}
task publishToS3(type: Exec) {
dependsOn buildZip
commandLine 'aws', 's3', 'cp',
'--sse', 'AES256',
buildZip.outputs.files.first().path,
"s3://${s3Bucket}/${s3Prefix}${zipName}"
}
task deployStack(type: Exec) {
dependsOn publishToS3
commandLine 'aws', 'cloudformation', 'deploy',
'--stack-name', stackName,
'--template-file', "${project.rootDir}/infrastructure/template.yml",
'--capabilities', 'CAPABILITY_NAMED_IAM',
'--parameter-overrides',
"S3Bucket=${s3Bucket}",
"S3Key=${s3Prefix}",
"ZipName=${zipName}"
doLast {
println "Stack Successfully Created."
}
}