Skip to content

Commit 95f8bcf

Browse files
authored
Merge pull request #20 from DataDog/jonathan.machado/minor_updates
Make some minors update to clean the code
2 parents f66752c + 3693418 commit 95f8bcf

File tree

9 files changed

+44
-30
lines changed

9 files changed

+44
-30
lines changed

examples/custom_vpc/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@ provider "aws" {
1414
}
1515

1616
module "agentless_scanner_role" {
17-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/agentless-scanner-role"
17+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/agentless-scanner-role?ref=0.2.0"
1818

1919
account_roles = [module.delegate_role.role.arn]
2020
}
2121

2222
module "delegate_role" {
23-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/scanning-delegate-role"
23+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/scanning-delegate-role?ref=0.2.0"
2424

2525
scanner_role_arn = module.agentless_scanner_role.role.arn
2626
}
2727

2828
module "user_data" {
29-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/user_data"
29+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/user_data?ref=0.2.0"
3030

3131
hostname = "agentless-scanning-us-east-1"
3232
api_key = var.api_key
3333
}
3434

3535
module "instance" {
36-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/instance"
36+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/instance?ref=0.2.0"
3737

3838
user_data = module.user_data.install_sh
3939
iam_instance_profile = module.agentless_scanner_role.profile.name

examples/multi_region/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ provider "aws" {
2020
}
2121

2222
module "agentless_scanner_role" {
23-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/agentless-scanner-role"
23+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/agentless-scanner-role?ref=0.2.0"
2424

2525
account_roles = [module.delegate_role.role.arn]
2626
}
2727

2828
module "delegate_role" {
29-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/scanning-delegate-role"
29+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/scanning-delegate-role?ref=0.2.0"
3030

3131
scanner_role_arn = module.agentless_scanner_role.role.arn
3232
}
3333

3434
module "agentless_scanner" {
35-
source = "github.com/DataDog/terraform-datadog-agentless-scanner"
35+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner?ref=0.2.0"
3636
providers = {
3737
aws = aws.us
3838
}
@@ -42,7 +42,7 @@ module "agentless_scanner" {
4242
}
4343

4444
module "agentless_scanner" {
45-
source = "github.com/DataDog/terraform-datadog-agentless-scanner"
45+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner?ref=0.2.0"
4646
providers = {
4747
aws = aws.eu
4848
}

examples/single_region/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ provider "aws" {
1313
region = "us-east-1"
1414
}
1515

16-
module "agentless_scanner_role" {
17-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/agentless-scanner-role"
16+
module "scanner_role" {
17+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/agentless-scanner-role?ref=0.2.0"
1818

1919
account_roles = [module.delegate_role.role.arn]
2020
}
2121

2222
module "delegate_role" {
23-
source = "github.com/DataDog/terraform-datadog-agentless-scanner//modules/scanning-delegate-role"
23+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner//modules/scanning-delegate-role?ref=0.2.0"
2424

25-
scanner_role_arn = module.agentless_scanner_role.role.arn
25+
scanner_role_arn = module.scanner_role.role.arn
2626
}
2727

2828
module "agentless_scanner" {
29-
source = "github.com/DataDog/terraform-datadog-agentless-scanner"
29+
source = "git::https://github.com/DataDog/terraform-datadog-agentless-scanner?ref=0.2.0"
3030

3131
api_key = var.api_key
32-
instance_profile_name = module.agentless_scanner_role.instance_profile.name
33-
}
32+
instance_profile_name = module.scanner_role.instance_profile.name
33+
}

main.tf

Lines changed: 3 additions & 1 deletion
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
23-
}
24+
tags = var.tags
25+
}

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 "enable_ssm" {
32+
description = "Whether to enable AWS SSM to facilitate executing troubleshooting commands on the instance"
33+
type = bool
34+
default = false
35+
}
36+
3137
variable "tags" {
3238
description = "A map of additional tags to add to the IAM role/profile created"
3339
type = map(string)
3440
default = {}
3541
}
36-
37-
variable "enable_ssm" {
38-
description = "Whether to enable AWS SSM to facilitate executing troubleshooting commands on the instance"
39-
type = bool
40-
default = false
41-
}

modules/user_data/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ variable "api_key_secret_arn" {
1414
description = "ARN of the secret holding the Datadog API key. Takes precedence over api_key variable"
1515
type = string
1616
default = null
17+
18+
validation {
19+
condition = length(var.api_key) == 32 && can(regex("^[[:alnum:]]+$", var.api_key))
20+
error_message = "A valid API key must be present in order to plan/apply this module."
21+
}
1722
}
1823

1924
variable "site" {

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: 7 additions & 1 deletion
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-
}
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 = {}
47+
}

0 commit comments

Comments
 (0)