Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to fix Invalid for_each argument for var.custom_iam_policy_arns #11

Merged
merged 39 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b336a1
Fixing logic for lambda function policy
jamengual Apr 20, 2022
abfcefc
Fixing logic for lambda function policy
jamengual Apr 20, 2022
2c0fd34
Fixing logic for lambda function policy
jamengual Apr 20, 2022
7ec8a7e
Fixing logic for lambda function policy
jamengual Apr 20, 2022
0930454
Fixing logic for lambda function policy
jamengual Apr 20, 2022
fa5e47c
Auto Format
cloudpossebot Apr 20, 2022
a4ffc04
Fixing logic for lambda function policy
jamengual Apr 20, 2022
6576c7b
Fixing logic for lambda function policy
jamengual Apr 20, 2022
0f9617b
Fixing logic for lambda function policy
jamengual Apr 20, 2022
1972e7b
Auto Format
cloudpossebot Apr 20, 2022
c28a059
Fixing logic for lambda function policy
jamengual Apr 20, 2022
74598dd
Fixing logic for lambda function policy
jamengual Apr 20, 2022
e7b1560
Auto Format
cloudpossebot Apr 20, 2022
224d5b0
Fixing logic for lambda function policy
jamengual Apr 20, 2022
e44a9e7
Fixing logic for lambda function policy
jamengual Apr 20, 2022
8d0d920
Fixing logic for lambda function policy
jamengual Apr 20, 2022
94b509c
Auto Format
cloudpossebot Apr 20, 2022
f92ff7c
Keep for_each and expand tests
nitrocode Apr 21, 2022
67896aa
Auto Format
cloudpossebot Apr 21, 2022
59fce63
Update iam-role.tf
nitrocode Apr 21, 2022
4236fc7
Add role_name output
nitrocode Apr 21, 2022
0f106e4
Update variables.tf
nitrocode Apr 21, 2022
5faa90e
Update iam-role.tf
nitrocode Apr 21, 2022
c4d43eb
Auto Format
cloudpossebot Apr 21, 2022
a562c3f
Update main.tf
nitrocode Apr 21, 2022
6d2c7c7
Add inside/outside and enabled flag
nitrocode Apr 21, 2022
cfa8b6d
Update main.tf
nitrocode Apr 21, 2022
5d754a4
Add context to iam_policy and count to archive
nitrocode Apr 21, 2022
dd549c8
Auto Format
cloudpossebot Apr 21, 2022
ce9e8d9
Unique policy names
nitrocode Apr 21, 2022
cd5f039
Auto Format
cloudpossebot Apr 21, 2022
bc5f1a2
Use label, construct string arn
nitrocode Apr 21, 2022
fe78f8a
Add role_arn output
nitrocode Apr 21, 2022
262acdd
Auto Format
cloudpossebot Apr 21, 2022
01e5d97
Use join splat
nitrocode Apr 21, 2022
950a559
Remove the iam_policy module
nitrocode Apr 22, 2022
f4176ae
Add count logic to assume_role_policy
nitrocode Apr 22, 2022
974e3ba
More robust no changes check
nitrocode Apr 22, 2022
1ae6f15
Update common.go
nitrocode Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ Available targets:
| <a name="input_cloudwatch_logs_kms_key_arn"></a> [cloudwatch\_logs\_kms\_key\_arn](#input\_cloudwatch\_logs\_kms\_key\_arn) | The ARN of the KMS Key to use when encrypting log data. | `string` | `null` | no |
| <a name="input_cloudwatch_logs_retention_in_days"></a> [cloudwatch\_logs\_retention\_in\_days](#input\_cloudwatch\_logs\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. Possible values are: <br> 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653, and 0. If you select 0, the events in the <br> log group are always retained and never expire. | `number` | `null` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
| <a name="input_custom_iam_policy_arns"></a> [custom\_iam\_policy\_arns](#input\_custom\_iam\_policy\_arns) | List of custom policies to be attached to the lambda role | `set(string)` | `[]` | no |
| <a name="input_custom_iam_policy_arn"></a> [custom\_iam\_policy\_arn](#input\_custom\_iam\_policy\_arn) | ARN of custom policy to be attached to the lambda role | `string` | `null` | no |
| <a name="input_custom_iam_policy_enabled"></a> [custom\_iam\_policy\_enabled](#input\_custom\_iam\_policy\_enabled) | To enable custom policies on the iam role | `string` | `false` | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
| <a name="input_description"></a> [description](#input\_description) | Description of what the Lambda Function does. | `string` | `null` | no |
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
Expand Down
3 changes: 2 additions & 1 deletion docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
| <a name="input_cloudwatch_logs_kms_key_arn"></a> [cloudwatch\_logs\_kms\_key\_arn](#input\_cloudwatch\_logs\_kms\_key\_arn) | The ARN of the KMS Key to use when encrypting log data. | `string` | `null` | no |
| <a name="input_cloudwatch_logs_retention_in_days"></a> [cloudwatch\_logs\_retention\_in\_days](#input\_cloudwatch\_logs\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. Possible values are: <br> 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653, and 0. If you select 0, the events in the <br> log group are always retained and never expire. | `number` | `null` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
| <a name="input_custom_iam_policy_arns"></a> [custom\_iam\_policy\_arns](#input\_custom\_iam\_policy\_arns) | List of custom policies to be attached to the lambda role | `set(string)` | `[]` | no |
| <a name="input_custom_iam_policy_arn"></a> [custom\_iam\_policy\_arn](#input\_custom\_iam\_policy\_arn) | ARN of custom policy to be attached to the lambda role | `string` | `null` | no |
| <a name="input_custom_iam_policy_enabled"></a> [custom\_iam\_policy\_enabled](#input\_custom\_iam\_policy\_enabled) | To enable custom policies on the iam role | `string` | `false` | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
| <a name="input_description"></a> [description](#input\_description) | Description of what the Lambda Function does. | `string` | `null` | no |
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
Expand Down
4 changes: 2 additions & 2 deletions iam-role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ resource "aws_iam_role_policy_attachment" "ssm" {
}

resource "aws_iam_role_policy_attachment" "custom" {
for_each = local.enabled && length(var.custom_iam_policy_arns) > 0 ? var.custom_iam_policy_arns : toset([])
count = try((local.enabled && var.custom_iam_policy_enabled), false) ? 1 : 0
role = aws_iam_role.this[0].name
policy_arn = each.key
policy_arn = var.custom_iam_policy_arn
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
}
14 changes: 10 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,14 @@ variable "vpc_config" {
})
}

variable "custom_iam_policy_arns" {
type = set(string)
description = "List of custom policies to be attached to the lambda role"
default = []

variable "custom_iam_policy_enabled" {
type = string
description = "To enable custom policies on the iam role"
default = false
}
variable "custom_iam_policy_arn" {
type = string
description = "ARN of custom policy to be attached to the lambda role"
default = null
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
}