cloudstack-terraform-provider
cloudstack-terraform-provider copied to clipboard
Service offering resource update
Overview
This PR completely updates the cloudstack_service_offering resource to support CloudStack API version 4.21, achieving 100% SDK coverage with all 54 parameters from CreateServiceOfferingParams fully implemented.
Motivation
I needed to update the Service Offering API to the latest CloudStack version (4.21) to support modern features like GPU configuration, advanced IOPS settings, and dynamic scaling. The existing implementation was missing critical parameters and had several drift issues.
What's New
1. Complete API v4.21 Coverage (54/54 Parameters)
All parameters from CloudStack Go SDK v2 CreateServiceOfferingParams are now implemented:
CPU & Memory:
cpu_number,cpu_speed,memorycustomized,min_cpu_number,max_cpu_numbermin_memory,max_memory
GPU Support (NEW):
gpu_card- GPU card name (maps togpucardid)gpu_type- vGPU profile UUID (maps tovgpuprofileid)gpu_count- Number of GPUs
Storage:
storage_type,storage_tags,host_tagsroot_disk_size,encrypt_rootprovisioning_type,cache_mode
IOPS & Bandwidth (12 parameters):
bytes_read_rate,bytes_write_ratebytes_read_rate_max,bytes_write_rate_maxbytes_read_rate_max_length,bytes_write_rate_max_lengthiops_read_rate,iops_write_rateiops_read_rate_max,iops_write_rate_maxiops_read_rate_max_length,iops_write_rate_max_length
Performance:
disk_iops_min,disk_iops_maxhypervisor_snapshot_reserveoffer_ha,limit_cpu_usedynamic_scaling_enabledcustomized_iops
System & Domain:
is_system,system_vm_typezone_id,domain_idis_volatile,deployment_planner
Advanced:
service_offering_details(map for custom settings)
2. Bug Fixes
Fixed service_offering_details Drift
- Problem: CloudStack adds system keys (
External:key,External:value,purge.db.entities) causing state drift - Solution: Implemented filtering in Read function (lines 847-863) to only track user-configured keys
Fixed customized Parameter Logic
- Problem: Incorrect handling of Fixed vs Custom offerings
- Solution: Smart conditional logic based on CPU/memory presence:
- If
cpu_number+memoryprovided →customized = false(Fixed Offering) - If
customized = true+ min/max → Custom Constrained - If
customized = true+ no limits → Custom Unconstrained
- If
Identified ForceNew Parameters (47 of 54)
- Problem: Most CloudStack Service Offering parameters are immutable after creation
- Solution: Added
ForceNew: trueto 47 parameters based on CloudStack API limitations - Updateable: Only
display_text,host_tags, andstorage_tagscan be updated in-place
3. Comprehensive Testing
Added 4 new tests covering all CloudStack UI offering types:
TestAccServiceOfferingTypeFixed- Fixed CPU/memoryTestAccServiceOfferingTypeCustomConstrained- Customizable with limitsTestAccServiceOfferingTypeCustomUnconstrained- Fully customizableTestAccServiceOfferingAllUITypes- All types together
Total: 17 tests (13 existing + 4 new)
4. Complete Documentation
Created comprehensive documentation in website/docs/r/service_offering.html.markdown:
- Detailed explanation of all 3 offering types with decision tree
- GPU configuration examples (A6000, A100, H100, RTX 4090, Multi-GPU)
- IOPS/bandwidth configuration examples
- High-performance offerings
- ForceNew behavior documentation
- CloudStack API behavior notes