Skip to content

Conversation

Pearl1594
Copy link
Contributor

@Pearl1594 Pearl1594 commented Aug 26, 2025

Fixes: #114

Tested locally:

terraform {
  required_providers {
    cloudstack = {
      source = "cloudstack/cloudstack"
      version = "0.5.0"
    }
  }
}

provider "cloudstack" {
  api_url    = "http://MS_IP:8080/client/api"
  api_key    = "LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8"
  secret_key = "R6QPwRUz09TVXBjXNwZk7grTjcPtsFRphH6xhN1oPvnc12YUk296t4KHytg8zRLczDA0X5NsLVi4d8rfMMx3y"

}

# Guest network1 for default network used by server
resource "cloudstack_network" "server_nw_01" {
  name                = "terraform-net"
  cidr                = "10.10.0.0/16"
  network_offering    = "DefaultIsolatedNetworkOfferingWithSourceNatService"
  zone                = "103b3230-2dd5-42b3-ad3d-75bc496d170b"
}

# Guest network2 to be added to server as additional network
resource "cloudstack_network" "server_nw_02" {
  name                = "terra-net-2"
  cidr                = "10.20.0.0/16"
  network_offering    = "DefaultIsolatedNetworkOfferingWithSourceNatService"
  zone                = "103b3230-2dd5-42b3-ad3d-75bc496d170b"
}

resource "cloudstack_instance" "server1" {
  depends_on = [ cloudstack_network.server_nw_01, cloudstack_network.server_nw_02 ]
  name             = "server-1"
  service_offering = "Small Instance"
  network_id       = cloudstack_network.server_nw_01.id
  template         = "32550aac-7015-423c-b238-211e5ad93279"
  zone             = "103b3230-2dd5-42b3-ad3d-75bc496d170b"
}

resource "cloudstack_nic" "nic1" {
  network_id         = cloudstack_network.server_nw_02.id
  ip_address         = "10.20.30.15"
  virtual_machine_id = cloudstack_instance.server1.id
  mac_address        = "02:1A:4B:3C:5D:6E"
}

@Pearl1594 Pearl1594 marked this pull request as ready for review August 26, 2025 18:51
Copy link
Member

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm. didn't test.

Copy link
Member

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. tested. it works as expected.

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM

@vishesh92 vishesh92 merged commit 8c28240 into main Aug 28, 2025
67 of 69 checks passed
@vishesh92 vishesh92 deleted the add-addParams-addNicToVM branch August 28, 2025 09:44
ianc769 pushed a commit to ianc769/cloudstack-terraform-provider that referenced this pull request Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot add multiple nics at instances and predefined mac addresses.
3 participants