├── README.md
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── javatechie
│ │ └── aws
│ │ └── lambda
│ │ ├── OrderHandler.java
│ │ ├── SpringbootAwsLambdaApplication.java
│ │ ├── domain
│ │ └── Order.java
│ │ └── respository
│ │ └── OrderDao.java
└── resources
│ └── application.properties
└── test
└── java
└── com
└── javatechie
└── aws
└── lambda
└── SpringbootAwsLambdaApplicationTests.java
/README.md:
--------------------------------------------------------------------------------
1 | # springboot-aws-lambda
2 | AWS Lambda is a serverless computing service provided by Amazon to reduce the configuration of servers, OS .
3 |
4 | AWS Lambda lets you run code without provisioning or managing servers—it scales automatically and only charges for the time your code is running
5 |
6 | ## Spring Cloud Function :
7 | https://www.youtube.com/watch?v=euLs1SbYKzE&t=807s
8 |
9 |
10 | ## Dependency (Required)
11 |
12 | ```javascript
13 |
14 | org.springframework.cloud
15 | spring-cloud-function-adapter-aws
16 |
17 |
18 | com.amazonaws
19 | aws-lambda-java-events
20 | 2.0.2
21 |
22 |
23 | com.amazonaws
24 | aws-lambda-java-core
25 | 1.1.0
26 |
27 | ```
28 |
29 |
30 |
31 | ## Plugins (It will helps to downstream your jar size)
32 |
33 | ```javascript
34 |
35 |
36 | org.apache.maven.plugins
37 | maven-deploy-plugin
38 |
39 | true
40 |
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-maven-plugin
45 |
46 |
47 | org.springframework.boot.experimental
48 | spring-boot-thin-layout
49 | 1.0.17.RELEASE
50 |
51 |
52 |
53 |
54 | org.apache.maven.plugins
55 | maven-shade-plugin
56 | 3.2.4
57 |
58 | false
59 | true
60 | aws
61 |
62 |
63 |
64 | ```
65 |
66 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.3.1.RELEASE
9 |
10 |
11 | com.javatechie
12 | springboot-aws-lambda
13 | 0.0.1-SNAPSHOT
14 | springboot-aws-lambda
15 | Demo project for Spring Boot
16 |
17 |
18 | 1.8
19 | Hoxton.SR6
20 | 1.0.17.RELEASE
21 |
22 |
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-starter
27 |
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-function-adapter-aws
32 |
33 |
34 | com.amazonaws
35 | aws-lambda-java-events
36 | 2.0.2
37 |
38 |
39 | com.amazonaws
40 | aws-lambda-java-core
41 | 1.1.0
42 |
43 |
44 | org.projectlombok
45 | lombok
46 | true
47 |
48 |
49 | org.springframework.boot
50 | spring-boot-starter-test
51 | test
52 |
53 |
54 | org.junit.vintage
55 | junit-vintage-engine
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | ${spring-cloud.version}
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.apache.maven.plugins
77 | maven-deploy-plugin
78 |
79 | true
80 |
81 |
82 |
83 | org.springframework.boot
84 | spring-boot-maven-plugin
85 |
86 |
87 | org.springframework.boot.experimental
88 | spring-boot-thin-layout
89 | ${wrapper.version}
90 |
91 |
92 |
93 |
94 | org.apache.maven.plugins
95 | maven-shade-plugin
96 | 3.2.4
97 |
98 | false
99 | true
100 | aws
101 |
102 |
103 |
104 | springboot-aws-lambda
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/src/main/java/com/javatechie/aws/lambda/OrderHandler.java:
--------------------------------------------------------------------------------
1 | package com.javatechie.aws.lambda;
2 |
3 | import org.springframework.cloud.function.adapter.aws.SpringBootRequestHandler;
4 |
5 | public class OrderHandler extends SpringBootRequestHandler {
6 | }
7 |
--------------------------------------------------------------------------------
/src/main/java/com/javatechie/aws/lambda/SpringbootAwsLambdaApplication.java:
--------------------------------------------------------------------------------
1 | package com.javatechie.aws.lambda;
2 |
3 | import com.javatechie.aws.lambda.domain.Order;
4 | import com.javatechie.aws.lambda.respository.OrderDao;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.context.annotation.Bean;
9 |
10 | import java.util.List;
11 | import java.util.function.Function;
12 | import java.util.function.Supplier;
13 | import java.util.stream.Collectors;
14 |
15 | @SpringBootApplication
16 | public class SpringbootAwsLambdaApplication {
17 |
18 | @Autowired
19 | private OrderDao orderDao;
20 |
21 | @Bean
22 | public Supplier> orders() {
23 | return () -> orderDao.buildOrders();
24 | }
25 |
26 | @Bean
27 | public Function> findOrderByName() {
28 | return (input) -> orderDao.buildOrders().stream().filter(order -> order.getName().equals(input)).collect(Collectors.toList());
29 | }
30 |
31 |
32 | public static void main(String[] args) {
33 | SpringApplication.run(SpringbootAwsLambdaApplication.class, args);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/javatechie/aws/lambda/domain/Order.java:
--------------------------------------------------------------------------------
1 | package com.javatechie.aws.lambda.domain;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | @Data
8 | @AllArgsConstructor
9 | @NoArgsConstructor
10 | public class Order {
11 |
12 | private int id;
13 | private String name;
14 | private double price;
15 | private int quantity;
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/com/javatechie/aws/lambda/respository/OrderDao.java:
--------------------------------------------------------------------------------
1 | package com.javatechie.aws.lambda.respository;
2 |
3 | import com.javatechie.aws.lambda.domain.Order;
4 | import org.springframework.stereotype.Repository;
5 |
6 | import java.util.List;
7 | import java.util.stream.Collectors;
8 | import java.util.stream.Stream;
9 |
10 | @Repository
11 | public class OrderDao {
12 |
13 |
14 | public List buildOrders(){
15 | return Stream.of(
16 | new Order(101, "Mobile", 20000, 1),
17 | new Order(102, "Book", 999, 2),
18 | new Order(278, "Book", 1466, 3),
19 | new Order(953, "Jeans", 4499, 1)
20 | ).collect(Collectors.toList());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/test/java/com/javatechie/aws/lambda/SpringbootAwsLambdaApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.javatechie.aws.lambda;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class SpringbootAwsLambdaApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------