Skip to content
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

fix: set user_data and backup_unit_id in cube server #688

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Fixes
- Fix documentation rendering of `autoscaling_group` resource and data source, `dbaas_mongo_template` data source and `server_boot_device_selection` resource in Terraform registry
- Fix `application_loadbalancer_forwardingrule` docs typo
- Fix for [#687](https://github.com/ionos-cloud/terraform-provider-ionoscloud/issues/687) by setting `user_data` and `backupunit_id` in `ionoscloud_cube_server`

## 6.5.6
### Fixes
Expand Down
22 changes: 22 additions & 0 deletions ionoscloud/resource_cube_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,28 @@ func resourceCubeServerCreate(ctx context.Context, d *schema.ResourceData, meta
volume.ImageAlias = nil
}

if backupUnitID, ok := d.GetOk("volume.0.backup_unit_id"); ok {
if utils.IsValidUUID(backupUnitID.(string)) {
if image == "" && imageAlias == "" {
diags := diag.FromErr(fmt.Errorf("it is mandatory to provide either public image or imageAlias in conjunction with backup unit id property"))
return diags
}

backupUnitID := backupUnitID.(string)
volume.BackupunitId = &backupUnitID
}
}

if userData, ok := d.GetOk("volume.0.user_data"); ok {
if image == "" && imageAlias == "" {
diags := diag.FromErr(fmt.Errorf("it is mandatory to provide either public image or imageAlias that has cloud-init compatibility in conjunction with backup unit id property "))
return diags
}

userData := userData.(string)
volume.UserData = &userData
}

server.Entities = &ionoscloud.ServerEntities{
Volumes: &ionoscloud.AttachedVolumes{
Items: &[]ionoscloud.Volume{
Expand Down
Loading