Terraform - Lambda - agent ec2 stop 추가
This commit is contained in:
43
terraform/lambda/dsk-agent-ec2/main.tf
Normal file
43
terraform/lambda/dsk-agent-ec2/main.tf
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user