From 386a5302515003d83ee8f739a5e37d1c95bba3a2 Mon Sep 17 00:00:00 2001 From: spengreb Date: Sat, 6 Nov 2021 15:18:53 +0100 Subject: [PATCH] Remove prompt for local IP --- main.tf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index 2fa9c04..0df8b60 100644 --- a/main.tf +++ b/main.tf @@ -57,9 +57,8 @@ data "aws_ami" "image" { } } -variable "your_ip" { - type = string - description = "Your global IP for SSH access" +data "http" "myip" { + url = "http://ipv4.icanhazip.com" } resource "aws_security_group" "ssh" { @@ -81,7 +80,7 @@ resource "aws_security_group_rule" "ssh" { to_port = 22 from_port = 22 protocol = "tcp" - cidr_blocks = [ "${var.your_ip}/32"] + cidr_blocks = [ "${chomp(data.http.myip.body)}/32" ] security_group_id = aws_security_group.ssh.id }