From 507139e2c81db9687cff96c7b9f79b39d5021cfe Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 19 Apr 2024 17:15:36 +0700 Subject: [PATCH] Create sanitech_infrastructure_testing.tf --- func/sanitech_infrastructure_testing.tf | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 func/sanitech_infrastructure_testing.tf diff --git a/func/sanitech_infrastructure_testing.tf b/func/sanitech_infrastructure_testing.tf new file mode 100644 index 0000000..6dbf971 --- /dev/null +++ b/func/sanitech_infrastructure_testing.tf @@ -0,0 +1,39 @@ +data "aws_route53_zone" "example" { + name = "example.com" +} + +resource "aws_route53_record" "example" { + name = "test.example.com" + type = "A" + zone_id = data.aws_route53_zone.example.zone_id + + alias { + evaluate_target_health = false + name = aws_instance.infrastructure_testing.private_ip + zone_id = aws_instance.infrastructure_testing.availability_zone_id + } +} + +resource "aws_instance" "infrastructure_testing" { + ami = "ami-0c94855ba95c574c8" + instance_type = "t2.micro" + + tags = { + Name = "infrastructure-testing" + } +} + +resource "null_resource" "infrastructure_testing" { + provisioner "remote-exec" { + inline = [ + "curl -I http://test.example.com" + ] + + connection { + type = "ssh" + user = "ubuntu" + host = aws_instance.infrastructure_testing.private_ip + private_key = file("~/.ssh/id_rsa") + } + } +}