Skip to content

Conversation

weizhouapache
Copy link
Member

@weizhouapache weizhouapache commented Aug 26, 2025

This fixes #162

  • Create a vpc in project
# cat new-vpc-project.tf
resource "cloudstack_vpc" "new-project-vpc" {
  project = "project-001"
  name = "project-vpc2"
  cidr = "172.17.0.0/20"
  vpc_offering = "Default VPC offering"
  zone         = "ref-trl-8888-k-Mol8-wei-zhou"
}

# terraform apply 
cloudstack_vpc.new-project-vpc: Refreshing state... [id=aeb4cfa1-2696-4d87-aa06-335dd83a471a]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # cloudstack_vpc.new-project-vpc will be created
  + resource "cloudstack_vpc" "new-project-vpc" {
      + cidr           = "172.17.0.0/20"
      + display_text   = (known after apply)
      + id             = (known after apply)
      + name           = "project-vpc2"
      + network_domain = (known after apply)
      + project        = "project-001"
      + source_nat_ip  = (known after apply)
      + tags           = (known after apply)
      + vpc_offering   = "Default VPC offering"
      + zone           = "ref-trl-8888-k-Mol8-wei-zhou"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

cloudstack_vpc.new-project-vpc: Creating...
cloudstack_vpc.new-project-vpc: Still creating... [00m10s elapsed]
cloudstack_vpc.new-project-vpc: Still creating... [00m20s elapsed]
cloudstack_vpc.new-project-vpc: Still creating... [00m30s elapsed]
cloudstack_vpc.new-project-vpc: Still creating... [00m40s elapsed]
cloudstack_vpc.new-project-vpc: Still creating... [00m50s elapsed]
cloudstack_vpc.new-project-vpc: Creation complete after 56s [id=aeb4cfa1-2696-4d87-aa06-335dd83a471a]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
  • get vpc in project
# cat vpc-project.tf 
data "cloudstack_vpc" "project-vpc2" {
  project = "project-001"
  filter{
    name  = "cidr"
    value = "172.17.0.0/20"
  }
  filter{
    name  = "name"
    value = "project-vpc2"
  }
}

# terraform apply 
data.cloudstack_vpc.project-vpc2: Reading...
cloudstack_vpc.new-project-vpc: Refreshing state... [id=aeb4cfa1-2696-4d87-aa06-335dd83a471a]
data.cloudstack_vpc.project-vpc2: Read complete after 0s [id=aeb4cfa1-2696-4d87-aa06-335dd83a471a]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

@weizhouapache
Copy link
Member Author

this could be extended to support other resources in project

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.

This might require changes in docs and tests as well.

@weizhouapache weizhouapache changed the title data: get vpc in project by projectid data: get vpc in project by project name Aug 26, 2025
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.

@weizhouapache
Copy link
Member Author

This might require changes in docs and tests as well.

@vishesh92
updated the doc

unfortunately there is no resource for project, cannot add test for project resources for now
depends on #167

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. Works as expected.

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@vishesh92 vishesh92 merged commit d131aa1 into apache:main Aug 27, 2025
45 of 68 checks passed
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.

Error with regex using vpc datasource
3 participants