fix: int64 user_id and some more
This commit is contained in:
parent
6aac685ed4
commit
d01ae71b75
8 changed files with 65 additions and 44 deletions
|
|
@ -40,6 +40,8 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
|
||||||
}
|
}
|
||||||
switch strings.ToLower(string(*s.Status)) {
|
switch strings.ToLower(string(*s.Status)) {
|
||||||
case strings.ToLower(InstanceStateSuccess):
|
case strings.ToLower(InstanceStateSuccess):
|
||||||
|
// if no instance address - return false
|
||||||
|
// if no router address - return false
|
||||||
return true, s, nil
|
return true, s, nil
|
||||||
case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
|
case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
|
||||||
return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
|
return true, s, fmt.Errorf("create failed for instance with id %s", instanceId)
|
||||||
|
|
@ -48,7 +50,7 @@ func CreateInstanceWaitHandler(ctx context.Context, a APIClientInstanceInterface
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
handler.SetTimeout(45 * time.Minute)
|
handler.SetTimeout(45 * time.Minute)
|
||||||
handler.SetSleepBeforeWait(5 * time.Second)
|
handler.SetSleepBeforeWait(15 * time.Second)
|
||||||
return handler
|
return handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
# see other files
|
# see other files
|
||||||
|
|
||||||
resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
|
data "stackitprivatepreview_sqlserverflexalpha_instance" "existing" {
|
||||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
project_id = var.project_id
|
||||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
instance_id = "b31575e9-9dbd-4ff6-b341-82d89c34f14f"
|
||||||
username = var.db_username
|
region = "eu01"
|
||||||
roles = ["login"]
|
}
|
||||||
|
|
||||||
|
output "myinstance" {
|
||||||
|
value = data.stackitprivatepreview_sqlserverflexalpha_instance.existing
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,3 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "ptlsdbsrv" {
|
||||||
}
|
}
|
||||||
version = 14
|
version = 14
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "stackitprivatepreview_sqlserverflexalpha_user" "ptlsdbuser" {
|
|
||||||
project_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.project_id
|
|
||||||
instance_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.id
|
|
||||||
username = var.db_username
|
|
||||||
roles = ["createdb", "login", "createrole"]
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,20 @@
|
||||||
data "stackit_postgresflexalpha_user" "example" {
|
data "stackitprivatepreview_postgresflexalpha_user" "example" {
|
||||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
project_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
instance_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.id
|
||||||
user_id = 1
|
user_id = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
|
resource "stackitprivatepreview_postgresflexalpha_user" "ptlsdbuser" {
|
||||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
project_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
instance_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.id
|
||||||
username = var.db_username
|
username = var.db_username
|
||||||
roles = ["createdb", "login", "createrole"]
|
# roles = ["createdb", "login", "createrole"]
|
||||||
}
|
roles = ["createdb", "login"]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_user" "ptlsdbuser" {
|
||||||
|
project_id = stackitprivatepreview_sqlserverflexalpha_instance.ptlsdbsqlsrv.project_id
|
||||||
|
instance_id = stackitprivatepreview_sqlserverflexalpha_instance.ptlsdbsqlsrv.id
|
||||||
|
username = var.db_username
|
||||||
|
roles = ["login"]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,10 @@ func (r *instanceResource) Schema(_ context.Context, req resource.SchemaRequest,
|
||||||
},
|
},
|
||||||
"size": schema.Int64Attribute{
|
"size": schema.Int64Attribute{
|
||||||
Required: true,
|
Required: true,
|
||||||
|
//PlanModifiers: []planmodifier.Int64{
|
||||||
|
// TODO - req replace if new size smaller than state size
|
||||||
|
// int64planmodifier.RequiresReplaceIf(),
|
||||||
|
//},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
|
||||||
"github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/postgresflexalpha/wait"
|
"github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/postgresflexalpha/wait"
|
||||||
postgresflexUtils "github.com/mhenselin/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
|
postgresflexUtils "github.com/mhenselin/terraform-provider-stackitprivatepreview/stackit/internal/services/postgresflexalpha/utils"
|
||||||
|
|
||||||
|
|
@ -147,15 +148,13 @@ func (r *userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
|
||||||
stringplanmodifier.UseStateForUnknown(),
|
stringplanmodifier.UseStateForUnknown(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"user_id": schema.StringAttribute{
|
"user_id": schema.Int64Attribute{
|
||||||
Description: descriptions["user_id"],
|
Description: descriptions["user_id"],
|
||||||
Computed: true,
|
Computed: true,
|
||||||
PlanModifiers: []planmodifier.String{
|
PlanModifiers: []planmodifier.Int64{
|
||||||
stringplanmodifier.UseStateForUnknown(),
|
int64planmodifier.UseStateForUnknown(),
|
||||||
},
|
|
||||||
Validators: []validator.String{
|
|
||||||
validate.NoSeparator(),
|
|
||||||
},
|
},
|
||||||
|
Validators: []validator.Int64{},
|
||||||
},
|
},
|
||||||
"instance_id": schema.StringAttribute{
|
"instance_id": schema.StringAttribute{
|
||||||
Description: descriptions["instance_id"],
|
Description: descriptions["instance_id"],
|
||||||
|
|
|
||||||
|
|
@ -64,16 +64,23 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
|
||||||
// Schema defines the schema for the data source.
|
// Schema defines the schema for the data source.
|
||||||
func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||||
descriptions := map[string]string{
|
descriptions := map[string]string{
|
||||||
"main": "SQLServer Flex instance data source schema. Must have a `region` specified in the provider configuration.",
|
"main": "SQLServer Flex ALPHA instance resource schema. Must have a `region` specified in the provider configuration.",
|
||||||
"id": "Terraform's internal data source. ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
|
"id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
|
||||||
"instance_id": "ID of the SQLServer Flex instance.",
|
"instance_id": "ID of the SQLServer Flex instance.",
|
||||||
"project_id": "STACKIT project ID to which the instance is associated.",
|
"project_id": "STACKIT project ID to which the instance is associated.",
|
||||||
"name": "Instance name.",
|
"name": "Instance name.",
|
||||||
"acl": "The Access Control List (ACL) for the SQLServer Flex instance.",
|
"access_scope": "The access scope of the instance. (e.g. SNA)",
|
||||||
"backup_schedule": `The backup schedule. Should follow the cron scheduling system format (e.g. "0 0 * * *").`,
|
"acl": "The Access Control List (ACL) for the SQLServer Flex instance.",
|
||||||
"options": "Custom parameters for the SQLServer Flex instance.",
|
"backup_schedule": `The backup schedule. Should follow the cron scheduling system format (e.g. "0 0 * * *")`,
|
||||||
"region": "The resource region. If not defined, the provider region is used.",
|
"region": "The resource region. If not defined, the provider region is used.",
|
||||||
// TODO @mhenselin
|
"encryption": "The encryption block.",
|
||||||
|
"network": "The network block.",
|
||||||
|
"keyring_id": "STACKIT KMS - KeyRing ID of the encryption key to use.",
|
||||||
|
"key_id": "STACKIT KMS - Key ID of the encryption key to use.",
|
||||||
|
"key_version": "STACKIT KMS - Key version to use in the encryption key.",
|
||||||
|
"service:account": "STACKIT KMS - service account to use in the encryption key.",
|
||||||
|
"instance_address": "The returned instance IP address of the SQLServer Flex instance.",
|
||||||
|
"router_address": "The returned router IP address of the SQLServer Flex instance.",
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.Schema = schema.Schema{
|
resp.Schema = schema.Schema{
|
||||||
|
|
@ -107,6 +114,10 @@ func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
||||||
Description: descriptions["backup_schedule"],
|
Description: descriptions["backup_schedule"],
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"is_deletable": schema.BoolAttribute{
|
||||||
|
Description: descriptions["is_deletable"],
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
"flavor": schema.SingleNestedAttribute{
|
"flavor": schema.SingleNestedAttribute{
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Attributes: map[string]schema.Attribute{
|
Attributes: map[string]schema.Attribute{
|
||||||
|
|
@ -122,6 +133,9 @@ func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
||||||
"ram": schema.Int64Attribute{
|
"ram": schema.Int64Attribute{
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"node_type": schema.StringAttribute{
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"replicas": schema.Int64Attribute{
|
"replicas": schema.Int64Attribute{
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
|
||||||
"github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/sqlserverflexalpha"
|
"github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/sqlserverflexalpha"
|
||||||
sqlserverflexalphaUtils "github.com/mhenselin/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils"
|
sqlserverflexalphaUtils "github.com/mhenselin/terraform-provider-stackitprivatepreview/stackit/internal/services/sqlserverflexalpha/utils"
|
||||||
|
|
||||||
|
|
@ -143,15 +144,13 @@ func (r *userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
|
||||||
stringplanmodifier.UseStateForUnknown(),
|
stringplanmodifier.UseStateForUnknown(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"user_id": schema.StringAttribute{
|
"user_id": schema.Int64Attribute{
|
||||||
Description: descriptions["user_id"],
|
Description: descriptions["user_id"],
|
||||||
Computed: true,
|
Computed: true,
|
||||||
PlanModifiers: []planmodifier.String{
|
PlanModifiers: []planmodifier.Int64{
|
||||||
stringplanmodifier.UseStateForUnknown(),
|
int64planmodifier.UseStateForUnknown(),
|
||||||
},
|
|
||||||
Validators: []validator.String{
|
|
||||||
validate.NoSeparator(),
|
|
||||||
},
|
},
|
||||||
|
Validators: []validator.Int64{},
|
||||||
},
|
},
|
||||||
"instance_id": schema.StringAttribute{
|
"instance_id": schema.StringAttribute{
|
||||||
Description: descriptions["instance_id"],
|
Description: descriptions["instance_id"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue