-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
415b259
commit f2a5847
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# bootstrap-go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type SampleHandler<EVENT extends { n1: number; n2: number }> = `Received ${EVENT["n1"]} and ${EVENT["n2"]}!` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
locals { | ||
# Type Level Runtime | ||
runtime_name = "tlrt" | ||
} | ||
|
||
resource "aws_lambda_function" "sample" { | ||
function_name = "${local.runtime_name}-sample" | ||
role = aws_iam_role.sample.arn | ||
|
||
runtime = "provided.al2023" | ||
handler = "${local.runtime_name}_sample_index.SampleHandler" | ||
filename = "${path.module}/index.zip" | ||
|
||
layers = [ | ||
aws_lambda_layer_version.tlrt.arn, | ||
] | ||
|
||
timeout = 600 | ||
} | ||
|
||
resource "aws_iam_role" "sample" { | ||
assume_role_policy = data.aws_iam_policy_document.assume_role.json | ||
} | ||
|
||
data "archive_file" "sample" { | ||
type = "zip" | ||
source_file = "${path.module}/${local.runtime_name}_sample_index.ts" | ||
output_path = "/tmp/index.zip" | ||
} | ||
|
||
data "aws_iam_policy_document" "assume_role" { | ||
statement { | ||
effect = "Allow" | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["lambda.amazonaws.com"] | ||
} | ||
|
||
actions = ["sts:AssumeRole"] | ||
} | ||
} | ||
|
||
data "aws_iam_policy_document" "logging" { | ||
statement { | ||
effect = "Allow" | ||
|
||
actions = [ | ||
"logs:CreateLogGroup", | ||
"logs:CreateLogStream", | ||
"logs:PutLogEvents", | ||
] | ||
|
||
resources = ["arn:aws:logs:*:*:*"] | ||
} | ||
} | ||
|
||
resource "aws_iam_role_policy" "logging" { | ||
role = aws_iam_role.sample.id | ||
policy = data.aws_iam_policy_document.logging.json | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# How to use TLRT | ||
|
||
1. Copy files to your project | ||
|
||
You must copy at least the following files to your project: | ||
- aws_lambda_layer.tf | ||
- runtime | ||
|
||
aws_lambda_layer.tf and runtime must be located in the same directory. | ||
|
||
If you want to try an example, you can copy the following files: | ||
- tlrt_sample_index.ts | ||
- tlrt_sample_lambda.tf | ||
|
||
These files also must be located in the same directory. | ||
|
||
```shell | ||
Your-Terraform-Project | ||
├── aws_lambda_layer.tf | ||
├── runtime | ||
│ ├── bootstrap | ||
│ ├── node | ||
│ └── index.js | ||
├── tlrt_sample_index.ts (Optional) | ||
└── tlrt_sample_lambda.tf (Optional) | ||
``` | ||
|
||
```shell | ||
terraform apply | ||
|
||
aws lambda invoke --function-name tlrt-sample --payload '{"n1": 1, "n2": 2}' --cli-binary-format raw-in-base64-out /tmp/res.json && cat /tmp/res.json | ||
``` | ||
|
||
# TLRT Components | ||
|
||
1. bootstrap | ||
|
||
2. runtime | ||
1. bootstrap | ||
2. node | ||
3. index.js |