fix: encryption_fix #75
8 changed files with 95 additions and 32 deletions
|
|
@ -10,3 +10,13 @@ import {
|
||||||
to = stackitprivatepreview_postgresflexalpha_database.import-example
|
to = stackitprivatepreview_postgresflexalpha_database.import-example
|
||||||
id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}"
|
id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.postgres_database_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_postgresflexalpha_database.import-example
|
||||||
|
identity = {
|
||||||
|
project_id = "project_id"
|
||||||
|
region = "region"
|
||||||
|
instance_id = "instance_id"
|
||||||
|
database_id = "database_id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
resource "stackitprivatepreview_postgresflexalpha_instance" "msh-instance-only" {
|
resource "stackitprivatepreview_postgresflexalpha_instance" "example-instance" {
|
||||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
name = "example-instance"
|
name = "example-instance"
|
||||||
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
|
acl = ["XXX.XXX.XXX.X/XX", "XX.XXX.XX.X/XX"]
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,13 @@ import {
|
||||||
to = stackitprivatepreview_postgresflexalpha_user.import-example
|
to = stackitprivatepreview_postgresflexalpha_user.import-example
|
||||||
id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}"
|
id = "${var.project_id},${var.region},${var.postgres_instance_id},${var.user_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_postgresflexalpha_user.import-example
|
||||||
|
identity = {
|
||||||
|
project_id = "project.id"
|
||||||
|
region = "region"
|
||||||
|
instance_id = "instance.id"
|
||||||
|
user_id = "user.id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_database" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
collation = ""
|
||||||
|
compatibility = "160"
|
||||||
|
name = ""
|
||||||
|
owner = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only use the import statement, if you want to import a existing sqlserverflex database
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_database.import-example
|
||||||
|
id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_database.import-example
|
||||||
|
identity = {
|
||||||
|
project_id = "project.id"
|
||||||
|
region = "region"
|
||||||
|
instance_id = "instance.id"
|
||||||
|
database_id = "database.id"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
username = "username"
|
||||||
|
roles = ["role"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only use the import statement, if you want to import an existing sqlserverflex user
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_user.import-example
|
||||||
|
id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_user" "example" {
|
||||||
|
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||||
|
username = "username"
|
||||||
|
roles = ["role"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Only use the import statement, if you want to import an existing sqlserverflex user
|
||||||
|
import {
|
||||||
|
to = stackitprivatepreview_sqlserverflexalpha_user.import-example
|
||||||
|
id = "${var.project_id},${var.region},${var.sql_instance_id},${var.sql_user_id}"
|
||||||
|
}
|
||||||
|
|
@ -243,7 +243,8 @@ func (r *instanceResource) Create(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx)
|
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).
|
||||||
|
WaitWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
core.LogAndAddError(
|
core.LogAndAddError(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func mapResponseToModel(
|
||||||
) error {
|
) error {
|
||||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||||
m.Edition = types.StringValue(string(resp.GetEdition()))
|
m.Edition = types.StringValue(string(resp.GetEdition()))
|
||||||
m.Encryption = handleEncryption(m, resp)
|
m.Encryption = handleEncryption(ctx, m, resp)
|
||||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||||
m.Id = types.StringValue(resp.GetId())
|
m.Id = types.StringValue(resp.GetId())
|
||||||
m.InstanceId = types.StringValue(resp.GetId())
|
m.InstanceId = types.StringValue(resp.GetId())
|
||||||
|
|
@ -81,7 +81,7 @@ func mapDataResponseToModel(
|
||||||
) error {
|
) error {
|
||||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||||
m.Edition = types.StringValue(string(resp.GetEdition()))
|
m.Edition = types.StringValue(string(resp.GetEdition()))
|
||||||
m.Encryption = handleDSEncryption(m, resp)
|
m.Encryption = handleDSEncryption(ctx, m, resp)
|
||||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||||
m.Id = types.StringValue(resp.GetId())
|
m.Id = types.StringValue(resp.GetId())
|
||||||
m.InstanceId = types.StringValue(resp.GetId())
|
m.InstanceId = types.StringValue(resp.GetId())
|
||||||
|
|
@ -130,6 +130,7 @@ func mapDataResponseToModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleEncryption(
|
func handleEncryption(
|
||||||
|
ctx context.Context,
|
||||||
m *sqlserverflexbetaResGen.InstanceModel,
|
m *sqlserverflexbetaResGen.InstanceModel,
|
||||||
resp *sqlserverflexbeta.GetInstanceResponse,
|
resp *sqlserverflexbeta.GetInstanceResponse,
|
||||||
) sqlserverflexbetaResGen.EncryptionValue {
|
) sqlserverflexbetaResGen.EncryptionValue {
|
||||||
|
|
@ -145,23 +146,20 @@ func handleEncryption(
|
||||||
return m.Encryption
|
return m.Encryption
|
||||||
}
|
}
|
||||||
|
|
||||||
enc := sqlserverflexbetaResGen.NewEncryptionValueNull()
|
enc := sqlserverflexbetaResGen.NewEncryptionValueMust(
|
||||||
if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
sqlserverflexbetaResGen.EncryptionValue{}.AttributeTypes(ctx),
|
||||||
enc.KekKeyId = types.StringValue(kVal)
|
map[string]attr.Value{
|
||||||
}
|
"kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||||
if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
|
"kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||||
enc.KekKeyRingId = types.StringValue(kkVal)
|
"kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||||
}
|
"service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||||
if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
|
},
|
||||||
enc.KekKeyVersion = types.StringValue(kkvVal)
|
)
|
||||||
}
|
|
||||||
if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
|
|
||||||
enc.ServiceAccount = types.StringValue(sa)
|
|
||||||
}
|
|
||||||
return enc
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleDSEncryption(
|
func handleDSEncryption(
|
||||||
|
ctx context.Context,
|
||||||
m *dataSourceModel,
|
m *dataSourceModel,
|
||||||
resp *sqlserverflexbeta.GetInstanceResponse,
|
resp *sqlserverflexbeta.GetInstanceResponse,
|
||||||
) sqlserverflexbetaDataGen.EncryptionValue {
|
) sqlserverflexbetaDataGen.EncryptionValue {
|
||||||
|
|
@ -177,19 +175,15 @@ func handleDSEncryption(
|
||||||
return m.Encryption
|
return m.Encryption
|
||||||
}
|
}
|
||||||
|
|
||||||
enc := sqlserverflexbetaDataGen.NewEncryptionValueNull()
|
enc := sqlserverflexbetaDataGen.NewEncryptionValueMust(
|
||||||
if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
sqlserverflexbetaDataGen.EncryptionValue{}.AttributeTypes(ctx),
|
||||||
enc.KekKeyId = types.StringValue(kVal)
|
map[string]attr.Value{
|
||||||
}
|
"kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||||
if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
|
"kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||||
enc.KekKeyRingId = types.StringValue(kkVal)
|
"kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||||
}
|
"service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||||
if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
|
},
|
||||||
enc.KekKeyVersion = types.StringValue(kkvVal)
|
)
|
||||||
}
|
|
||||||
if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
|
|
||||||
enc.ServiceAccount = types.StringValue(sa)
|
|
||||||
}
|
|
||||||
return enc
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue