Skip to content

Commit

Permalink
pass Lambda source file as a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Fitzwater - IDI-C committed Jun 23, 2020
1 parent 7890ea6 commit 03ed968
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lambda.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
resource "aws_lambda_function" "lambda" {
filename = local.lambda_src
filename = var.source_file
function_name = local.app_name
description = "Creates an EC2 instance and executes Ansible playbooks"
role = aws_iam_role.role.arn
handler = local.lambda_handler
source_code_hash = filesha256(local.lambda_src)
source_code_hash = filesha256(var.source_file)
kms_key_arn = aws_kms_key.kms.arn
reserved_concurrent_executions = 1
runtime = "go1.x"
Expand Down Expand Up @@ -38,4 +38,4 @@ resource "aws_lambda_permission" "cloudwatch_invoke" {
function_name = aws_lambda_function.lambda.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.schedule.arn
}
}
3 changes: 1 addition & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ data "aws_caller_identity" "current" {}
locals {
app_name = "${var.project}-${var.appenv}-ansible-lambda"
account_id = data.aws_caller_identity.current.account_id
lambda_src = "release/grace-ansible-lambda.zip"
lambda_handler = "grace-ansible-lambda"
}
}
10 changes: 8 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ variable "schedule_expression" {
default = "rate(60 minutes)"
}

variable "source_file" {
type = string
description = "(optional) full or relative path to zipped binary of lambda handler"
default = "../release/grace-ansible-lambda.zip"
}

# TODO: uncomment when aws_iam_policy_document.kms supports dynamic updates
#
#
# variable "config_role_arn" {
# type = string
# description = "(optional) The Role Arn used by the AWS Config service"
# value = ""
# }
# }

0 comments on commit 03ed968

Please sign in to comment.