int128 / terraform-aws-nat-instance

Terraform module to provision a NAT Instance using an Auto Scaling Group and Spot Instance from $1/month
https://registry.terraform.io/modules/int128/nat-instance/aws/
Apache License 2.0
175 stars 90 forks source link

No eth1 after apply #44

Open alex404sl opened 2 years ago

alex404sl commented 2 years ago

Hi! Thank you for the work!

But I am not be able to make this work though. The created nat instance does not have eth1.

Thanks!

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  name                 = "main_vpc"
  cidr                 = "10.1.0.0/16"
  azs                  = ["xxxxxxx"]
  private_subnets      = ["10.1.1.0/24"]
  public_subnets       = ["10.1.0.0/24"]
  enable_dns_hostnames = true
}

module "nat" {
  # https://registry.terraform.io/modules/int128/nat-instance/aws/latest?tab=inputs
  source  = "int128/nat-instance/aws"
  name = "nat"
  vpc_id                      = module.vpc.vpc_id
  public_subnet               = module.vpc.public_subnets[0]
  private_subnets_cidr_blocks = module.vpc.private_subnets_cidr_blocks
  private_route_table_ids     = module.vpc.private_route_table_ids
  enabled = true
}

resource "aws_eip" "nat" {
  network_interface = module.nat.eni_id
  tags = {
    "Name" = "nat-instance"
  }
}
alex404sl commented 2 years ago

Tried to attach the created network interface and run the systemctl start snat, got following error message:

[root@ip-10-1-0-177 bin]# systemctl status snat
● snat.service - SNAT via ENI eth1
   Loaded: loaded (/etc/systemd/system/snat.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2022-02-09 02:22:50 UTC; 15s ago
  Process: 2814 ExecStart=/opt/nat/snat.sh (code=exited, status=2)
 Main PID: 2814 (code=exited, status=2)

Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: --rpm-requires
Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: --restricted
Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: --verbose
Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: --version
Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: Shell options:
Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: -irsD or -c command or -O shopt_option                (invocation only)
Feb 09 02:22:50 ip-10-1-0-177.compute.internal snat.sh[2814]: -abefhkmnptuvxBCHP or -o option
Feb 09 02:22:50 ip-10-1-0-177.compute.internal systemd[1]: Failed to start SNAT via ENI eth1.
Feb 09 02:22:50 ip-10-1-0-177.compute.internal systemd[1]: Unit snat.service entered failed state.
Feb 09 02:22:50 ip-10-1-0-177.compute.internal systemd[1]: snat.service failed.