Skip to content

Add cloudstack_project resource #167

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ianc769
Copy link

@ianc769 ianc769 commented Apr 3, 2025

Adding project as a terraform managed resource option -> https://cloudstack.apache.org/api/apidocs-4.20/apis/createProject.html

Contributes to #82

Using this code for example:

resource "cloudstack_project" "foo" {
  name         = "terraform-test-project"
  display_text = "Terraform Test Project"
}
+ resource "cloudstack_project" "foo" {
  + display_text = "Terraform Test Project"
  + domain       = (known after apply)
  + id           = (known after apply)
  + name         = "terraform-test-project"
  }
cloudstack_project.foo: Creating...
cloudstack_project.foo: Creation complete after 1s [id=06c584de-8f5f-4c72-8eab-672668e3c165]

image

@ianc769
Copy link
Author

ianc769 commented Apr 14, 2025

I set this up for Cloudstack API 4.20, I see the tests are 4.18 and 4.19.

What's the back version compatibility of this project looking for?

There was a difference in the API between 4.18 and 4.19+ for this resource at a quick glance. So if there is a plan to add 4.20 Acceptance Tests and depreciate 4.18 I will wait for those results.

@ianc769
Copy link
Author

ianc769 commented Jun 11, 2025

Maybe supersedes #152

@ianc769
Copy link
Author

ianc769 commented Jun 12, 2025

@CodeBleu If possible can you kick a test off here? I merged your actions changes from earlier today to hopefully get the acceptance tests actually working

@CodeBleu
Copy link
Collaborator

CodeBleu commented Jun 12, 2025

@CodeBleu If possible can you kick a test off here? I merged your actions changes from earlier today to hopefully get the acceptance tests actually working

@ianc769
I kicked it off

@ianc769 ianc769 marked this pull request as ready for review June 16, 2025 16:41
@ianc769 ianc769 changed the title [WIP] Add CloudStack project resource Add CloudStack project resource Jun 16, 2025
@ianc769
Copy link
Author

ianc769 commented Jun 16, 2025

@CodeBleu Ok I think i resolved all the test issues, thanks for fixing the workflows!
If you can kick tests for this and #181 that would be much appreciated 😄

@ianc769 ianc769 changed the title Add CloudStack project resource Add CloudStack project resource Jul 10, 2025
@ianc769 ianc769 changed the title Add CloudStack project resource Add cloudstack_project resource Jul 14, 2025
Fix issue where getProjectByID() would always return "id not found" while
getProjectByName() could find the same project. CloudStack projects are only
unique within a domain context, so we now include domain ID in lookups.

- Modified getProjectByID() to accept optional domain parameter
- Updated all calls to include domain when available
- Updated test functions accordingly
- Updated documentation to clarify domain requirement for project imports
@ianc769
Copy link
Author

ianc769 commented Jul 17, 2025

After some more in depth testing with all the new resources I'm adding in #181 #195 and #197 I found some issues I had to fix when deleting project resources.

@DaanHoogland DaanHoogland requested a review from Copilot August 6, 2025 08:04
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new cloudstack_project resource to the Terraform CloudStack provider, enabling users to manage CloudStack projects through Terraform. The implementation includes comprehensive CRUD operations, import functionality, and account/user ownership management.

  • Implements the cloudstack_project resource with full lifecycle support
  • Adds comprehensive test coverage for various project scenarios
  • Includes proper documentation and website integration

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cloudstack/resource_cloudstack_project.go Core resource implementation with CRUD operations and ownership management
cloudstack/resource_cloudstack_project_test.go Comprehensive test suite covering basic operations, updates, imports, and edge cases
cloudstack/provider.go Registers the new project resource in the provider
cloudstack/resources.go Adds domain ID lookup support for project operations
website/docs/r/project.html.markdown Complete documentation with examples and parameter descriptions
website/cloudstack.erb Adds navigation link to project resource documentation
scripts/list_accounts_and_users.go Utility script for listing accounts and users (development helper)
README.md Minor formatting and container name corrections
Comments suppressed due to low confidence (1)

cloudstack/resource_cloudstack_project_test.go:431

  • The test configuration for userid testing doesn't actually include a userid parameter, making the test ineffective for validating userid functionality. The test should include a valid userid to properly test this feature.
const testAccCloudStackProject_userid = `

@kiranchavala kiranchavala added this to the v0.6.0 milestone Aug 8, 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.

Improvement request - Support the following resource creation via terraform
3 participants