Skip to content

Commit 39c59d1

Browse files
committed
chore: adding a description to the secruity group rule
1 parent a0e9812 commit 39c59d1

File tree

4 files changed

+136
-44
lines changed

4 files changed

+136
-44
lines changed

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module "dns_security_group" {
2525
source = "terraform-aws-modules/security-group/aws"
2626
version = "5.1.2"
2727

28-
name = local.security_group_name
29-
#description = ""
28+
name = local.security_group_name
29+
description = "Used by the Route53 Resolver to allow DNS traffic to the internal dns solution"
3030
ingress_cidr_blocks = ["10.0.0.0/8"]
3131
ingress_rules = ["dns-tcp", "dns-udp"]
3232
egress_rules = ["dns-tcp", "dns-udp"]

tests/basic.tftest.hcl

-42
This file was deleted.

tests/plan.tftest.hcl

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
mock_provider "aws" {
3+
mock_data "aws_availability_zones" {
4+
defaults = {
5+
group_names = []
6+
names = ["eu-west-2a", "eu-west-2b", "eu-west-2c"]
7+
}
8+
}
9+
}
10+
11+
# Ensure the plan runs successfully
12+
run "plan" {
13+
command = plan
14+
15+
variables {
16+
resolver_name = "test"
17+
tags = {
18+
Environment = "Test"
19+
}
20+
21+
resolver_rule_groups = []
22+
23+
network = {
24+
availability_zones = 2
25+
vpc_cidr = "10.90.0.0/21"
26+
transit_gateway_id = "tgw-12222222"
27+
}
28+
}
29+
}
30+

tests/resolver.tftest.hcl

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
2+
mock_provider "aws" {
3+
mock_data "aws_availability_zones" {
4+
defaults = {
5+
group_names = []
6+
names = ["eu-west-2a", "eu-west-2b", "eu-west-2c"]
7+
}
8+
}
9+
}
10+
11+
run "resolver_sharing" {
12+
command = plan
13+
14+
variables {
15+
resolver_name = "test"
16+
tags = {
17+
Environment = "Test"
18+
}
19+
20+
resolver_rule_groups = [
21+
{
22+
ram_share_name = "internal"
23+
ram_principals = {
24+
"Deployments" = "arn:aws:organizations::536471746696:ou/o-7enwqk0f2c/ou-1tbg-mq4w830q"
25+
"Workloads" = "arn:aws:organizations::536471746696:ou/o-7enwqk0f2c/ou-1tbg-lk6g79d4"
26+
}
27+
rules = [
28+
{
29+
name = "aws-appvia-local"
30+
domain = "aws.appvia.local"
31+
}
32+
]
33+
}
34+
]
35+
36+
network = {
37+
name = "test"
38+
availability_zones = 2
39+
vpc_cidr = "10.90.0.0/21"
40+
transit_gateway_id = "tgw-12222222"
41+
}
42+
}
43+
44+
assert {
45+
condition = length(aws_ram_principal_association.this) == length(var.resolver_rule_groups[0].ram_principals)
46+
error_message = "Expected the correct number of RAM principal associations"
47+
}
48+
}
49+
50+
run "resolver_creation" {
51+
command = plan
52+
53+
variables {
54+
resolver_name = "test"
55+
tags = {
56+
Environment = "Test"
57+
}
58+
59+
resolver_rule_groups = [
60+
{
61+
ram_share_name = "internal"
62+
ram_principals = {}
63+
rules = [
64+
{
65+
name = "aws-appvia-local"
66+
domain = "aws.appvia.local"
67+
}
68+
]
69+
}
70+
]
71+
72+
network = {
73+
name = "test"
74+
availability_zones = 2
75+
vpc_cidr = "10.90.0.0/21"
76+
transit_gateway_id = "tgw-12222222"
77+
}
78+
}
79+
80+
assert {
81+
condition = aws_route53_resolver_endpoint.this.name == var.resolver_name
82+
error_message = "Name of the resolver is incorrect"
83+
}
84+
85+
assert {
86+
condition = length(aws_route53_resolver_endpoint.this.protocols) == length(var.resolver_protocols)
87+
error_message = "Expected protocols to be set"
88+
}
89+
90+
assert {
91+
condition = aws_route53_resolver_endpoint.this.resolver_endpoint_type == var.resolver_endpoint_type
92+
error_message = "Expected resolver endpoint type to be set"
93+
}
94+
95+
assert {
96+
condition = aws_route53_resolver_endpoint.this.direction == "OUTBOUND"
97+
error_message = "Expected an outbound resolver"
98+
}
99+
100+
assert {
101+
condition = module.dns_security_group.aws_security_group.this_name_prefix[0].name_prefix == "dns-resolvers-test"
102+
error_message = "Expected security group to be created"
103+
}
104+
}

0 commit comments

Comments
 (0)