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: Rust CRUD pipeline | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- 'rust_crud/**' | |
- '.github/workflows/rust-crud-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
import os | |
function_parent_folder = "./lambda_functions" | |
build_target = "x86_64-unknown-linux-musl" | |
output_file_name = "bootstrap" | |
print("[BUILD] Starting Rust functions building process...") | |
function_folders = [name for name in os.listdir(function_parent_folder)] |
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
# Output value definitions | |
output "invoke_url" { | |
value = aws_apigatewayv2_stage.api_stage.invoke_url | |
} |
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_apigatewayv2_deployment" "api_deployment" { | |
api_id = aws_apigatewayv2_api.users_api.id | |
description = "API deployment" | |
triggers = { | |
redeployment = sha1(join(",", [ | |
jsonencode(aws_apigatewayv2_integration.get_user_integration), | |
jsonencode(aws_apigatewayv2_route.get_user_route), | |
jsonencode(aws_apigatewayv2_integration.create_user_integration), | |
jsonencode(aws_apigatewayv2_route.create_user_route), |
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_lambda_permission" "get_user_api_permission" { | |
function_name = aws_lambda_function.get_user_lambda.function_name | |
action = "lambda:InvokeFunction" | |
principal = "apigateway.amazonaws.com" | |
source_arn = "${aws_apigatewayv2_api.users_api.execution_arn}/*/*/${split("/", aws_apigatewayv2_route.get_user_route.route_key)[1]}" | |
} |
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_apigatewayv2_route" "get_user_route" { | |
api_id = aws_apigatewayv2_api.users_api.id | |
route_key = "GET /users" | |
target = "integrations/${aws_apigatewayv2_integration.get_user_integration.id}" | |
} |
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_apigatewayv2_integration" "get_user_integration" { | |
api_id = aws_apigatewayv2_api.users_api.id | |
integration_type = "AWS_PROXY" | |
connection_type = "INTERNET" | |
description = "Get User" | |
integration_method = "POST" | |
integration_uri = aws_lambda_function.get_user_lambda.invoke_arn | |
payload_format_version = "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
resource "aws_apigatewayv2_api" "users_api" { | |
name = "API" | |
description = "Users API" | |
protocol_type = "HTTP" | |
} | |
resource "aws_apigatewayv2_stage" "api_stage" { | |
api_id = aws_apigatewayv2_api.users_api.id | |
name = "$default" | |
auto_deploy = true |
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_lambda_function" "get_user_lambda" { | |
function_name = "GetUser" | |
source_code_hash = data.archive_file.lambda_get_user_archive.output_base64sha256 | |
filename = data.archive_file.lambda_get_user_archive.output_path | |
handler = "func" | |
runtime = "provided" | |
role = aws_iam_role.lambda_execution_role.arn |
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_policy_attachment" "lambda_execution_policy" { | |
role = aws_iam_role.lambda_execution_role.name | |
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | |
} |
NewerOlder