diff --git a/docs/resources/s3_bucket_policy.md b/docs/resources/s3_bucket_policy.md index 621e5c84f..b9c2a6376 100644 --- a/docs/resources/s3_bucket_policy.md +++ b/docs/resources/s3_bucket_policy.md @@ -15,8 +15,12 @@ Manages **S3 Buckets policies** on IonosCloud. ```hcl +resource "ionoscloud_s3_bucket" "example" { + name = "example" +} + resource "ionoscloud_s3_bucket_policy" "example" { - bucket = "your_bucket_name_here" + bucket = ionoscloud_s3_bucket.example.name policy = jsonencode({ Version = "2012-10-17" Statement = [ diff --git a/ionoscloud/provider.go b/ionoscloud/provider.go index bd6063aeb..6cb862887 100644 --- a/ionoscloud/provider.go +++ b/ionoscloud/provider.go @@ -293,9 +293,14 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa clientOpts.Password = password.(string) clientOpts.Token = token.(string) clientOpts.Url = cleanedUrl - clientOpts.Version = ionoscloud.Version clientOpts.TerraformVersion = terraformVersion + return NewSDKBundleClient(clientOpts), nil +} + +// NewSDKBundleClient returns a new SDK bundle client +func NewSDKBundleClient(clientOpts ClientOptions) interface{} { + clientOpts.Version = ionoscloud.Version return services.SdkBundle{ CDNClient: NewClientByType(clientOpts, cdnClient).(*cdnService.Client), AutoscalingClient: NewClientByType(clientOpts, autoscalingClient).(*autoscalingService.Client), @@ -313,7 +318,7 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa APIGatewayClient: NewClientByType(clientOpts, apiGatewayClient).(*apiGatewayService.Client), VPNClient: NewClientByType(clientOpts, vpnClient).(*vpn.Client), InMemoryDBClient: NewClientByType(clientOpts, inMemoryDBClient).(*inmemorydb.InMemoryDBClient), - }, nil + } } type clientType int @@ -338,6 +343,7 @@ const ( inMemoryDBClient ) +// NewClientByType returns a new client based on the client type func NewClientByType(clientOpts ClientOptions, clientType clientType) interface{} { switch clientType { case ionosClient: