Fix/stackittpr 102 objectstorage handling region in individual resources (#711)

* Revert "fix: make resource/data-source specific region attribute read-only (#682)"

This reverts commit 3e8dcc542b.

* fix: Support individual regions

* fix: review findings
This commit is contained in:
Rüdiger Schmitz 2025-03-12 10:49:47 +01:00 committed by GitHub
parent 81f876adea
commit c257ac49e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
105 changed files with 176 additions and 143 deletions

View file

@ -124,7 +124,7 @@ func (r *barResource) Configure(ctx context.Context, req resource.ConfigureReque
} else {
apiClient, err = foo.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.DefaultRegion),
)
}

View file

@ -26,6 +26,9 @@ data "stackit_objectstorage_bucket" "example" {
- `name` (String) The bucket name. It must be DNS conform.
- `project_id` (String) STACKIT Project ID to which the bucket is associated.
### Optional
- `region` (String) The resource region. If not defined, the provider region is used.
### Read-Only

View file

@ -28,6 +28,9 @@ data "stackit_objectstorage_credentials_group" "example" {
- `credential_id` (String) The credential ID.
- `credentials_group_id` (String) The credential group ID.
- `project_id` (String) STACKIT Project ID to which the credential group is associated.
### Optional
- `region` (String) The resource region. If not defined, the provider region is used.
### Read-Only

View file

@ -25,12 +25,12 @@ data "stackit_objectstorage_credentials_group" "example" {
### Required
- `project_id` (String) Object Storage Project ID to which the credentials group is associated.
- `region` (String) The resource region. If not defined, the provider region is used.
### Optional
- `credentials_group_id` (String) The credentials group ID.
- `name` (String) The credentials group's display name.
- `region` (String) The resource region. If not defined, the provider region is used.
### Read-Only

View file

@ -154,6 +154,7 @@ Note: AWS specific checks must be skipped as they do not work on STACKIT. For de
- `argus_custom_endpoint` (String, Deprecated) Custom endpoint for the Argus service
- `authorization_custom_endpoint` (String) Custom endpoint for the Membership service
- `credentials_path` (String) Path of JSON from where the credentials are read. Takes precedence over the env var `STACKIT_CREDENTIALS_PATH`. Default value is `~/.stackit/credentials.json`.
- `default_region` (String) Region will be used as the default location for regional services. Not all services require a region, some are global
- `dns_custom_endpoint` (String) Custom endpoint for the DNS service
- `enable_beta_resources` (Boolean) Enable beta resources. Default is false.
- `iaas_custom_endpoint` (String) Custom endpoint for the IaaS service
@ -169,7 +170,7 @@ Note: AWS specific checks must be skipped as they do not work on STACKIT. For de
- `private_key_path` (String) Path for the private RSA key used for authentication, relevant for the key flow. It takes precedence over the private key that is included in the service account key.
- `rabbitmq_custom_endpoint` (String) Custom endpoint for the RabbitMQ service
- `redis_custom_endpoint` (String) Custom endpoint for the Redis service
- `region` (String) Region will be used as the default location for regional services. Not all services require a region, some are global
- `region` (String, Deprecated) Region will be used as the default location for regional services. Not all services require a region, some are global
- `resourcemanager_custom_endpoint` (String) Custom endpoint for the Resource Manager service
- `secretsmanager_custom_endpoint` (String) Custom endpoint for the Secrets Manager service
- `server_backup_custom_endpoint` (String) Custom endpoint for the Server Backup service

View file

@ -14,9 +14,11 @@ import (
const Separator = ","
type ProviderData struct {
RoundTripper http.RoundTripper
ServiceAccountEmail string // Deprecated: ServiceAccountEmail is not required and will be removed after 12th June 2025.
RoundTripper http.RoundTripper
ServiceAccountEmail string // Deprecated: ServiceAccountEmail is not required and will be removed after 12th June 2025.
// Deprecated: Use DefaultRegion instead
Region string
DefaultRegion string
ArgusCustomEndpoint string
AuthorizationCustomEndpoint string
DnsCustomEndpoint string
@ -41,6 +43,17 @@ type ProviderData struct {
EnableBetaResources bool
}
// GetRegion returns the effective region for the provider, falling back to the deprecated _region_ attribute
func (pd *ProviderData) GetRegion() string {
if pd.DefaultRegion != "" {
return pd.DefaultRegion
} else if pd.Region != "" {
return pd.Region
}
// final fallback
return "eu01"
}
// DiagsToError Converts TF diagnostics' errors into an error with a human-readable description.
// If there are no errors, the output is nil
func DiagsToError(diags diag.Diagnostics) error {

View file

@ -73,7 +73,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = argus.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -62,7 +62,7 @@ func (d *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = argus.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -362,7 +362,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = argus.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -64,7 +64,7 @@ func (d *scrapeConfigDataSource) Configure(ctx context.Context, req datasource.C
} else {
apiClient, err = argus.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -137,7 +137,7 @@ func (r *scrapeConfigResource) Configure(ctx context.Context, req resource.Confi
} else {
apiClient, err = argus.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -68,7 +68,7 @@ func (d *affinityGroupDatasource) Configure(ctx context.Context, req datasource.
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -94,7 +94,7 @@ func (r *affinityGroupResource) Configure(ctx context.Context, req resource.Conf
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -93,7 +93,7 @@ func (d *imageDataSource) Configure(ctx context.Context, req datasource.Configur
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -153,7 +153,7 @@ func (r *imageResource) Configure(ctx context.Context, req resource.ConfigureReq
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -72,7 +72,7 @@ func (d *keyPairDataSource) Configure(ctx context.Context, req datasource.Config
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -89,7 +89,7 @@ func (r *keyPairResource) Configure(ctx context.Context, req resource.ConfigureR
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -86,7 +86,7 @@ func (d *networkDataSource) Configure(ctx context.Context, req datasource.Config
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -100,7 +100,7 @@ func (r *networkResource) Configure(ctx context.Context, req resource.ConfigureR
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -77,7 +77,7 @@ func (d *networkAreaDataSource) Configure(ctx context.Context, req datasource.Co
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -118,7 +118,7 @@ func (r *networkAreaResource) Configure(ctx context.Context, req resource.Config
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -74,7 +74,7 @@ func (d *networkAreaRouteDataSource) Configure(ctx context.Context, req datasour
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -93,7 +93,7 @@ func (r *networkAreaRouteResource) Configure(ctx context.Context, req resource.C
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -75,7 +75,7 @@ func (d *networkInterfaceDataSource) Configure(ctx context.Context, req datasour
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -103,7 +103,7 @@ func (r *networkInterfaceResource) Configure(ctx context.Context, req resource.C
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -88,7 +88,7 @@ func (r *networkInterfaceAttachResource) Configure(ctx context.Context, req reso
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -74,7 +74,7 @@ func (d *publicIpDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -92,7 +92,7 @@ func (r *publicIpResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -90,7 +90,7 @@ func (r *publicIpAssociateResource) Configure(ctx context.Context, req resource.
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -87,7 +87,7 @@ func (d *publicIpRangesDataSource) Configure(ctx context.Context, req datasource
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -74,7 +74,7 @@ func (d *securityGroupDataSource) Configure(ctx context.Context, req datasource.
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -96,7 +96,7 @@ func (r *securityGroupResource) Configure(ctx context.Context, req resource.Conf
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -74,7 +74,7 @@ func (d *securityGroupRuleDataSource) Configure(ctx context.Context, req datasou
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -140,7 +140,7 @@ func (r *securityGroupRuleResource) Configure(ctx context.Context, req resource.
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -98,7 +98,7 @@ func (d *serverDataSource) Configure(ctx context.Context, req datasource.Configu
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -181,7 +181,7 @@ func (r *serverResource) Configure(ctx context.Context, req resource.ConfigureRe
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -88,7 +88,7 @@ func (r *networkInterfaceAttachResource) Configure(ctx context.Context, req reso
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -75,7 +75,7 @@ func (d *volumeDataSource) Configure(ctx context.Context, req datasource.Configu
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -129,7 +129,7 @@ func (r *volumeResource) Configure(ctx context.Context, req resource.ConfigureRe
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -90,7 +90,7 @@ func (r *volumeAttachResource) Configure(ctx context.Context, req resource.Confi
} else {
apiClient, err = iaas.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -78,7 +78,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = loadbalancer.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -64,7 +64,7 @@ func (r *loadBalancerDataSource) Configure(ctx context.Context, req datasource.C
} else {
apiClient, err = loadbalancer.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -205,7 +205,7 @@ func (r *loadBalancerResource) Configure(ctx context.Context, req resource.Confi
} else {
apiClient, err = loadbalancer.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -78,7 +78,7 @@ func (r *observabilityCredentialResource) Configure(ctx context.Context, req res
} else {
apiClient, err = loadbalancer.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -60,7 +60,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
} else {
apiClient, err = logme.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -80,7 +80,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = logme.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = logme.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -142,7 +142,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = logme.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
} else {
apiClient, err = mariadb.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -83,7 +83,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = mariadb.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = mariadb.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -112,7 +112,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = mariadb.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -62,7 +62,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = mongodbflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -144,7 +144,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = mongodbflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -75,7 +75,7 @@ func (r *userDataSource) Configure(ctx context.Context, req datasource.Configure
} else {
apiClient, err = mongodbflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -83,7 +83,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
} else {
apiClient, err = mongodbflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -84,7 +84,7 @@ func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
"project_id": "STACKIT Project ID to which the bucket is associated.",
"url_path_style": "URL in path style.",
"url_virtual_hosted_style": "URL in virtual hosted style.",
"region": "The resource region. Read-only attribute that reflects the provider region.",
"region": "The resource region. If not defined, the provider region is used.",
}
resp.Schema = schema.Schema{
@ -117,8 +117,7 @@ func (r *bucketDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
},
"region": schema.StringAttribute{
// the region cannot be found automatically, so it has to be passed
Optional: false,
Computed: true,
Optional: true,
Description: descriptions["region"],
},
},
@ -137,7 +136,7 @@ func (r *bucketDataSource) Read(ctx context.Context, req datasource.ReadRequest,
bucketName := model.Name.ValueString()
var region string
if utils.IsUndefined(model.Region) {
region = r.providerData.Region
region = r.providerData.GetRegion()
} else {
region = model.Region.ValueString()
}

View file

@ -71,7 +71,7 @@ func (r *bucketResource) ModifyPlan(ctx context.Context, req resource.ModifyPlan
return
}
utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.Region, resp)
utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
if resp.Diagnostics.HasError() {
return
}
@ -132,7 +132,7 @@ func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, res
"project_id": "STACKIT Project ID to which the bucket is associated.",
"url_path_style": "URL in path style.",
"url_virtual_hosted_style": "URL in virtual hosted style.",
"region": "The resource region. Read-only attribute that reflects the provider region.",
"region": "The resource region. If not defined, the provider region is used.",
}
resp.Schema = schema.Schema{
@ -175,7 +175,7 @@ func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, res
Computed: true,
},
"region": schema.StringAttribute{
Optional: false,
Optional: true,
// must be computed to allow for storing the override value from the provider
Computed: true,
Description: descriptions["region"],
@ -249,7 +249,7 @@ func (r *bucketResource) Read(ctx context.Context, req resource.ReadRequest, res
bucketName := model.Name.ValueString()
region := model.Region.ValueString()
if region == "" {
region = r.providerData.Region
region = r.providerData.GetRegion()
}
ctx = tflog.SetField(ctx, "project_id", projectId)

View file

@ -79,7 +79,7 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
"credential_id": "The credential ID.",
"credentials_group_id": "The credential group ID.",
"project_id": "STACKIT Project ID to which the credential group is associated.",
"region": "The resource region. Read-only attribute that reflects the provider region.",
"region": "The resource region. If not defined, the provider region is used.",
}
resp.Schema = schema.Schema{
@ -116,8 +116,7 @@ func (r *credentialDataSource) Schema(_ context.Context, _ datasource.SchemaRequ
},
"region": schema.StringAttribute{
// the region cannot be found automatically, so it has to be passed
Optional: false,
Computed: true,
Optional: true,
Description: descriptions["region"],
},
},
@ -138,7 +137,7 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
credentialId := model.CredentialId.ValueString()
var region string
if utils.IsUndefined(model.Region) {
region = r.providerData.Region
region = r.providerData.GetRegion()
} else {
region = model.Region.ValueString()
}

View file

@ -87,7 +87,7 @@ func (r *credentialResource) modifyPlanRegion(ctx context.Context, req *resource
return
}
utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.Region, resp)
utils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
if resp.Diagnostics.HasError() {
return
}
@ -176,7 +176,7 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
"credentials_group_id": "The credential group ID.",
"project_id": "STACKIT Project ID to which the credential group is associated.",
"expiration_timestamp": "Expiration timestamp, in RFC339 format without fractional seconds. Example: \"2025-01-01T00:00:00Z\". If not set, the credential never expires.",
"region": "The resource region. Read-only attribute that reflects the provider region.",
"region": "The resource region. If not defined, the provider region is used.",
}
resp.Schema = schema.Schema{
@ -246,7 +246,7 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
},
},
"region": schema.StringAttribute{
Optional: false,
Optional: true,
// must be computed to allow for storing the override value from the provider
Computed: true,
Description: descriptions["region"],
@ -349,7 +349,7 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
credentialId := model.CredentialId.ValueString()
region := model.Region.ValueString()
if region == "" {
region = r.providerData.Region
region = r.providerData.GetRegion()
}
ctx = tflog.SetField(ctx, "project_id", projectId)

View file

@ -83,7 +83,7 @@ func (r *credentialsGroupDataSource) Schema(_ context.Context, _ datasource.Sche
"name": "The credentials group's display name.",
"project_id": "Object Storage Project ID to which the credentials group is associated.",
"urn": "Credentials group uniform resource name (URN)",
"region": "The resource region. Read-only attribute that reflects the provider region.",
"region": "The resource region. If not defined, the provider region is used.",
}
resp.Schema = schema.Schema{
@ -117,8 +117,7 @@ func (r *credentialsGroupDataSource) Schema(_ context.Context, _ datasource.Sche
},
"region": schema.StringAttribute{
// the region cannot be found automatically, so it has to be passed
Optional: false,
Computed: true,
Optional: true,
Description: descriptions["region"],
},
},
@ -137,7 +136,7 @@ func (r *credentialsGroupDataSource) Read(ctx context.Context, req datasource.Re
credentialsGroupId := model.CredentialsGroupId.ValueString()
var region string
if utils.IsUndefined(model.Region) {
region = r.providerData.Region
region = r.providerData.GetRegion()
} else {
region = model.Region.ValueString()
}

View file

@ -71,7 +71,7 @@ func (r *credentialsGroupResource) ModifyPlan(ctx context.Context, req resource.
return
}
coreutils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.Region, resp)
coreutils.AdaptRegion(ctx, configModel.Region, &planModel.Region, r.providerData.GetRegion(), resp)
if resp.Diagnostics.HasError() {
return
}
@ -132,7 +132,7 @@ func (r *credentialsGroupResource) Schema(_ context.Context, _ resource.SchemaRe
"name": "The credentials group's display name.",
"project_id": "Project ID to which the credentials group is associated.",
"urn": "Credentials group uniform resource name (URN)",
"region": "The resource region. Read-only attribute that reflects the provider region.",
"region": "The resource region. If not defined, the provider region is used.",
}
resp.Schema = schema.Schema{
@ -174,7 +174,7 @@ func (r *credentialsGroupResource) Schema(_ context.Context, _ resource.SchemaRe
Computed: true,
},
"region": schema.StringAttribute{
Optional: false,
Optional: true,
// must be computed to allow for storing the override value from the provider
Computed: true,
Description: descriptions["region"],
@ -250,7 +250,7 @@ func (r *credentialsGroupResource) Read(ctx context.Context, req resource.ReadRe
ctx = tflog.SetField(ctx, "credentials_group_id", credentialsGroupId)
ctx = tflog.SetField(ctx, "region", region)
if region == "" {
region = r.providerData.Region
region = r.providerData.GetRegion()
}
found, err := readCredentialsGroups(ctx, &model, region, r.client)

View file

@ -75,7 +75,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = observability.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -62,7 +62,7 @@ func (d *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = observability.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -364,7 +364,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = observability.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -64,7 +64,7 @@ func (d *scrapeConfigDataSource) Configure(ctx context.Context, req datasource.C
} else {
apiClient, err = observability.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
if err != nil {

View file

@ -139,7 +139,7 @@ func (r *scrapeConfigResource) Configure(ctx context.Context, req resource.Confi
} else {
apiClient, err = observability.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
} else {
apiClient, err = opensearch.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -83,7 +83,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = opensearch.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = opensearch.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -125,7 +125,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = opensearch.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -60,7 +60,7 @@ func (r *databaseDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = postgresflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -77,7 +77,7 @@ func (r *databaseResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = postgresflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -63,7 +63,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = postgresflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -117,7 +117,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = postgresflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -74,7 +74,7 @@ func (r *userDataSource) Configure(ctx context.Context, req datasource.Configure
} else {
apiClient, err = postgresflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -87,7 +87,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
} else {
apiClient, err = postgresflex.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
} else {
apiClient, err = rabbitmq.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -86,7 +86,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = rabbitmq.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = rabbitmq.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -122,7 +122,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = rabbitmq.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *credentialDataSource) Configure(ctx context.Context, req datasource.Con
} else {
apiClient, err = redis.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -83,7 +83,7 @@ func (r *credentialResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = redis.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = redis.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -141,7 +141,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = redis.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -61,7 +61,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = secretsmanager.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -80,7 +80,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = secretsmanager.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -72,7 +72,7 @@ func (r *userDataSource) Configure(ctx context.Context, req datasource.Configure
} else {
apiClient, err = secretsmanager.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -79,7 +79,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
} else {
apiClient, err = secretsmanager.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -107,7 +107,7 @@ func (r *scheduleResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = serverbackup.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -78,7 +78,7 @@ func (r *scheduleDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = serverbackup.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -77,7 +77,7 @@ func (r *schedulesDataSource) Configure(ctx context.Context, req datasource.Conf
} else {
apiClient, err = serverbackup.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -99,7 +99,7 @@ func (r *scheduleResource) Configure(ctx context.Context, req resource.Configure
} else {
apiClient, err = serverupdate.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -77,7 +77,7 @@ func (r *scheduleDataSource) Configure(ctx context.Context, req datasource.Confi
} else {
apiClient, err = serverupdate.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -77,7 +77,7 @@ func (r *schedulesDataSource) Configure(ctx context.Context, req datasource.Conf
} else {
apiClient, err = serverupdate.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -60,7 +60,7 @@ func (r *clusterDataSource) Configure(ctx context.Context, req datasource.Config
} else {
apiClient, err = ske.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -267,7 +267,7 @@ func (r *clusterResource) Configure(ctx context.Context, req resource.ConfigureR
} else {
skeClient, err = ske.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
@ -284,7 +284,7 @@ func (r *clusterResource) Configure(ctx context.Context, req resource.ConfigureR
} else {
enablementClient, err = serviceenablement.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -86,7 +86,7 @@ func (r *kubeconfigResource) Configure(ctx context.Context, req resource.Configu
} else {
apiClient, err = ske.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -62,7 +62,7 @@ func (r *projectDataSource) Configure(ctx context.Context, req datasource.Config
} else {
apiClient, err = ske.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
@ -79,7 +79,7 @@ func (r *projectDataSource) Configure(ctx context.Context, req datasource.Config
} else {
enablementClient, err = serviceenablement.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

View file

@ -74,7 +74,7 @@ func (r *projectResource) Configure(ctx context.Context, req resource.ConfigureR
} else {
apiClient, err = ske.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}
@ -91,7 +91,7 @@ func (r *projectResource) Configure(ctx context.Context, req resource.ConfigureR
} else {
enablementClient, err = serviceenablement.NewAPIClient(
config.WithCustomAuth(providerData.RoundTripper),
config.WithRegion(providerData.Region),
config.WithRegion(providerData.GetRegion()),
)
}

Some files were not shown because too many files have changed in this diff Show more