Skip to content

Commit

Permalink
add initial script
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Nov 22, 2023
1 parent dcde2df commit 67fca10
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
38 changes: 38 additions & 0 deletions aws-lambda-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Misc ###
*.log
.DS_Store
docker/volume/
33 changes: 33 additions & 0 deletions aws-lambda-project/.localstack/init-aws.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
#!/usr/bin/env bash

# Set the JAR file path
JAR_FILE="target/aws-lambda-project-0.0.1-SNAPSHOT-aws.jar"

# Check if the JAR file exists
if [ -f "$JAR_FILE" ]; then
# Zip the JAR file
zip -j function.zip "$JAR_FILE"

# Create Lambda function
awslocal lambda create-function \
--function-name localstack-lambda-url-example \
--runtime java17 \
--zip-file fileb://function.zip \
--handler org.springframework.cloud.function.adapter.aws.FunctionInvoker::handleRequest \
--role arn:aws:iam::000000000000:role/lambda-role

echo "created lambda function"

awslocal lambda create-function-url-config \
--function-name localstack-lambda-url-example \
--auth-type NONE

echo "created function URL"

awslocal lambda invoke --function-name localstack-lambda-url-example \
--cli-binary-format raw-in-base64-out \
--payload '{"body": "{\"name\": \"profile\"}" }' output.txt

echo "invoked lambda function"
else
echo "Error: JAR file not found at $JAR_FILE"
fi

0 comments on commit 67fca10

Please sign in to comment.