File tree Expand file tree Collapse file tree 5 files changed +11
-8
lines changed
Expand file tree Collapse file tree 5 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1- FROM amazonlinux:latest
1+ FROM amazonlinux:2.0.20230727.0
22
33RUN yum install -y tar xz gzip gcc
44
5- RUN curl -L -o golang.tar.gz https://go.dev/dl/go1.20.7 .linux-amd64.tar.gz
5+ RUN curl -L -o golang.tar.gz https://go.dev/dl/go1.21.0 .linux-amd64.tar.gz
66
7- RUN rm -rf /usr/local/go && tar -C /usr/local -xzf golang.tar.gz
7+ RUN rm -rf /usr/local/go && tar -C /usr/local -xzf golang.tar.gz
88
99WORKDIR /project
1010
1111COPY go.mod go.sum ./
12-
1312RUN /usr/local/go/bin/go mod download -x
1413
14+ RUN /usr/local/go/bin/go install github.com/mattn/go-sqlite3
1515ENV PATH="${PATH}:/usr/local/go/bin"
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ This repository contains example lambda handler integration with API gateway. Te
1515## Setup (optional)
1616
1717### Docker
18+
1819Although not require specifically to run go in lambdas, can be useful to avoid compatibility issues
1920when using cgo bindings or third party libraries using cgo such as sqlite3.
2021
Original file line number Diff line number Diff line change 11module github.com/JayJamieson/go-lambda
22
3- go 1.20
3+ go 1.21
44
55require github.com/aws/aws-lambda-go v1.41.0
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ resource "aws_lambda_permission" "api_gateway_lambda" {
5454 action = " lambda:InvokeFunction"
5555 function_name = aws_lambda_function. go_lambda . function_name
5656 principal = " apigateway.amazonaws.com"
57- source_arn = " arn:aws:execute-api:ap-southeast-2:834849242330 :${ aws_api_gateway_rest_api . lambda_api . id } /*"
57+ source_arn = " arn:aws:execute-api:${ var . region } : ${ data . aws_caller_identity . current . account_id } :${ aws_api_gateway_rest_api . lambda_api . id } /*"
5858}
5959
6060resource "aws_api_gateway_usage_plan" "lambda_api_usage" {
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ provider "aws" {
1111 region = var. region
1212}
1313
14+ data "aws_caller_identity" "current" {}
15+
1416data "archive_file" "lambda" {
1517 type = " zip"
1618 source_file = " bootstrap"
@@ -59,7 +61,7 @@ resource "aws_iam_policy" "lambda_execution_policy" {
5961 Action = [" logs:CreateLogGroup" ]
6062 Effect = " Allow"
6163 Resource = [
62- " arn:aws:logs:ap-southeast-2:834849242330 :*"
64+ " arn:aws:logs:${ var . region } : ${ data . aws_caller_identity . current . account_id } :*"
6365 ]
6466 },
6567 {
@@ -68,7 +70,7 @@ resource "aws_iam_policy" "lambda_execution_policy" {
6870 " logs:CreateLogStream" ,
6971 " logs:PutLogEvents"
7072 ],
71- Resource = " arn:aws:logs:ap-southeast-2:834849242330 :log-group:*"
73+ Resource = " arn:aws:logs:${ var . region } : ${ data . aws_caller_identity . current . account_id } :log-group:*"
7274 }
7375 ]
7476 })
You can’t perform that action at this time.
0 commit comments