diff --git a/deploy/api-gateway.tf b/deploy/api_gateway.tf similarity index 100% rename from deploy/api-gateway.tf rename to deploy/api_gateway.tf diff --git a/deploy/cloudwatch_alarms.tf b/deploy/cloudwatch_alarms.tf index 2aaadeb63c2f4e32eb39bf0f8182204e87467ea1..f3d2ce7a85b47ae63dad4f82b697be94e46b0553 100644 --- a/deploy/cloudwatch_alarms.tf +++ b/deploy/cloudwatch_alarms.tf @@ -83,4 +83,4 @@ resource "aws_lambda_permission" "with_sns" { function_name = aws_lambda_function.slack.arn principal = "sns.amazonaws.com" source_arn = data.aws_sns_topic.cloudmon.arn -} \ No newline at end of file +} diff --git a/deploy/cloudwatch_api_logs.tf b/deploy/cloudwatch_api_logs.tf index 2120e552377bca8055bd1762d3715e0865187b29..a93dc1e985fd65ce41f63fc330dd013358de8d9b 100644 --- a/deploy/cloudwatch_api_logs.tf +++ b/deploy/cloudwatch_api_logs.tf @@ -1,9 +1,11 @@ locals { API_GATEWAY_LOG_GROUP = "API-Gateway-Execution-Logs_${split("-", aws_api_gateway_stage.main.id)[1]}/${aws_api_gateway_stage.main.stage_name}" } + output "log_groupe_name" { value = local.API_GATEWAY_LOG_GROUP } + resource "aws_lambda_function" "logs" { filename = data.archive_file.lambda_logs_file.output_path function_name = "${local.prefix}-logs-apigw" @@ -59,8 +61,7 @@ data "archive_file" "lambda_logs_event_file" { } resource "aws_iam_role" "iam_for_lambda_logs" { - name = "${local.prefix}-lambda-admin-cloudwatch-logs" - + name = "${local.prefix}-lambda-admin-cloudwatch-logs" assume_role_policy = file("./templates/lambda/assume-role-policy.json") } @@ -72,4 +73,4 @@ resource "aws_iam_role_policy_attachment" "lambda_logs_FA" { resource "aws_iam_role_policy_attachment" "lambda_cloudwatch_FA" { role = aws_iam_role.iam_for_lambda_logs.name policy_arn = "arn:aws:iam::aws:policy/CloudWatchFullAccess" -} \ No newline at end of file +} diff --git a/deploy/dashboard.tf b/deploy/dashboard.tf index 5800d97a193d99aa8c29e186a55326d90522c14e..2b100c5c6197dcb641a08e5657711e5248695089 100644 --- a/deploy/dashboard.tf +++ b/deploy/dashboard.tf @@ -11,7 +11,3 @@ resource "aws_cloudwatch_dashboard" "main" { }) } - -output "dashboard_json" { - value = aws_cloudwatch_dashboard.main.dashboard_body -} diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index beb2ec4c8005312eeac94024a5e2e9b410cca052..e40688ebb268ffec3d21d3e5ddae0e648d2c226f 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.7' services: terraform: - image: hashicorp/terraform:0.14.8 + image: hashicorp/terraform:0.14.9 volumes: - .:/infra working_dir: /infra diff --git a/deploy/dynamodb.tf b/deploy/dynamodb.tf index 8af33a12f59075a9df1fd2f752850de9f045a765..66d4d049e66d14c35239cbc693ee5fcff90de329 100644 --- a/deploy/dynamodb.tf +++ b/deploy/dynamodb.tf @@ -10,6 +10,10 @@ resource "aws_dynamodb_table" "main" { type = "S" } + point_in_time_recovery { + enabled = var.dynamodb_enable_pitr + } + tags = local.common_tags lifecycle { diff --git a/deploy/lambda.tf b/deploy/lambda.tf index 46eb720343150557c3927bef2e348d25c214f479..ee4146e26ac7a657bbca6603736ad0d9d7aaa855 100644 --- a/deploy/lambda.tf +++ b/deploy/lambda.tf @@ -46,11 +46,10 @@ resource "aws_lambda_function" "index" { tags = local.common_tags } - resource "aws_iam_role" "iam_for_lambda" { - name = "${local.prefix}-lambda" - + name = "${local.prefix}-lambda" assume_role_policy = file("./templates/lambda/assume-role-policy.json") + tags = local.common_tags } # See also the following AWS managed policy: AWSLambdaBasicExecutionRole @@ -58,8 +57,7 @@ resource "aws_iam_policy" "lambda_logging" { name = "${local.prefix}-lambda_logging" path = "/" description = "IAM policy for logging from a lambda" - - policy = file("./templates/lambda/lambda-policy.json") + policy = file("./templates/lambda/lambda-policy.json") } resource "aws_iam_role_policy_attachment" "lambda_logs" { diff --git a/deploy/variables.tf b/deploy/variables.tf index ce5736bf963f6057b715085db6c9831eb4a544a5..13fa0d6466eb8c60bcfc1b3074029ccd9c9128b9 100644 --- a/deploy/variables.tf +++ b/deploy/variables.tf @@ -35,3 +35,7 @@ variable "dynamodb_read_capacity" { variable "dynamodb_write_capacity" { type = number } + +variable "dynamodb_enable_pitr" { + type = bool +} diff --git a/deploy/vars/staging.tfvars b/deploy/vars/staging.tfvars index 387fc691d73c9e4d56f68b7a59ab177885beccad..6980b79e8433ad023e3dabb12b3863ab49be3100 100644 --- a/deploy/vars/staging.tfvars +++ b/deploy/vars/staging.tfvars @@ -1,2 +1,3 @@ dynamodb_read_capacity = 5 -dynamodb_write_capacity = 5 \ No newline at end of file +dynamodb_write_capacity = 5 +dynamodb_enable_pitr = true diff --git a/deploy/xray.tf b/deploy/xray.tf index 0316034dab4213a86cb0df4683eeb654621b5c6d..b336b8615501d9eb00349bf4752fd62a42ee122e 100644 --- a/deploy/xray.tf +++ b/deploy/xray.tf @@ -2,4 +2,4 @@ resource "aws_xray_group" "main" { group_name = "${local.prefix}-group" filter_expression = "http.url CONTAINS \"${aws_api_gateway_stage.main.invoke_url}\"" tags = local.common_tags -} \ No newline at end of file +}