Skip to content

Commit

Permalink
Merge branch 'master' into feat/move_psql_to_bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiGuranIonos authored Jan 29, 2025
2 parents 5574944 + 6ca4426 commit 9dd94f6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
17 changes: 10 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
## 6.7.1
### Refactor
- Move postgresql to sdk-go-bundle.

## 6.7.0
### Fixes
- Fix [#735](https://github.com/ionos-cloud/terraform-provider-ionoscloud/issues/735) by reading all values for `api_subnet_allow_list`, not only non-nill values.
- Fix [#748](https://github.com/ionos-cloud/terraform-provider-ionoscloud/issues/748) by removing unecessary error check
- S3 key creation fails with 422 if s3 key not found. Add function to check for that specific response from the API.
### Features
- Add new read-only attribute: `ipv4_cidr_block` to `ionoscloud_lan` resource and data source.
- Make `volume` optional for `ionoscloud_server` resource
- Make `volume` optional for `ionoscloud_server` resource.
- `name` attribute for `ionoscloud_auto_certificate` resource is now required.
- Move postgresql to sdk-go-bundle.
- Add `allow_replace` field to `ionoscloud_pg_cluster` resource.
### Docs
- Changed dead link in MongoDB cluster docs.

## 6.6.9
### Features
Expand Down Expand Up @@ -1025,9 +1034,3 @@ FEATURES:
https://nfs.us-las.ionos.com (Las Vegas, USA)
https://nfs.us-ewr.ionos.com (Newark, USA)
https://nfs.us-mci.ionos.com (Lenexa, USA)

### Fixes:
- Changed Dead link in MongoDB cluster docs

### Features:
- Add `allow_replace` field to `ionoscloud_pg_cluster` resource.
22 changes: 18 additions & 4 deletions ionoscloud/resource_s3_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ionoscloud

import (
"context"
"errors"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -102,7 +103,7 @@ func resourceS3KeyRead(ctx context.Context, d *schema.ResourceData, meta interfa
logApiRequestTime(apiResponse)

if err != nil {
if httpNotFound(apiResponse) {
if httpNotFound(apiResponse) || isS3KeyNotFound(err) {
d.SetId("")
return nil
}
Expand Down Expand Up @@ -141,7 +142,7 @@ func resourceS3KeyUpdate(ctx context.Context, d *schema.ResourceData, meta inter
logApiRequestTime(apiResponse)

if err != nil {
if httpNotFound(apiResponse) {
if httpNotFound(apiResponse) || isS3KeyNotFound(err) {
d.SetId("")
return nil
}
Expand All @@ -164,7 +165,7 @@ func resourceS3KeyDelete(ctx context.Context, d *schema.ResourceData, meta inter
logApiRequestTime(apiResponse)

if err != nil {
if httpNotFound(apiResponse) {
if httpNotFound(apiResponse) || isS3KeyNotFound(err) {
d.SetId("")
return nil
}
Expand All @@ -178,6 +179,10 @@ func resourceS3KeyDelete(ctx context.Context, d *schema.ResourceData, meta inter
s3KeyDeleted, dsErr := s3KeyDeleted(ctx, client, d)

if dsErr != nil {
if isS3KeyNotFound(dsErr) {
log.Printf("[INFO] Successfully deleted Object Storage key: %s", d.Id())
return nil
}
diags := diag.FromErr(fmt.Errorf("error while checking deletion status of Object Storage key %s: %w", d.Id(), dsErr))
return diags
}
Expand All @@ -200,6 +205,15 @@ func resourceS3KeyDelete(ctx context.Context, d *schema.ResourceData, meta inter
return nil
}

// isS3KeyNotFound needed because api returns 422 instead of 404 on key being not found. will be removed once API issue is fixed
func isS3KeyNotFound(err error) bool {
var genericOpenAPIError ionoscloud.GenericOpenAPIError
if !errors.As(err, &genericOpenAPIError) {
return false
}
return genericOpenAPIError.StatusCode() == 422 && strings.Contains(genericOpenAPIError.Error(), "[VDC-21-2] The access key cannot be found, please double-check the key id and try again.")
}

func s3KeyDeleted(ctx context.Context, client *ionoscloud.APIClient, d *schema.ResourceData) (bool, error) {
userId := d.Get("user_id").(string)
_, apiResponse, err := client.UserS3KeysApi.UmUsersS3keysFindByKeyId(ctx, userId, d.Id()).Execute()
Expand Down Expand Up @@ -242,7 +256,7 @@ func resourceS3KeyImport(ctx context.Context, d *schema.ResourceData, meta inter
logApiRequestTime(apiResponse)

if err != nil {
if httpNotFound(apiResponse) {
if httpNotFound(apiResponse) || isS3KeyNotFound(err) {
d.SetId("")
return nil, fmt.Errorf("unable to find Object Storage key %q", keyId)
}
Expand Down
4 changes: 0 additions & 4 deletions ionoscloud/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ func resourceUserRead(ctx context.Context, d *schema.ResourceData, meta interfac
return diag.FromErr(err)
}

if err = d.Set("group_ids", getUserGroups(&user)); err != nil {
return diag.FromErr(err)
}

return nil
}

Expand Down

0 comments on commit 9dd94f6

Please sign in to comment.