Skip to content

Commit

Permalink
feat: add lambda permission to schedule rds
Browse files Browse the repository at this point in the history
  • Loading branch information
Julen Dixneuf committed May 26, 2021
1 parent db3d543 commit 0874871
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,46 @@ resource "aws_iam_role_policy" "lambda_autoscalinggroup" {
policy = data.aws_iam_policy_document.lambda_autoscalinggroup.json
}

data "aws_iam_policy_document" "lambda_tagging_api" {
statement {
actions = [
"tag:GetResources",
]

resources = [
"*",
]
}
}

resource "aws_iam_role_policy" "lambda_tagging_api" {
count = var.custom_iam_lambda_role ? 0 : 1

name_prefix = "${local.name_prefix}_tagging_api"
role = aws_iam_role.lambda[0].id
policy = data.aws_iam_policy_document.lambda_tagging_api.json
}

data "aws_iam_policy_document" "lambda_rds" {
statement {
actions = [
"rds:StartDBInstance",
"rds:StopDBInstance",
]

resources = [
"*",
]
}
}

resource "aws_iam_role_policy" "lambda_rds" {
count = var.custom_iam_lambda_role ? 0 : 1

name_prefix = "${local.name_prefix}_rds"
role = aws_iam_role.lambda[0].id
policy = data.aws_iam_policy_document.lambda_rds.json
}

data "archive_file" "lambda_zip" {
type = "zip"
Expand Down

0 comments on commit 0874871

Please sign in to comment.