Skip to content

Commit df0a7ce

Browse files
committed
Use object for var.policy to avoid computed count errors
See: claranet#53
1 parent b47b590 commit df0a7ce

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ module "lambda" {
3232
source_path = "${path.module}/lambda.py"
3333

3434
// Attach a policy.
35-
policy = data.aws_iam_policy_document.lambda.json
35+
policy = {
36+
json = data.aws_iam_policy_document.lambda.json
37+
}
3638

3739
// Add a dead letter queue.
3840
dead_letter_config {
@@ -64,7 +66,7 @@ Inputs for this module are the same as the [aws_lambda_function](https://www.ter
6466
| **source\_path** | The absolute path to a local file or directory containing your Lambda source code | string | | yes |
6567
| build\_script | The path to the script which will compile a zip of the lambda function | string | `"build.py"` | no |
6668
| cloudwatch\_logs | Set this to false to disable logging your Lambda output to CloudWatch Logs | bool | true | no |
67-
| policy | An addional policy to attach to the Lambda function | string | | no |
69+
| policy | An additional policy to attach to the Lambda function role | object({json=string}) | | no |
6870

6971
The following arguments from the [aws_lambda_function](https://www.terraform.io/docs/providers/aws/r/lambda_function.html) resource are not supported:
7072

iam.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ resource "aws_iam_policy" "additional" {
139139
count = var.policy == null ? 0 : 1
140140

141141
name = var.function_name
142-
policy = var.policy
142+
policy = var.policy.json
143143
}
144144

145145
resource "aws_iam_policy_attachment" "additional" {

variables.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ variable "tags" {
9696
}
9797

9898
variable "policy" {
99-
description = "An addional policy to attach to the Lambda function"
100-
type = string
101-
default = null
99+
description = "An additional policy to attach to the Lambda function role"
100+
type = object({
101+
json = string
102+
})
103+
default = null
102104
}
103105

104106
variable "cloudwatch_logs" {

0 commit comments

Comments
 (0)