Terraform - Lambda - agent ec2 stop 추가

This commit is contained in:
dsk-minchulahn
2024-01-29 14:20:01 +09:00
parent 61149888de
commit 3c9be964a5
9 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
provider "aws" {
region = var.aws_region
}
data "archive_file" "start_lambda_function" {
type = "zip"
source_file = "./lambda_function/${var.start_lambda_function_name}.py"
output_path = "./lambda_function/${var.start_lambda_function_name}.zip"
}
data "archive_file" "stop_lambda_function" {
type = "zip"
source_file = "./lambda_function/${var.stop_lambda_function_name}.py"
output_path = "./lambda_function/${var.stop_lambda_function_name}.zip"
}
resource "aws_lambda_function" "start_lambda_function" {
filename = "./lambda_function/${var.start_lambda_function_name}.zip"
function_name = var.start_lambda_function_name
role = var.dsk_lambda_role
handler = "${var.start_lambda_function_name}.lambda_handler"
source_code_hash = data.archive_file.start_lambda_function.output_base64sha256
runtime = "python3.9"
}
resource "aws_lambda_function" "stop_lambda_function" {
filename = "./lambda_function/${var.stop_lambda_function_name}.zip"
function_name = var.stop_lambda_function_name
role = var.dsk_lambda_role
handler = "${var.stop_lambda_function_name}.lambda_handler"
source_code_hash = data.archive_file.stop_lambda_function.output_base64sha256
runtime = "python3.9"
}
resource "aws_cloudwatch_log_group" "start_lambda_function_log_group" {
name = "/aws/lambda/${var.start_lambda_function_name}"
retention_in_days = 7
}
resource "aws_cloudwatch_log_group" "stop_lambda_function_log_group" {
name = "/aws/lambda/${var.stop_lambda_function_name}"
retention_in_days = 7
}