Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing options to attach a firewall to the packer instance ? #157

Open
roberto-sebastiano opened this issue Mar 13, 2024 · 4 comments
Open

Comments

@roberto-sebastiano
Copy link

Description

Hello, I don't see a way to attach an Hetzner firewall to the packer instance.

Use Case(s)

I'm building a packer instance on Hetzner that has NFS, this has rcp portmapper opened to the world and I'm receiving alerts from the cloud provider. I should be able to attach an Hetzner firewall to the packer instance like it is already done for all the other VMs I have

Potential configuration

something like firewall_id = number in source "hcloud" ?

Potential References

Thank you

@jooola
Copy link
Member

jooola commented Mar 13, 2024

We are open to merging a pull request for this :)

@roberto-sebastiano
Copy link
Author

Due to time constrains on the project I'm working on, I can't work on this right now.
I can share the workaround for an ubuntu 22.04:

in the "os-setup.sh" (or shell provisioner), put these lines to allow ssh only:

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install iptables -y
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -P INPUT DROP

Keep up the good work,
Roberto

@jooola
Copy link
Member

jooola commented Jun 5, 2024

As a workaround, you can configure a firewall with a label selector, and use this label in the packer configuration:

source "hcloud" "example" {
  server_name = "hcloud-example"
  server_labels = {
    firewall-ssh-only = "enabled"
  }
}

Then for the firewall label selector, you can use: firewall-ssh-only or even firewall-ssh-only=enabled

@roberto-sebastiano
Copy link
Author

I'll give it a try, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants