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

[BUG] public_ip_required ignored via terraform provider for creating instances #357

Closed
russivo opened this issue Nov 28, 2024 · 1 comment · Fixed by #358
Closed

[BUG] public_ip_required ignored via terraform provider for creating instances #357

russivo opened this issue Nov 28, 2024 · 1 comment · Fixed by #358
Assignees
Labels
bug Something isn't working

Comments

@russivo
Copy link

russivo commented Nov 28, 2024

Description

On creating an instance via the terraform provider (1.1.3), the public_ip_required attribute is ignored. Documentation suggests the correct responses are "create" and "none", with "create" being the default.

resource "civo_instance" "hidden-vm" {
    hostname = "hidden-vm"
    region = "LON1"
    firewall_id = civo_firewall.fw-a.id
    size = element(data.civo_size.xsmall.sizes, 0).name
    disk_image = element(data.civo_disk_image.ubuntu.diskimages, 0).id
    sshkey_id = data.civo_ssh_key.rss-civo.id
    public_ip_required = "none"
}

This creates the following instance - with a Private and Public IP, as opposed to just a Private IP:

# civo instance show hidden-vm
              ID : a9983759-7108-4219-b1a3-f0c639eb080f
        Hostname : hidden-vm
          Status : ACTIVE
            Size : g3.xsmall
     Volume Type : ms-xfs-2-replicas
       Cpu Cores : 1
             Ram : 1024
        SSD disk : 25
          Region : lon1
      Network ID : 68ec754d-4065-4902-97ac-2b48a50f7055
   Disk image ID : ubuntu-noble
    Initial User : civo
Initial Password :
      SSH Key ID : 5d4489d0-1a01-4efa-8f70-17902f0edcbf
     Firewall ID : 82bbc4c9-1d98-430d-ba59-4fb6c6795d27
            Tags :
      Created At : Wed, 27 Nov 2024 12:01:52 UTC
      Private IP : 192.168.1.6
       Public IP : 74.220.17.198

Alternatively, creating a VM through the dashboard and selecting "None" as the Public IP Address, we get the following:

# civo instance show withered-fog-15429930
              ID : a67c81e5-6a9d-4661-b6c2-d3fa90e61824
        Hostname : withered-fog-15429930
          Status : ACTIVE
            Size : g4s.xsmall
     Volume Type : ms-xfs-2-replicas
       Cpu Cores : 1
             Ram : 1024
        SSD disk : 25
          Region : lon1
      Network ID : 68ec754d-4065-4902-97ac-2b48a50f7055
   Disk image ID : ubuntu-noble
    Initial User : civo
Initial Password :
      SSH Key ID : 5d4489d0-1a01-4efa-8f70-17902f0edcbf
     Firewall ID : 82bbc4c9-1d98-430d-ba59-4fb6c6795d27
            Tags :
      Created At : Wed, 27 Nov 2024 12:08:55 UTC
      Private IP : 192.168.1.8
       Public IP :

Acceptance Criteria

  • Ensure that the instance is created by the terraform provider without a public IP if public_ip_required is set to "none"
@russivo russivo added the bug Something isn't working label Nov 28, 2024
@russivo
Copy link
Author

russivo commented Dec 2, 2024

FYI - I've also found a weird inconsistency with the CLI while trying to work around the TF provider issue that may be relevant. On reflection, it may be that the issue is in the API rather than the TF/CLI, because while I can get the outcome required through the Web UI, it may be avoiding the issue simply because it's slower - whereas the TF provider and scripted CLI issue instructions faster.

I've got a script that issues the following commands:

civo region current lon1
civo network create --cidr-v4 10.33.44.0/24 --create-default-firewall int-net-a
civo firewall rename "int-net-a - Default" fw-a
civo instance create -r int-net-a -l fw-a -s vpn-server -p create -i g4s.xsmall -t ubuntu-noble -k rss-civo -u civo vpn-server
civo instance create -r int-net-a -l fw-a -s hidden-vm-a -p none -i g4s.xsmall -t ubuntu-noble -k rss-civo -u civo hidden-vm-a

The partially successful outcomes are:

  • Network with 10.33.44.0/24 as the IP range called "int-net-a" - correct
  • The default firewall on that network renamed to "fw-a" - correct
  • One instance called "vpn-server" on that network with a public IP and a private IP - correct
  • One instance called "hidden-vm-a" on that network with only a public IP and no private IP - failed - it generates hidden-vm-a with a public IP.

However, if I add "sleep 300" to wait 5 minutes before running the command to create "hidden-vm-a", it generates hidden-vm-a without a public IP, like it's supposed to:

civo region current lon1
civo network create --cidr-v4 10.33.44.0/24 --create-default-firewall int-net-a
civo firewall rename "int-net-a - Default" fw-a
civo instance create -r int-net-a -l fw-a -s vpn-server -p create -i g4s.xsmall -t ubuntu-noble -k rss-civo -u civo vpn-server
echo "Sleeping for 5 mins"
sleep 300
civo instance create -r int-net-a -l fw-a -s hidden-vm-a -p none -i g4s.xsmall -t ubuntu-noble -k rss-civo -u civo hidden-vm-a

The fully successful outcomes are:

  • Network with 10.33.44.0/24 as the IP range called "int-net-a" - correct
  • The default firewall on that network renamed to "fw-a" - correct
  • One instance called "vpn-server" on that network with a public IP and a private IP - correct
  • One instance called "hidden-vm-a" on that network with only a public IP and no private IP - correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants