jeanvetorello opened a new pull request, #248:
URL: https://github.com/apache/cloudstack-terraform-provider/pull/248
# CloudStack Quota API Implementation
## Summary
This PR implements comprehensive support for CloudStack Quota APIs in the
Terraform CloudStack provider, enabling users to manage quota tariffs and
monitor quota usage through Terraform.
## Features Added
### Data Sources
- **`cloudstack_quota`** - Retrieve quota summary for accounts/domains
- **`cloudstack_quota_enabled`** - Check if quota plugin is enabled
- **`cloudstack_quota_tariff`** - Query existing quota tariffs with filtering
### Resources
- **`cloudstack_quota_tariff`** - Full CRUD operations for quota tariff
management
- Create/Update/Delete tariffs
- Activation rules support
- Import existing tariffs
- Schema validation
## Technical Implementation
### Core Components
- Complete CRUD operations using CloudStack Go client v2.18.1
- Robust error handling and validation
- Lifecycle management with ForceNew attributes
- Import functionality for existing resources
### Schema Features
- **Usage Types**: Support for all CloudStack usage types (1-25)
- **Activation Rules**: Complex pricing rules based on service offerings
- **Validation**: Input validation for negative values and invalid types
- **Lifecycle**: Proper resource recreation when needed
## Testing Coverage
### Acceptance Tests (11 total)
- **Data Sources**: Basic and filtered queries for all data sources
- **Resource CRUD**: Create, Read, Update, Delete, Import operations
- **Validation**: Invalid input handling and error scenarios
- **Activation Rules**: Simple and complex pricing rules
### Manual Testing Scenarios
- ✅ Real CloudStack integration verified
- ✅ All CRUD operations tested
- ✅ Complex activation rules validated
- ✅ Import/export functionality confirmed
- ✅ Edge cases and error handling tested
## Documentation
### Website Documentation
- Complete markdown documentation for all resources and data sources
- Usage examples and configuration options
- Import instructions and best practices
### Examples
- **11 example configurations** covering:
- Basic tariff creation
- Multiple tariffs management
- Complex activation rules
- Lifecycle management
- Import scenarios
- Validation examples
## Code Quality
### Standards Compliance
- Follows Terraform provider patterns
- Consistent with existing CloudStack provider code
- Proper Go formatting and conventions
- Comprehensive error handling
### Dependencies
- Uses existing CloudStack Go client
- No new external dependencies
- Compatible with current provider architecture
## Use Cases
This implementation enables:
1. **Cost Management**: Define pricing for CloudStack resources
2. **Billing Automation**: Automated tariff management through Terraform
3. **Multi-tenant Pricing**: Different pricing rules per service offering
4. **Quota Monitoring**: Track quota usage across accounts/domains
## Breaking Changes
None - This is a new feature addition with no impact on existing
functionality.
## Checklist
- [x] All tests pass
- [x] Documentation complete
- [x] Examples provided
- [x] Real CloudStack integration tested
- [x] Import functionality working
- [x] Schema validation implemented
- [x] Error handling robust
## Related APIs
Implements CloudStack APIs:
- `quotaSummary`
- `quotaIsEnabled`
- `quotaTariffList`
- `quotaTariffCreate`
- `quotaTariffUpdate`
- `quotaTariffDelete`
## How to Test
```bash
# Run acceptance tests
TF_ACC=1 go test -v ./cloudstack -run "TestAccCloudStackQuota"
# Test specific resource
TF_ACC=1 go test -v ./cloudstack -run "TestAccCloudStackQuotaTariff"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]