Skip to content

Commit bdf695f

Browse files
authored
feat: add tags to aws_iam_policy resources (#153)
1 parent d8c8c50 commit bdf695f

File tree

10 files changed

+30
-10
lines changed

10 files changed

+30
-10
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ repos:
2121
- '--args=--only=terraform_standard_module_structure'
2222
- '--args=--only=terraform_workspace_remote'
2323
- repo: git://github.com/pre-commit/pre-commit-hooks
24-
rev: v3.4.0
24+
rev: v4.0.1
2525
hooks:
2626
- id: check-merge-conflict

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
549549
| Name | Version |
550550
|------|---------|
551551
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
552-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.19 |
552+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.35 |
553553
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 1 |
554554
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1 |
555555
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2 |
@@ -559,7 +559,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
559559

560560
| Name | Version |
561561
|------|---------|
562-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.19 |
562+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.35 |
563563
| <a name="provider_external"></a> [external](#provider\_external) | >= 1 |
564564
| <a name="provider_local"></a> [local](#provider\_local) | >= 1 |
565565
| <a name="provider_null"></a> [null](#provider\_null) | >= 2 |

iam.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ resource "aws_iam_policy" "logs" {
9898

9999
name = "${local.role_name}-logs"
100100
policy = data.aws_iam_policy_document.logs[0].json
101+
tags = var.tags
101102
}
102103

103104
resource "aws_iam_policy_attachment" "logs" {
@@ -134,6 +135,7 @@ resource "aws_iam_policy" "dead_letter" {
134135

135136
name = "${local.role_name}-dl"
136137
policy = data.aws_iam_policy_document.dead_letter[0].json
138+
tags = var.tags
137139
}
138140

139141
resource "aws_iam_policy_attachment" "dead_letter" {
@@ -160,6 +162,7 @@ resource "aws_iam_policy" "vpc" {
160162

161163
name = "${local.role_name}-vpc"
162164
policy = data.aws_iam_policy.vpc[0].policy
165+
tags = var.tags
163166
}
164167

165168
resource "aws_iam_policy_attachment" "vpc" {
@@ -186,6 +189,7 @@ resource "aws_iam_policy" "tracing" {
186189

187190
name = "${local.role_name}-tracing"
188191
policy = data.aws_iam_policy.tracing[0].policy
192+
tags = var.tags
189193
}
190194

191195
resource "aws_iam_policy_attachment" "tracing" {
@@ -222,6 +226,7 @@ resource "aws_iam_policy" "async" {
222226

223227
name = "${local.role_name}-async"
224228
policy = data.aws_iam_policy_document.async[0].json
229+
tags = var.tags
225230
}
226231

227232
resource "aws_iam_policy_attachment" "async" {
@@ -241,6 +246,7 @@ resource "aws_iam_policy" "additional_json" {
241246

242247
name = local.role_name
243248
policy = var.policy_json
249+
tags = var.tags
244250
}
245251

246252
resource "aws_iam_policy_attachment" "additional_json" {
@@ -260,6 +266,7 @@ resource "aws_iam_policy" "additional_jsons" {
260266

261267
name = "${local.role_name}-${count.index}"
262268
policy = var.policy_jsons[count.index]
269+
tags = var.tags
263270
}
264271

265272
resource "aws_iam_policy_attachment" "additional_jsons" {
@@ -343,6 +350,7 @@ resource "aws_iam_policy" "additional_inline" {
343350

344351
name = "${local.role_name}-inline"
345352
policy = data.aws_iam_policy_document.additional_inline[0].json
353+
tags = var.tags
346354
}
347355

348356
resource "aws_iam_policy_attachment" "additional_inline" {

modules/alias/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ module "lambda" {
116116
| Name | Version |
117117
|------|---------|
118118
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
119-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.19 |
119+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.35 |
120120

121121
## Providers
122122

123123
| Name | Version |
124124
|------|---------|
125-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.19 |
125+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.35 |
126126

127127
## Modules
128128

modules/alias/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ terraform {
22
required_version = ">= 0.12.26"
33

44
required_providers {
5-
aws = ">= 3.19"
5+
aws = ">= 3.35"
66
}
77
}

modules/deploy/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ module "lambda" {
100100
| Name | Version |
101101
|------|---------|
102102
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
103-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.19 |
103+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.35 |
104104
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1 |
105105
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2 |
106106

107107
## Providers
108108

109109
| Name | Version |
110110
|------|---------|
111-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.19 |
111+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.35 |
112112
| <a name="provider_local"></a> [local](#provider\_local) | >= 1 |
113113
| <a name="provider_null"></a> [null](#provider\_null) | >= 2 |
114114

@@ -164,6 +164,7 @@ No modules.
164164
| <a name="input_function_name"></a> [function\_name](#input\_function\_name) | The name of the Lambda function to deploy | `string` | `""` | no |
165165
| <a name="input_interpreter"></a> [interpreter](#input\_interpreter) | List of interpreter arguments used to execute deploy script, first arg is path | `list(string)` | <pre>[<br> "/bin/bash",<br> "-c"<br>]</pre> | no |
166166
| <a name="input_save_deploy_script"></a> [save\_deploy\_script](#input\_save\_deploy\_script) | Save deploy script locally | `bool` | `false` | no |
167+
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to resources. | `map(string)` | `{}` | no |
167168
| <a name="input_target_version"></a> [target\_version](#input\_target\_version) | Target version of Lambda function version to deploy | `string` | `""` | no |
168169
| <a name="input_triggers"></a> [triggers](#input\_triggers) | Map of triggers which will be notified when event happens. Valid options for event types are DeploymentStart, DeploymentSuccess, DeploymentFailure, DeploymentStop, DeploymentRollback, DeploymentReady (Applies only to replacement instances in a blue/green deployment), InstanceStart, InstanceSuccess, InstanceFailure, InstanceReady. Note that not all are applicable for Lambda deployments. | `map(any)` | `{}` | no |
169170
| <a name="input_use_existing_app"></a> [use\_existing\_app](#input\_use\_existing\_app) | Whether to use existing AWS CodeDeploy app | `bool` | `false` | no |

modules/deploy/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ resource "aws_codedeploy_app" "this" {
123123

124124
name = var.app_name
125125
compute_platform = "Lambda"
126+
tags = var.tags
126127
}
127128

128129
resource "aws_codedeploy_deployment_group" "this" {
@@ -162,6 +163,8 @@ resource "aws_codedeploy_deployment_group" "this" {
162163
trigger_target_arn = trigger_configuration.value.target_arn
163164
}
164165
}
166+
167+
tags = var.tags
165168
}
166169

167170
data "aws_iam_role" "codedeploy" {
@@ -175,6 +178,7 @@ resource "aws_iam_role" "codedeploy" {
175178

176179
name = coalesce(var.codedeploy_role_name, "${local.app_name}-codedeploy")
177180
assume_role_policy = data.aws_iam_policy_document.assume_role[0].json
181+
tags = var.tags
178182
}
179183

180184

@@ -217,6 +221,7 @@ resource "aws_iam_policy" "triggers" {
217221
count = var.create && var.create_codedeploy_role && var.attach_triggers_policy ? 1 : 0
218222

219223
policy = data.aws_iam_policy_document.triggers[0].json
224+
tags = var.tags
220225
}
221226

222227
resource "aws_iam_role_policy_attachment" "triggers" {

modules/deploy/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ variable "create" {
44
default = true
55
}
66

7+
variable "tags" {
8+
description = "A map of tags to assign to resources."
9+
type = map(string)
10+
default = {}
11+
}
12+
713
variable "alias_name" {
814
description = "Name for the alias"
915
type = string

modules/deploy/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.12.26"
33

44
required_providers {
5-
aws = ">= 3.19"
5+
aws = ">= 3.35"
66
local = ">= 1"
77
null = ">= 2"
88
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.12.26"
33

44
required_providers {
5-
aws = ">= 3.19"
5+
aws = ">= 3.35"
66
external = ">= 1"
77
local = ">= 1"
88
random = ">= 2"

0 commit comments

Comments
 (0)