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
resource "aws_iam_role" "lambda_execution_role" { | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, |
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
data "archive_file" "lambda_get_user_archive" { | |
type = "zip" | |
source_file = "${var.get_user_bin_path}" | |
output_path = "get_user_lambda.zip" | |
} |
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
# Input variable definitions | |
variable "aws_region" { | |
description = "AWS region for all resources." | |
type = string | |
default = "eu-west-1" | |
} | |
variable "get_user_bin_path" { |
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
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 3.48.0" | |
} | |
archive = { | |
source = "hashicorp/archive" | |
version = "~> 2.2.0" | |
} |
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
use lambda_http::{ | |
handler, | |
lambda_runtime::{self, Context, Error}, | |
IntoResponse, Request, RequestExt, Response, | |
}; | |
#[tokio::main] | |
async fn main() -> Result<(), Error> { | |
lambda_runtime::run(handler(func)).await?; | |
Ok(()) |
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
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
- name: deploy | |
run: | | |
aws lambda update-function-code --function-name=basic-function --zip-file=fileb://lambda.zip |
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
steps: | |
- uses: actions/checkout@v2 | |
- name: Add target | |
run: rustup target add x86_64-unknown-linux-musl | |
- name: Build | |
run: cargo build --release --target x86_64-unknown-linux-musl | |
- name: Create .zip file | |
run: | | |
cp target/x86_64-unknown-linux-musl/release/basic-function bootstrap | |
zip lambda.zip bootstrap |
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
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./basic-function |
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
name: Basic function pipeline | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- 'basic-function/**' | |
- '.github/workflows/basic-function-pipeline.yml' | |
env: |
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
#[tokio::main] | |
async fn main() -> Result<(), Error> { | |
let handler = lambda_runtime::handler_fn(handler); | |
lambda_runtime::run(handler).await?; | |
Ok(()) | |
} |