diff --git a/go.mod b/go.mod index 6e8280740..bb7579546 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/outscale/terraform-provider-outscale go 1.22.0 require ( - github.com/aws/aws-sdk-go v1.53.1 + github.com/aws/aws-sdk-go v1.55.1 github.com/davecgh/go-spew v1.1.1 github.com/go-test/deep v1.0.6 github.com/hashicorp/errwrap v1.1.0 @@ -13,7 +13,7 @@ require ( github.com/hashicorp/terraform-plugin-mux v0.12.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 github.com/nav-inc/datetime v0.1.3 - github.com/outscale/osc-sdk-go/v2 v2.19.0 + github.com/outscale/osc-sdk-go/v2 v2.21.0 github.com/spf13/cast v1.6.0 ) @@ -58,11 +58,11 @@ require ( golang.org/x/crypto v0.23.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.25.0 // indirect - golang.org/x/oauth2 v0.17.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect google.golang.org/grpc v1.62.0 // indirect - google.golang.org/protobuf v1.34.1 // indirect + google.golang.org/protobuf v1.34.2 // indirect ) diff --git a/go.sum b/go.sum index 8cf61ce30..30ec40762 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/aws/aws-sdk-go v1.44.103/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= -github.com/aws/aws-sdk-go v1.53.1 h1:15/i0m9rE8r1q3P4ooHCfZTJtkxwG2Dwqp9JhPaVbs0= -github.com/aws/aws-sdk-go v1.53.1/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= +github.com/aws/aws-sdk-go v1.55.1 h1:ZTNPmbRMxaK5RlTJrBullX9r/rF1MPf3yAJOLlwDiT8= +github.com/aws/aws-sdk-go v1.55.1/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= @@ -142,8 +142,8 @@ github.com/nav-inc/datetime v0.1.3 h1:PaybPUsScX+Cd3TEa1tYpfwU61deCEhMTlCO2hONm1 github.com/nav-inc/datetime v0.1.3/go.mod h1:gKGf5G+cW7qkTo5TC/sieNyz6lYdrA9cf1PNV+pXIOE= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= -github.com/outscale/osc-sdk-go/v2 v2.19.0 h1:lunUeIB0AfklKztI4LH9yTIvG5t/fnRXVzSAZLX9EjY= -github.com/outscale/osc-sdk-go/v2 v2.19.0/go.mod h1:kzhtUErCzKYl87bZ+kDMphDafmnwbsyFJY9iHF7NgNE= +github.com/outscale/osc-sdk-go/v2 v2.21.0 h1:8MqhexV+ALG76CvY8EpuQlr0+hC5VFrWQY4fHqdT358= +github.com/outscale/osc-sdk-go/v2 v2.21.0/go.mod h1:kzhtUErCzKYl87bZ+kDMphDafmnwbsyFJY9iHF7NgNE= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -197,8 +197,8 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= -golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -256,8 +256,8 @@ google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/outscale/resource_outscale_access_key.go b/outscale/resource_outscale_access_key.go index 451889930..be35dede7 100644 --- a/outscale/resource_outscale_access_key.go +++ b/outscale/resource_outscale_access_key.go @@ -92,6 +92,10 @@ func ResourceOutscaleAccessKeyCreate(d *schema.ResourceData, meta interface{}) e d.SetId(*resp.GetAccessKey().AccessKeyId) + if err := d.Set("secret_key", *resp.GetAccessKey().SecretKey); err != nil { + return err + } + if d.Get("state").(string) != "ACTIVE" { if err := updateAccessKey(conn, d.Id(), "INACTIVE"); err != nil { return err @@ -104,12 +108,17 @@ func ResourceOutscaleAccessKeyCreate(d *schema.ResourceData, meta interface{}) e func ResourceOutscaleAccessKeyRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*OutscaleClient).OSCAPI - filter := oscgo.ReadSecretAccessKeyRequest{ - AccessKeyId: d.Id(), + filter := oscgo.FiltersAccessKeys{ + AccessKeyIds: &[]string{d.Id()}, + } + + req := oscgo.ReadAccessKeysRequest{ + Filters: &filter, } - var resp oscgo.ReadSecretAccessKeyResponse + + var resp oscgo.ReadAccessKeysResponse err := resource.Retry(2*time.Minute, func() *resource.RetryError { - rp, httpResp, err := conn.AccessKeyApi.ReadSecretAccessKey(context.Background()).ReadSecretAccessKeyRequest(filter).Execute() + rp, httpResp, err := conn.AccessKeyApi.ReadAccessKeys(context.Background()).ReadAccessKeysRequest(req).Execute() if err != nil { return utils.CheckThrottling(httpResp, err) } @@ -121,28 +130,26 @@ func ResourceOutscaleAccessKeyRead(d *schema.ResourceData, meta interface{}) err return err } - accessKey, ok := resp.GetAccessKeyOk() - if !ok { + accessKey := resp.GetAccessKeys() + if len(accessKey) == 0 { d.SetId("") return nil } - if err := d.Set("access_key_id", accessKey.GetAccessKeyId()); err != nil { + if err := d.Set("access_key_id", accessKey[0].GetAccessKeyId()); err != nil { return err } - if err := d.Set("creation_date", accessKey.GetCreationDate()); err != nil { + if err := d.Set("creation_date", accessKey[0].GetCreationDate()); err != nil { return err } - if err := d.Set("expiration_date", accessKey.GetExpirationDate()); err != nil { + if err := d.Set("expiration_date", accessKey[0].GetExpirationDate()); err != nil { return err } - if err := d.Set("last_modification_date", accessKey.GetLastModificationDate()); err != nil { + if err := d.Set("last_modification_date", accessKey[0].GetLastModificationDate()); err != nil { return err } - if err := d.Set("secret_key", accessKey.GetSecretKey()); err != nil { - return err - } - if err := d.Set("state", accessKey.GetState()); err != nil { + + if err := d.Set("state", accessKey[0].GetState()); err != nil { return err } diff --git a/outscale/resource_outscale_image_launch_permission.go b/outscale/resource_outscale_image_launch_permission.go index 4de6ae4ff..0022ff548 100644 --- a/outscale/resource_outscale_image_launch_permission.go +++ b/outscale/resource_outscale_image_launch_permission.go @@ -140,17 +140,17 @@ func ResourceOutscaleImageLaunchPermissionCreate(d *schema.ResourceData, meta in } log.Printf("Creating Outscale Image Launch Permission, image_id (%+v)", imageID.(string)) - permissionLunch := oscgo.PermissionsOnResourceCreation{} + permissionLaunch := oscgo.PermissionsOnResourceCreation{} if permissionAdditions, ok := d.GetOk("permission_additions"); ok { - permissionLunch.SetAdditions(expandOAPIImagePermission(permissionAdditions)) + permissionLaunch.SetAdditions(expandOAPIImagePermission(permissionAdditions)) } if permissionRemovals, ok := d.GetOk("permission_removals"); ok { - permissionLunch.SetRemovals(expandOAPIImagePermission(permissionRemovals)) + permissionLaunch.SetRemovals(expandOAPIImagePermission(permissionRemovals)) } request := oscgo.UpdateImageRequest{ ImageId: imageID.(string), - PermissionsToLaunch: permissionLunch, + PermissionsToLaunch: &permissionLaunch, } err := resource.Retry(5*time.Minute, func() *resource.RetryError {