I have this error "dial tcp <My IP>:443: connect: connection refused", how can I solve it?

93 Views Asked by At

Hi I am new to Terraform and Proxmox, and I need some help. I have a Proxmox server, in it I have some template VMs and I am trying to use Terraform to deploy more VMs. When I try to do terraform apply I get this error:

Error: Get "https://<My IP address>/api2/json/cluster/resources?type=vm": dial tcp <My IP address>:443: connect: connection refused
with proxmox_vm_qemu.test,
on main.tf line 5, in resource "proxmox_vm_qemu" "test":
5: resource "proxmox_vm_qemu" "test" {

I have this as a main.tf: `resource "proxmox_vm_qemu" "test" {

# VM General Settings
target_node = "pve"
vmid = "100"
name = "vm-test"
desc = "Test deployment VM"

# VM Advanced General Settings
onboot = true 

# VM OS Settings
clone = "ubuntu-template"

# VM System Settings
agent = 1

# VM CPU Settings
cores = 2
sockets = 1
cpu = "kvm64"    

# VM Memory Settings
memory = 2048

# VM Network Settings
network {
    bridge = "vmbr0"
    model  = "virtio"
}

# VM Cloud-Init Settings
os_type = "cloud-init"

# Default User
ciuser = "joana"

# My SSH KEY
sshkeys = <<EOF
<My ssh key>
EOF

}` I have a seperate file with the credentials. This is the provider.tf:

terraform {

    # required_version = ">= 0.13.0"

    required_providers {
        proxmox = {
            source = "telmate/proxmox"
            version = "2.9.11"
        }
    }
}

variable "proxmox_api_url" {
    type = string
}

variable "proxmox_api_token_id" {
    type = string
}

variable "proxmox_api_token_secret" {
    type = string
}

provider "proxmox" {

    pm_api_url = var.proxmox_api_url
    pm_api_token_id = var.proxmox_api_token_id
    pm_api_token_secret = var.proxmox_api_token_secret

    # (Optional) Skip TLS Verification
    pm_tls_insecure = true

}

I have seen many suggestions for this issue but none have worked for me. I think I am missing somethings in the code or have some stuff wrong. Thank you so much in advance.

0

There are 0 best solutions below