Skip to content

Commit b2e3126

Browse files
committed
use sandpiper infra
Signed-off-by: matto <muhamadto@gmail.com>
1 parent 0b97b1f commit b2e3126

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ $ ./mvnw -ntp clean verify -U
4343
```
4444
The service responds
4545
```json
46-
[
47-
{
48-
"name": "CoffeeBeans",
49-
"saved": true
50-
}
51-
]
46+
{
47+
"id": "production1234someapp",
48+
"env": "production",
49+
"costCentre": "1234",
50+
"applicationName": "some-app",
51+
"items": {
52+
"GITHUB_TOKEN": "WOAH",
53+
"AWS_ACCESS_KEY_ID": "OMG",
54+
"AWS_SECRET_ACCESS_KEY": "OH NO"
55+
}
56+
}
5257
```
5358

5459
#### Using `mvnw`
@@ -81,16 +86,6 @@ $ ./mvnw -ntp clean verify -U
8186
"body": "{ \"env\": \"production\", \"costCentre\": \"1234\", \"applicationName\": \"some-app\", \"items\": { \"GITHUB_TOKEN\": \"WOAH\", \"AWS_ACCESS_KEY_ID\": \"OMG\", \"AWS_SECRET_ACCESS_KEY\": \"OH NO\" } }"
8287
}'
8388
```
84-
```shell
85-
curl --location --request POST 'http://localhost:8080' \
86-
--header 'Content-Type: application/json' \
87-
--data-raw '{
88-
"httpMethod": "GET",
89-
"pathParameters": {
90-
"proxy": "production-1234-someapp"
91-
}
92-
}'
93-
```
9489

9590
The service responds
9691
```json
@@ -451,7 +446,10 @@ Now that the setup is done you can deploy to AWS.
451446
the [github action](.github/workflows/release.yml) will start and a deployment to AWS
452447
environment.
453448
2. Test via curl
454-
```shell
449+
450+
POST
451+
452+
```shell
455453
$ curl --location --request POST 'https://lmk0qo0xrl.execute-api.ap-southeast-2.amazonaws.com/dev/' \
456454
--header 'Content-Type: application/json' \
457455
--data-raw '{
@@ -464,6 +462,19 @@ Now that the setup is done you can deploy to AWS.
464462
"AWS_SECRET_ACCESS_KEY": "OH NO"
465463
}
466464
}'
467-
```
465+
```
466+
467+
GET
468+
469+
```shell
470+
curl --location --request POST 'http://localhost:8080' \
471+
--header 'Content-Type: application/json' \
472+
--data-raw '{
473+
"httpMethod": "GET",
474+
"pathParameters": {
475+
"proxy": "production-1234-someapp"
476+
}
477+
}'
478+
```
468479
3. Et voila! It runs with 500 ms for cold start.
469480

cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"app": "./mvnw --settings /Users/muhammad/.m2/settings-nonqantas.xml exec:java -pl spring-native-aws-service-infra -Dexec.mainClass=com.coffeebeans.springnativeawslambda.infra.Application",
2+
"app": "./mvnw exec:java -pl spring-native-aws-service-infra -Dexec.mainClass=com.coffeebeans.springnativeawslambda.infra.Application",
33
"context": {
44
"@aws-cdk/core:bootstrapQualifier": "cbcore"
55
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ services:
4949
'
5050
function package_spring_native_function() {
5151
if [ "$$BUILD_ARTIFACT" = "true" ]; then
52-
./mvnw -ntp clean -Pnative -DskipTests native:compile package -pl "$$FUNCTION_NAME" --settings /home/worker/.m2/settings-nonqantas.xml
52+
./mvnw -ntp clean -Pnative -DskipTests native:compile package -pl "$$FUNCTION_NAME"
5353
else
5454
print_info_message "plain" "BUILD_ARTIFACT environment variable is not set. Skipping Maven build."
5555
fi

spring-native-aws-service-infra/src/main/java/com/coffeebeans/springnativeawslambda/infra/SpringNativeAwsFunctionStack.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@
2121
import io.sadpipers.cdk.type.KebabCaseString;
2222
import io.sadpipers.cdk.type.SafeString;
2323
import io.sandpipers.cdk.core.AbstractEnvironment;
24+
import io.sandpipers.cdk.core.construct.BaseStack;
2425
import io.sandpipers.cdk.core.construct.dynamodb.TableV2;
2526
import io.sandpipers.cdk.core.construct.dynamodb.TableV2.TableProps;
2627
import io.sandpipers.cdk.core.construct.lambda.CustomRuntime2023Function;
2728
import io.sandpipers.cdk.core.construct.lambda.CustomRuntime2023Function.CustomRuntime2023FunctionProps;
2829
import org.apache.commons.lang3.StringUtils;
2930
import org.jetbrains.annotations.NotNull;
30-
import software.amazon.awscdk.DefaultStackSynthesizer;
3131
import software.amazon.awscdk.Duration;
3232
import software.amazon.awscdk.RemovalPolicy;
33-
import software.amazon.awscdk.Stack;
34-
import software.amazon.awscdk.StackProps;
3533
import software.amazon.awscdk.services.apigateway.LambdaRestApi;
3634
import software.amazon.awscdk.services.apigateway.Resource;
3735
import software.amazon.awscdk.services.apigateway.StageOptions;
@@ -51,7 +49,7 @@
5149
import static software.amazon.awscdk.services.iam.ManagedPolicy.fromAwsManagedPolicyName;
5250
import static software.amazon.awscdk.services.lambda.Code.fromAsset;
5351

54-
public class SpringNativeAwsFunctionStack extends Stack {
52+
public class SpringNativeAwsFunctionStack extends BaseStack {
5553

5654
private static final int LAMBDA_FUNCTION_TIMEOUT_IN_SECONDS = 3;
5755
private static final int LAMBDA_FUNCTION_MEMORY_SIZE = 512;
@@ -63,8 +61,7 @@ public SpringNativeAwsFunctionStack(@NotNull final Application app,
6361
@NotNull final AbstractEnvironment environment,
6462
@NotBlank final String lambdaCodePath,
6563
@NotBlank final String stage) {
66-
super(app, "SpringNativeAwsFunctionStack",
67-
StackProps.builder().synthesizer(DefaultStackSynthesizer.Builder.create().qualifier("cbcore").build()).build());
64+
super(app, environment);
6865

6966
final List<IManagedPolicy> managedPolicies =
7067
List.of(fromAwsManagedPolicyName("service-role/AWSLambdaBasicExecutionRole"));

spring-native-aws-service/src/shell/native/bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ set -euo pipefail
2121

2222
cd ${LAMBDA_TASK_ROOT:-.}
2323

24-
./spring-native-aws-function
24+
./spring-native-aws-service

0 commit comments

Comments
 (0)