Skip to content

Commit 0e1df3f

Browse files
committed
Allow tagging resources from the main module
1 parent ad91e11 commit 0e1df3f

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module "vpc" {
44
source = "./modules/vpc"
55

66
enable_ssm_vpc_endpoint = var.enable_ssm && var.enable_ssm_vpc_endpoint
7+
tags = var.tags
78
}
89

910
module "user_data" {
@@ -20,4 +21,5 @@ module "instance" {
2021
user_data = module.user_data.install_sh
2122
iam_instance_profile = var.instance_profile_name
2223
subnet_id = module.vpc.private_subnet.id
24+
tags = var.tags
2325
}

modules/agentless-scanner-role/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ resource "aws_iam_role_policy_attachment" "attachment" {
8282
}
8383

8484
resource "aws_iam_role_policy_attachment" "ssm-attachment" {
85-
count = var.enable_ssm ? 1 : 0
85+
count = var.enable_ssm ? 1 : 0
86+
8687
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
8788
role = aws_iam_role.role.name
8889
}

modules/agentless-scanner-role/variables.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ variable "kms_key_arn" {
2828
default = null
2929
}
3030

31-
variable "tags" {
32-
description = "A map of additional tags to add to the IAM role/profile created"
33-
type = map(string)
34-
default = {}
35-
}
36-
3731
variable "enable_ssm" {
3832
description = "Whether to enable AWS SSM to facilitate executing troubleshooting commands on the instance"
3933
type = bool
4034
default = false
35+
}
36+
37+
variable "tags" {
38+
description = "A map of additional tags to add to the IAM role/profile created"
39+
type = map(string)
40+
default = {}
4141
}

modules/vpc/variables.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ variable "cidr" {
1010
default = "10.0.0.0/16"
1111
}
1212

13+
variable "enable_ssm_vpc_endpoint" {
14+
description = "Whether to enable AWS SSM VPC endpoint"
15+
type = bool
16+
default = false
17+
}
18+
1319
variable "tags" {
1420
description = "A map of additional tags to add to the instance/volume created"
1521
type = map(string)
1622
default = {}
1723
}
18-
19-
variable "enable_ssm_vpc_endpoint" {
20-
description = "Whether to enable AWS SSM VPC endpoint"
21-
type = bool
22-
default = false
23-
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@ variable "enable_ssm_vpc_endpoint" {
3838
description = "Whether to enable AWS SSM VPC endpoint (only applicable if enable_ssm is true)"
3939
type = bool
4040
default = true
41+
}
42+
43+
variable "tags" {
44+
description = "A map of additional tags to add to the IAM role/profile created"
45+
type = map(string)
46+
default = {}
4147
}

0 commit comments

Comments
 (0)