diff --git a/main.tf b/main.tf index 6337bb1..b4ed95a 100644 --- a/main.tf +++ b/main.tf @@ -16,16 +16,13 @@ locals { ssh_key_name = var.ssh_key_name public_ssh_key = var.public_ssh_key # create when public key is given, otherwise select with name - ifconfig_co_json = jsondecode(data.http.my_public_ip[0].response_body) - ip = (local.security_group_ip == "" ? local.ifconfig_co_json.ip : local.security_group_ip) + ipinfo_ip = chomp(data.http.my_public_ip[0].response_body) + ip = (local.security_group_ip == "" ? local.ipinfo_ip : local.security_group_ip) } data "http" "my_public_ip" { count = (local.security_group_ip == "" ? 1 : 0) - url = "https://ifconfig.co/json" - request_headers = { - Accept = "application/json" - } + url = "https://ipinfo.io/ip" } module "vpc" { diff --git a/modules/security_group/main.tf b/modules/security_group/main.tf index 8061277..29109f1 100644 --- a/modules/security_group/main.tf +++ b/modules/security_group/main.tf @@ -4,7 +4,7 @@ locals { create = (var.type != "" ? 1 : 0) # create if given a type type = (local.types[(var.type == "" ? "none" : var.type)]) owner = var.owner - ip = var.ip + ip = chomp(var.ip) cidr = var.cidr vpc_id = var.vpc_id vpc_cidr = var.vpc_cidr diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 20cfb65..9b3d6f6 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -20,6 +20,11 @@ resource "aws_vpc" "new" { Name = local.name } assign_generated_ipv6_cidr_block = true + lifecycle { + ignore_changes = [ + default_network_acl_id, + ] + } } resource "aws_internet_gateway" "new" {