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)) {
|
||||
case strings.ToLower(InstanceStateSuccess):
|
||||
// if no instance address - return false
|
||||
// if no router address - return false
|
||||
return true, s, nil
|
||||
case strings.ToLower(InstanceStateUnknown), strings.ToLower(InstanceStateFailed):
|
||||
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.SetSleepBeforeWait(5 * time.Second)
|
||||
handler.SetSleepBeforeWait(15 * time.Second)
|
||||
return handler
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
# see other files
|
||||
|
||||
resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
|
||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
||||
username = var.db_username
|
||||
roles = ["login"]
|
||||
data "stackitprivatepreview_sqlserverflexalpha_instance" "existing" {
|
||||
project_id = var.project_id
|
||||
instance_id = "b31575e9-9dbd-4ff6-b341-82d89c34f14f"
|
||||
region = "eu01"
|
||||
}
|
||||
|
||||
output "myinstance" {
|
||||
value = data.stackitprivatepreview_sqlserverflexalpha_instance.existing
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,3 @@ resource "stackitprivatepreview_postgresflexalpha_instance" "ptlsdbsrv" {
|
|||
}
|
||||
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" {
|
||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
||||
data "stackitprivatepreview_postgresflexalpha_user" "example" {
|
||||
project_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||
instance_id = stackitprivatepreview_postgresflexalpha_instance.ptlsdbsrv.id
|
||||
user_id = 1
|
||||
}
|
||||
|
||||
resource "stackit_sqlserverflexalpha_user" "ptlsdbuser" {
|
||||
project_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.project_id
|
||||
instance_id = stackitalpha_postgresflexalpha_instance.ptlsdbsrv.id
|
||||
resource "stackitprivatepreview_postgresflexalpha_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"]
|
||||
}
|
||||
# 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{
|
||||
Required: true,
|
||||
//PlanModifiers: []planmodifier.Int64{
|
||||
// TODO - req replace if new size smaller than state size
|
||||
// int64planmodifier.RequiresReplaceIf(),
|
||||
//},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
|
||||
"github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/postgresflexalpha/wait"
|
||||
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(),
|
||||
},
|
||||
},
|
||||
"user_id": schema.StringAttribute{
|
||||
"user_id": schema.Int64Attribute{
|
||||
Description: descriptions["user_id"],
|
||||
Computed: true,
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.UseStateForUnknown(),
|
||||
},
|
||||
Validators: []validator.String{
|
||||
validate.NoSeparator(),
|
||||
PlanModifiers: []planmodifier.Int64{
|
||||
int64planmodifier.UseStateForUnknown(),
|
||||
},
|
||||
Validators: []validator.Int64{},
|
||||
},
|
||||
"instance_id": schema.StringAttribute{
|
||||
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.
|
||||
func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
|
||||
descriptions := map[string]string{
|
||||
"main": "SQLServer Flex instance data source 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`\".",
|
||||
"instance_id": "ID of the SQLServer Flex instance.",
|
||||
"project_id": "STACKIT project ID to which the instance is associated.",
|
||||
"name": "Instance name.",
|
||||
"acl": "The Access Control List (ACL) for the SQLServer Flex instance.",
|
||||
"backup_schedule": `The backup schedule. Should follow the cron scheduling system format (e.g. "0 0 * * *").`,
|
||||
"options": "Custom parameters for the SQLServer Flex instance.",
|
||||
"region": "The resource region. If not defined, the provider region is used.",
|
||||
// TODO @mhenselin
|
||||
"main": "SQLServer Flex ALPHA instance resource schema. Must have a `region` specified in the provider configuration.",
|
||||
"id": "Terraform's internal resource ID. It is structured as \"`project_id`,`region`,`instance_id`\".",
|
||||
"instance_id": "ID of the SQLServer Flex instance.",
|
||||
"project_id": "STACKIT project ID to which the instance is associated.",
|
||||
"name": "Instance name.",
|
||||
"access_scope": "The access scope of the instance. (e.g. SNA)",
|
||||
"acl": "The Access Control List (ACL) 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.",
|
||||
"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{
|
||||
|
|
@ -107,6 +114,10 @@ func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
|||
Description: descriptions["backup_schedule"],
|
||||
Computed: true,
|
||||
},
|
||||
"is_deletable": schema.BoolAttribute{
|
||||
Description: descriptions["is_deletable"],
|
||||
Computed: true,
|
||||
},
|
||||
"flavor": schema.SingleNestedAttribute{
|
||||
Computed: true,
|
||||
Attributes: map[string]schema.Attribute{
|
||||
|
|
@ -122,6 +133,9 @@ func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
|||
"ram": schema.Int64Attribute{
|
||||
Computed: true,
|
||||
},
|
||||
"node_type": schema.StringAttribute{
|
||||
Computed: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
"replicas": schema.Int64Attribute{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
|
||||
"github.com/mhenselin/terraform-provider-stackitprivatepreview/pkg/sqlserverflexalpha"
|
||||
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(),
|
||||
},
|
||||
},
|
||||
"user_id": schema.StringAttribute{
|
||||
"user_id": schema.Int64Attribute{
|
||||
Description: descriptions["user_id"],
|
||||
Computed: true,
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.UseStateForUnknown(),
|
||||
},
|
||||
Validators: []validator.String{
|
||||
validate.NoSeparator(),
|
||||
PlanModifiers: []planmodifier.Int64{
|
||||
int64planmodifier.UseStateForUnknown(),
|
||||
},
|
||||
Validators: []validator.Int64{},
|
||||
},
|
||||
"instance_id": schema.StringAttribute{
|
||||
Description: descriptions["instance_id"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue