skytap / terraform-provider-skytap

Terraform Skytap provider
https://www.terraform.io/docs/providers/skytap/
Mozilla Public License 2.0
4 stars 11 forks source link

Referencing a specific network interface and published service #7

Closed ja6a closed 5 years ago

ja6a commented 5 years ago

As a user - it is not clear how to reference a specific network interface given that it is represented by a set. Ditto a published service within a network interface. Access to these resources is required to provision external services, e.g., ssh access. Previously this was done using list indexing: e.g.

${skytap_vm.cassandra1.network_interface.0.published_service.0.external_ip}

Solution: 1) provide a name for the published service 2) add an argument which is a map - keyed on the name - computed with the properties of each published service.

Note: it is up to the user to keep each published service with a unique name

resource "skytap_vm" "my_vm" {
    "network_interface" = {
        "interface_type" = "vmxnet3"
         "network_id"     = "${skytap_network.dev_network.id}"
         "ip"         = "10.0.3.2"
         "hostname" = "myhost2"

        "published_service" = {
            "name" = "ssh" # required
            "internal_port" = 22
            "internal_ip" = "10.0.0.1"
        }
        "published_service" = {
            "name" = "http" # required
            "internal_port" = 80
            "internal_ip" = "10.0.0.1"
        }
    }
}

output "external_svc_ssh_port" {
  value = "${skytap_vm.my_vm.published_services.ssh.external_port}"
}
output "external_svc_ssh_address" {
  value = "${skytap_vm.my_vm.published_services.ssh.external_ip}"
}
ja6a commented 5 years ago

relevant comment: https://github.com/terraform-providers/terraform-provider-skytap/issues/4#issuecomment-447112882

ja6a commented 5 years ago

Relevant PR: #5