Skip to content

Commit ef426cc

Browse files
committed
Added scripts
1 parent ce80923 commit ef426cc

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99

1010
## How to try it?
1111

12-
First create a package: `mvn clean package`
12+
Just execute:
1313

14-
After that, a `zip` with our code should be in `target` folder. Let's execute `terraform init` and `terraform apply` to upload our code to AWS.
14+
* `cd terraform && terraform init && cd ..` (First time only)
15+
* `sh build_and_deploy.sh`
1516

1617
DONE. Now you can try your lambda just executing the last line of the terraform output, it should be something like this:
1718
`curl -H 'Content-Type: application/json' -X POST -d '{"name": "Josemy", "greeting":"Hello"}' https://[ACCOUNT_ID].execute-api.[REGION].amazonaws.com/beta/helloworld`

build_and_deploy.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
cd helloworldjava
4+
printf '\n\nBuilding the Java Lambda Function!\n\n'
5+
mvn clean package
6+
if [ $? -ne 0 ]; then
7+
printf '\n\nJava application build failed! No new Lambda Function will be deployed!!!\n'
8+
exit -1
9+
fi
10+
11+
printf '\n\nStarting the Terraforming!\n\n'
12+
cd terraform
13+
terraform plan -out=plan.out
14+
terraform apply plan.out

destroy.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
cd terraform
4+
terraform destroy -force
5+
rm plan.out

0 commit comments

Comments
 (0)