Skip to content

Commit

Permalink
modify alert
Browse files Browse the repository at this point in the history
  • Loading branch information
LamSut committed Nov 2, 2024
1 parent f0361e1 commit 65d9727
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ec2/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_instance" "server" {
ami = "ami-066784287e358dad1"
ami = "ami-06b21ccaeff8cd686"
instance_type = "t2.micro"
subnet_id = var.subnet
security_groups = [var.security_group]
Expand Down
12 changes: 7 additions & 5 deletions tests/freeEC2.tftest.hcl
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
variables {
ami = "ami-066784287e358dad1"
ami_amazon_linux_2023 = "ami-06b21ccaeff8cd686"
ami_amazon_linux_hvm = "ami-0ddc798b3f1a5117e"
//more ami
instance_type = "t2.micro"
//more
//more instace type
}

run "ec2_tests" {
command = plan

assert {
condition = module.ec2.ami == var.ami
error_message = "Invalid AMI type!"
condition = module.ec2.ami == var.ami_amazon_linux_2023 || module.ec2.ami == var.ami_amazon_linux_hvm
error_message = "Invalid or not a free AMI type!"
}

assert {
condition = module.ec2.instance_type == var.instance_type
error_message = "Invalid instance type!"
error_message = "Invalid or not a free instance type!"
}
}

16 changes: 16 additions & 0 deletions tests/vpc.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
variables {
enable_dns_hostnames = true
enable_dns_support = true
//more
}

run "vpc_tests" {
command = plan

assert {
condition = module.vpc.enable_dns_hostnames == var.enable_dns_hostnames && module.vpc.enable_dns_support == var.enable_dns_support
error_message = "Must enable DNS!"
}

}

8 changes: 8 additions & 0 deletions vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ output "public_subnet" {
output "security_group" {
value = aws_security_group.security_group.id
}

output "enable_dns_hostnames" {
value = aws_vpc.myvpc.enable_dns_hostnames
}

output "enable_dns_support" {
value = aws_vpc.myvpc.enable_dns_support
}

0 comments on commit 65d9727

Please sign in to comment.