File tree Expand file tree Collapse file tree 6 files changed +39
-4
lines changed
Expand file tree Collapse file tree 6 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 77
88 policy_arn_prefix = format (
99 " arn:%s:iam::%s:policy" ,
10- join (" " , data. aws_partition . current . * . partition ),
11- join (" " , data. aws_caller_identity . current . * . account_id ),
10+ join (" " , data. aws_partition . current [ * ] . partition ),
11+ join (" " , data. aws_caller_identity . current [ * ] . account_id ),
1212 )
1313
1414 policy_arn_inside = format (" %s/%s" , local. policy_arn_prefix , local. policy_name_inside )
@@ -77,7 +77,7 @@ resource "aws_iam_role_policy_attachment" "outside" {
7777module "lambda" {
7878 source = " ../.."
7979
80- filename = join (" " , data. archive_file . lambda_zip . * . output_path )
80+ filename = join (" " , data. archive_file . lambda_zip [ * ] . output_path )
8181 function_name = module. label . id
8282 handler = var. handler
8383 runtime = var. runtime
Original file line number Diff line number Diff line change @@ -2,3 +2,18 @@ output "arn" {
22 description = " ARN of the lambda function"
33 value = module. lambda . arn
44}
5+
6+ output "function_name" {
7+ description = " Lambda function name"
8+ value = module. lambda . function_name
9+ }
10+
11+ output "role_name" {
12+ description = " Lambda IAM role name"
13+ value = module. lambda . role_name
14+ }
15+
16+ output "cloudwatch_log_group_name" {
17+ description = " Name of Cloudwatch log group"
18+ value = module. lambda . cloudwatch_log_group_name
19+ }
Original file line number Diff line number Diff line change @@ -6,5 +6,9 @@ terraform {
66 source = " hashicorp/aws"
77 version = " >= 3.0"
88 }
9+ archive = {
10+ source = " hashicorp/archive"
11+ version = " >= 2.0"
12+ }
913 }
1014}
Original file line number Diff line number Diff line change @@ -9,11 +9,14 @@ module "cloudwatch_log_group" {
99 source = " cloudposse/cloudwatch-logs/aws"
1010 version = " 0.6.6"
1111
12+ enabled = module. this . enabled
13+
1214 iam_role_enabled = false
1315 kms_key_arn = var. cloudwatch_logs_kms_key_arn
1416 retention_in_days = var. cloudwatch_logs_retention_in_days
1517 name = " /aws/lambda/${ var . function_name } "
16- context = module. this . context
18+
19+ tags = module. this . tags
1720}
1821
1922resource "aws_lambda_function" "this" {
Original file line number Diff line number Diff line change @@ -27,3 +27,8 @@ output "role_arn" {
2727 description = " Lambda IAM role ARN"
2828 value = local. enabled ? aws_iam_role. this [0 ]. arn : null
2929}
30+
31+ output "cloudwatch_log_group_name" {
32+ description = " Name of Cloudwatch log group"
33+ value = local. enabled ? module. cloudwatch_log_group . log_group_name : null
34+ }
Original file line number Diff line number Diff line change @@ -39,7 +39,15 @@ func TestExamplesComplete(t *testing.T) {
3939
4040 // Run `terraform output` to get the value of an output variable
4141 arn := terraform .Output (t , terraformOptions , "arn" )
42+ function_name := terraform .Output (t , terraformOptions , "function_name" )
43+ role_name := terraform .Output (t , terraformOptions , "role_name" )
44+ cloudwatch_log_group_name := terraform .Output (t , terraformOptions , "cloudwatch_log_group_name" )
45+
46+ // Validate values returned by terraform
4247 assert .NotNil (t , arn )
48+ assert .Equal (t , "eg-ue2-test-" + randID + "-example-complete" , function_name )
49+ assert .Equal (t , "eg-ue2-test-" + randID + "-example-complete-us-east-2" , role_name )
50+ assert .Equal (t , "/aws/lambda/eg-ue2-test-" + randID + "-example-complete" , cloudwatch_log_group_name )
4351
4452 sess := session .Must (session .NewSessionWithOptions (session.Options {
4553 SharedConfigState : session .SharedConfigEnable ,
You can’t perform that action at this time.
0 commit comments