diff --git a/ec2/main.tf b/ec2/main.tf index a1f3bb5..513f26b 100644 --- a/ec2/main.tf +++ b/ec2/main.tf @@ -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] diff --git a/tests/freeEC2.tftest.hcl b/tests/freeEC2.tftest.hcl index ba39a0a..314e9e3 100644 --- a/tests/freeEC2.tftest.hcl +++ b/tests/freeEC2.tftest.hcl @@ -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!" } } diff --git a/tests/vpc.tftest.hcl b/tests/vpc.tftest.hcl new file mode 100644 index 0000000..64b55f7 --- /dev/null +++ b/tests/vpc.tftest.hcl @@ -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!" + } + +} + diff --git a/vpc/outputs.tf b/vpc/outputs.tf index b922121..d23377b 100644 --- a/vpc/outputs.tf +++ b/vpc/outputs.tf @@ -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 +}