Skip to content

Commit 4dd990a

Browse files
authored
Update module versions, examples and tests (#24)
* Update module versions * Update module versions * Update module versions, examples and tests * Update module versions, examples and tests * Update module versions, examples and tests * Update module versions, examples and tests * Update module versions, examples and tests * Update module versions, examples and tests * Update module versions, examples and tests
1 parent dc8f0f2 commit 4dd990a

25 files changed

+281
-880
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2020 Cloud Posse, LLC
189+
Copyright 2021-2022 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 26 additions & 23 deletions
Large diffs are not rendered by default.

README.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ related:
5252
url: "https://github.com/cloudposse/terraform-null-label"
5353

5454
description: |-
55-
This module deploys an AWS Lambda function from a zip file or from a docker image. Additionally, it creates an IAM
56-
role for the Lambda function, which optionally attaches policies to allow for Cloudwatch Logs, Cloudwatch Insights,
55+
This module deploys an AWS Lambda function from a Zip file or from a Docker image. Additionally, it creates an IAM
56+
role for the Lambda function, which optionally attaches policies to allow for CloudWatch Logs, Cloudwatch Insights,
5757
VPC Access and X-Ray tracing.
58-
# Example usage
5958
6059
# How to use this module. Should be an easy example to copy and paste.
6160
usage: |-
6261
For a complete example, see [examples/complete](examples/complete).
6362
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
6463
(which tests and deploys the example on AWS), see [test](test).
64+
6565
```hcl
6666
module "lambda" {
6767
source = "cloudposse/lambda-function/aws"
@@ -75,8 +75,8 @@ usage: |-
7575
```
7676
7777
examples: |-
78-
Here is an example of using this module:
79-
- [`examples/complete`](https://github.com/cloudposse/terraform-aws-lambda-function/) - complete example of using this module
78+
- [`examples/complete`](https://github.com/cloudposse/terraform-aws-lambda-function/examples/complete) - complete example of using this module
79+
- [`examples/docker-image`](https://github.com/cloudposse/terraform-aws-lambda-function/examples/docker-image) - example of using Lambda with Docker images
8080
8181
# Other files to include in this README from the project folder
8282
include:
@@ -89,3 +89,5 @@ contributors:
8989
github: "mcalhoun"
9090
- name: "PePe Amengual"
9191
github: "jamengual"
92+
- name: "Andriy Knysh"
93+
github: "aknysh"

docs/terraform.md

Lines changed: 17 additions & 16 deletions
Large diffs are not rendered by default.

examples/complete/fixtures.us-east-2.tfvars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ namespace = "eg"
33
environment = "ue2"
44
stage = "test"
55

6-
function_name = "example-complete-function"
6+
function_name = "example-complete"
77
handler = "handler.handler"
88
runtime = "nodejs14.x"

examples/complete/handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
exports.handler = async function (_event, _context) {
2-
return { data: "Hello World" };
2+
return {data: "Hello World"};
33
};

examples/complete/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ locals {
1010
join("", data.aws_partition.current.*.partition),
1111
join("", data.aws_caller_identity.current.*.account_id),
1212
)
13+
1314
policy_arn_inside = format("%s/%s", local.policy_arn_prefix, local.policy_name_inside)
1415

1516
policy_json = jsonencode({
@@ -53,7 +54,7 @@ resource "aws_iam_policy" "inside" {
5354
count = local.enabled ? 1 : 0
5455
name = local.policy_name_inside
5556
path = "/"
56-
description = "My policy attached inside the lambda module"
57+
description = "The policy attached inside the Lambda module"
5758

5859
policy = local.policy_json
5960
}
@@ -62,7 +63,7 @@ resource "aws_iam_policy" "outside" {
6263
count = local.enabled ? 1 : 0
6364
name = local.policy_name_outside
6465
path = "/"
65-
description = "My policy attached outside the lambda module"
66+
description = "The policy attached outside the Lambda module"
6667

6768
policy = local.policy_json
6869
}
@@ -76,10 +77,11 @@ resource "aws_iam_role_policy_attachment" "outside" {
7677
module "lambda" {
7778
source = "../.."
7879

79-
filename = join("", data.archive_file.lambda_zip.*.output_path)
80-
function_name = module.label.id
81-
handler = var.handler
82-
runtime = var.runtime
80+
filename = join("", data.archive_file.lambda_zip.*.output_path)
81+
function_name = module.label.id
82+
handler = var.handler
83+
runtime = var.runtime
84+
iam_policy_description = var.iam_policy_description
8385

8486
custom_iam_policy_arns = [
8587
"arn:aws:iam::aws:policy/job-function/ViewOnlyAccess",
@@ -89,7 +91,5 @@ module "lambda" {
8991

9092
context = module.this.context
9193

92-
depends_on = [
93-
aws_iam_policy.inside,
94-
]
94+
depends_on = [aws_iam_policy.inside]
9595
}

examples/complete/variables.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ variable "region" {
44
}
55

66
variable "function_name" {
7-
description = "Unique name for the Lambda Function."
87
type = string
8+
description = "Unique name for the Lambda Function."
99
}
1010

1111
variable "handler" {
12+
type = string
1213
description = "The function entrypoint in your code."
1314
default = ""
14-
type = string
1515
}
1616

1717
variable "runtime" {
18+
type = string
1819
description = "The runtime environment for the Lambda function you are uploading."
1920
default = ""
21+
}
22+
23+
variable "iam_policy_description" {
2024
type = string
25+
description = "Description of the IAM policy for the Lambda IAM role"
26+
default = "Minimum SSM read permissions for Lambda"
2127
}

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 0.13"
2+
required_version = ">= 0.14"
33

44
required_providers {
55
aws = {

examples/docker-image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ COPY handler.js ${LAMBDA_TASK_ROOT}
66
ENV NODE_ENV=production
77

88
# start app
9-
CMD [ "handler.handler" ]
9+
CMD [ "handler.handler" ]

0 commit comments

Comments
 (0)