Skip to content

Commit d57ba13

Browse files
committed
feat(test): add aws_security_group_id variable and remove obsolete security group validation tests
1 parent 12647c8 commit d57ba13

1 file changed

Lines changed: 1 addition & 41 deletions

File tree

tests/unit/aws/aws_ssh_ec2.tftest.hcl

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ variables {
22
aws_region = "us-east-1"
33
vpc_id = "vpc-12345678"
44
subnet_id = "subnet-12345678"
5+
aws_security_group_id = "sg-1234567890"
56
tags = {
67
Environment = "test"
78
Owner = "terraform-test"
@@ -67,47 +68,6 @@ run "validate_ec2_instance_public_ip" {
6768
}
6869

6970

70-
71-
run "validate_ec2_security_group_created" {
72-
command = plan
73-
74-
assert {
75-
condition = aws_security_group.sg.name == "sdm-gw-sg-sdm"
76-
error_message = "Security group should be created"
77-
}
78-
79-
assert {
80-
condition = alltrue([
81-
aws_vpc_security_group_ingress_rule.sdm_sg_ingress_rule.from_port == 5000,
82-
aws_vpc_security_group_ingress_rule.sdm_sg_ingress_rule.to_port == 5000,
83-
aws_vpc_security_group_ingress_rule.sdm_sg_ingress_rule.ip_protocol == "tcp",
84-
aws_vpc_security_group_ingress_rule.sdm_sg_ingress_rule.cidr_ipv4 == "0.0.0.0/0",
85-
])
86-
error_message = "Security group rules exists with correct rules"
87-
}
88-
89-
assert {
90-
condition = alltrue([
91-
aws_vpc_security_group_egress_rule.sdm_sg_egress_rule.from_port == -1,
92-
aws_vpc_security_group_egress_rule.sdm_sg_egress_rule.to_port == -1,
93-
aws_vpc_security_group_egress_rule.sdm_sg_egress_rule.ip_protocol == "-1",
94-
aws_vpc_security_group_egress_rule.sdm_sg_egress_rule.cidr_ipv4 == "0.0.0.0/0",
95-
])
96-
error_message = "Security group rules exists with correct rules"
97-
}
98-
99-
assert {
100-
condition = alltrue([
101-
aws_security_group.sg.tags["Environment"] == "test",
102-
aws_security_group.sg.tags["Owner"] == "terraform-test",
103-
aws_security_group.sg.tags["Project"] == "sdm-template",
104-
aws_security_group.sg.tags["Application"] == "strongdm",
105-
aws_security_group.sg.tags["ManagedBy"] == "terraform"
106-
])
107-
error_message = "Security group exists with correct tags"
108-
}
109-
}
110-
11171
run "user_data_contains_admin_token_variable" {
11272
command = plan
11373

0 commit comments

Comments
 (0)