Giter Site home page Giter Site logo

rajiska / terraform-aws-fck-nat Goto Github PK

View Code? Open in Web Editor NEW
45.0 45.0 25.0 64 KB

Terraform module for fck-nat

Home Page: https://registry.terraform.io/modules/RaJiska/fck-nat/aws/latest

License: MIT License

Makefile 2.97% HCL 95.25% Shell 1.77%
aws fck-nat nat nat-gateway terraform terraform-modules

terraform-aws-fck-nat's People

Contributors

bobsut avatar github-actions[bot] avatar hrist0stoichev avatar kieranbrown avatar kralizek avatar michelecoco avatar rajiska avatar rtkmhart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-aws-fck-nat's Issues

Current state?

Hi,

Thank you for this project. I arrived here from a link in a issue in the fck-nat repository.

I was wondering if this is ok to deploy or is it still at a development stage.

I'm not asking if it's production grade. I'm working on a personal project and the managed NAT cost is not sustainable. Most likely I'll switch back to the managed NAT by the time/if I hit production.

So I just need this to be stable enough not to think about it.

Thanks =)

Question: why two private IPv4 addresses?

Hi,

I've set up and am using fck-nat via the Terraform module. My module config looks like this:

  module "fck-nat" {
  source = "git::https://github.com/RaJiska/terraform-aws-fck-nat.git?ref=ab69ccf34629e49033f52c4e6351e188be7a1f8f"

  name      = "${local.label}-fck-nat"
  vpc_id    = aws_vpc.vpc.id
  subnet_id = aws_subnet.public_subnet01.id
  ha_mode   = false # Enables high-availability mode
  #  eip_allocation_ids = ["eipalloc-0137b6eb9d101f063"] # Allocation ID of an existing EIP / see https://github.com/RaJiska/terraform-aws-fck-nat/issues/5
  instance_type = var.instance_type

  update_route_tables = true
  route_tables_ids = {
    "private_rt" = aws_route_table.private_rt.id
  }

  tags = {
    Name = "${local.label}-fck-nat"
  }

  # To ensure proper ordering, add an explicit dependency on the Internet Gateway for the VPC.
  depends_on = [aws_internet_gateway.igw]
}

and I end up with two private IPv4 addresses against the instance:

image

and I'm not sure why. I don't think it's part of the AMI (tested by starting an instance with the AMI and I got only one private IPv4 address) and I've glanced (not studied) the module's Terraform config where it wasn't immediately obvious to me why two private IPv4 addresses are assigned.

Is there a reason why there are two IPv4 addresses assigned to the fck-nat instance when using the Terraform module?

Regards,

Warren.

var.additional_security_group_ids not in use by the module

Just a heads up that var.additional_security_group_ids is not being used by the aws_network_interface resource.

A visible fix is to point security_groups = [aws_security_group.main.id] to security_groups = local.security_groups

Great work with the module!

Architecture

Hello, I'm new to nat instances.

Is the intention with this module, to have 1 module per subnet/AZ in a VPC?

I notice the variables for route table ID's and subnet id's are of type string, and not list. So im thinking i'd need one fck-nat per AZ?

For the HA option - is that HA in the single AZ?

Attaching the same elastic IP not working

Hello and thank you for developing this module! I'm trying to pass eip_allocation_ids so that the NAT instance always has the same public IP but it's not working. I don't see the elastic IPs being associated with the EC2 instances. Here's an example configuration:

resource "aws_eip" "nat" {
  count = length(var.external_subnets)
  vpc   = true
}

module "fck-nat" {
  count = length(var.external_subnets)

  source  = "RaJiska/fck-nat/aws"
  version = "1.2.0"

  name                 = "fck-nat-${count.index}"
  vpc_id               = aws_vpc.main.id
  subnet_id            = element(aws_subnet.external.*.id, count.index)
  
  ami_id               = "ami-00d653f185e930c04"
  instance_type        = "t4g.nano"
  use_spot_instances   = false
  use_cloudwatch_agent = true
  encryption           = true
  update_route_table   = true
  route_table_id       = element(aws_route_table.internal.*.id, count.index)
  ha_mode              = true
  eip_allocation_ids   = [element(aws_eip.nat.*.id, count.index)]
}

I see that the allocation_id is passed in the user data as eip_id=... but for some reason it is not associated with the EC2 as it should be happening here. I tried viewing logs from inside the instance with aws ec2 get-console-output --instance-id ... but didn't have much success as no logs were shown. I'm wondering whether I need to change my configuration to something like

resource "aws_eip" "nat" {
  count = length(var.external_subnets)
  vpc   = true
  network_interface = element(fck-nat.*.eni_id, count.index)
}

which would associate the Elastic IP with the Network Interface but then I'm not sure why this call should be made at all. As a matter of fact, I'm also wondering about those calls as well since the network interface is already attached to the EC2. Maybe there's no need to pass eni_id and eip_id if the infrastructure is already configured (eip and eni attached)? That would also remove the need for the IAM permissions.

Another eip related thing I'm wondering about is this one. Do you think that if eip_allocation_ids is provided there's no need to create an ephemeral public network interface since there's already an elastic IP that will be associated with this instance?

update_route_tables and route_tables_ids error with Unexpected Attribute

When trying to use fck-nat as a module in terraform, documentation says that update_route_table and route_table_id is deprecated. However, the recommended variables update_route_tables and route_tables_ids errors out as Unexpected Attribute.

module "fck-nat" {
  source = "RaJiska/fck-nat/aws"
  name = "fck-nat-${var.availability_zones[count.index]}"
  vpc_id = aws_vpc.main.id
  subnet_id = aws_subnet.public[count.index].id
  use_spot_instances = true
  instance_type = "t4g.nano"
  update_route_tables = true
  route_tables_ids = {
    "private" = aws_route_table.private[count.index].id
  }
}

Allow to use non-arm instances

Hi. I'm trying to run this module with t2.micro, and I can't use it b/c of the wrong (?) arm regex checker. I'm not a master of regex, but for me, it looks a little bit wrong. I was trying to use regex101 but found redundant backslashes.
[a-zA-Z]+\\d+g[a-z]*\\..+ should be [a-zA-Z]+\d+g[a-z]*\..+

╷
│ Error: Error in function call
│
│   on .terraform/modules/fck-nat/main.tf line 2, in locals:
│    2:   is_arm             = regex("[a-zA-Z]+\\d+g[a-z]*\\..+", var.instance_type) == var.instance_type
│     ├────────────────
│     │ while calling regex(pattern, string)
│     │ var.instance_type is "t2.micro"
│
│ Call to function "regex" failed: pattern did not match any part of the given string.

Exclude name from passed tags for asg or check that it's not provided

  tag {
    key                 = "Name"
    value               = var.name
    propagate_at_launch = true
  }

  dynamic "tag" {
    for_each = var.tags

    content {
      key                 = tag.key
      value               = tag.value
      propagate_at_launch = false
    }

It will be good to check here that Name tag is not in the provided map and apply it only if it's not there

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.