Aggiornamento della tabella NoSQL Oracle mediante Terraform e OCI Resource Manager
In questo articolo verranno descritti i passi per aggiornare uno schema di tabella NDCS o unità di storage (lettura o scrittura) esistenti utilizzando Terraform. Verrà utilizzata l'interfaccia CLI di OCI Resource Manager per aggiornare le tabelle NDCS. Prima di procedere con questo articolo, si presume di essere a conoscenza di NoSQL Cloud Service e di conoscerne le nozioni di base, insieme a Terraform.
- Aggiornare uno stack.
- Genera ed esamina il piano di esecuzione.
- Eseguire il job di applicazione per aggiornare le risorse NoSQL richieste.
- Esaminare i file di log in base alle esigenze.
Questo articolo contiene i seguenti argomenti:
Prerequisiti
- Stack esistente con risorse di database NoSQL, ad esempio tabelle o indici.
- File di configurazione Terraform esistenti utilizzati per creare le risorse del database NoSQL, ad esempio tabelle o indici.
Passo 1: creare i file di override Terraform per la tabella del database NoSQL
Creare un nuovo file denominato "nosql_override.tf
" o "override.tf
" e fornire la parte specifica dell'oggetto tabella del database NoSQL da sostituire. Ad esempio, è possibile aggiungere o eliminare una colonna dalla tabella modificando il tipo di dati di una colonna esistente oppure modificando i limiti della tabella (unità di lettura/scrittura e memorizzazione).
Nell'esempio seguente verrà modificata la tabella demo
per eliminare una colonna esistente denominata fullName
e modificare la tabella demoKeyVal
per aggiungere una nuova colonna alla fine denominata shortName
.
Ad esempio:
nosql.tf
con i seguenti contenuti:variable "compartment_ocid" {
}
resource "oci_nosql_table" "nosql_demo" {
compartment_id = var.compartment_ocid
ddl_statement = "CREATE TABLE if not exists demo (ticketNo INTEGER, fullName STRING, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY (ticketNo))"
name = "demo"
table_limits {
max_read_units = var.table_table_limits_max_read_units
max_storage_in_gbs = var.table_table_limits_max_storage_in_gbs
max_write_units = var.table_table_limits_max_write_units
}
}
resource "oci_nosql_table" "nosql_demoKeyVal" {
compartment_id = var.compartment_ocid
ddl_statement = "CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, PRIMARY KEY (key))"
name = "demoKeyVal"
table_limits {
max_read_units = var.table_table_limits_max_read_units
max_storage_in_gbs = var.table_table_limits_max_storage_in_gbs
max_write_units = var.table_table_limits_max_write_units
}
}
demo
ed eliminare una colonna esistente, denominata fullName
, e modificare la tabella demoKeyVal
per aggiungere una nuova colonna alla fine, denominata shortName. Quindi creare un file nosql_override.tf
o override.tf
contenente il seguente contenuto:variable "compartment_ocid" {
}
resource "oci_nosql_table" "nosql_demo" {
compartment_id = var.compartment_ocid
ddl_statement = "CREATE TABLE if not exists demo (ticketNo INTEGER, contactPhone STRING,
confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY (ticketNo))"
name = "demo"
}
resource "oci_nosql_table" "nosql_demoKeyVal" {
compartment_id = var.compartment_ocid
ddl_statement = "CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY
(START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, shortName STRING, PRIMARY KEY (key))"
name = "demoKeyVal"
}
Nota
Durante l'aggiunta di colonne a una tabella esistente, è possibile aggiungere solo colonne alla fine della tabella. Non è possibile inserire una nuova colonna prima di una colonna esistente o modificare l'ordine delle colonne esistenti. Ad esempio, non è possibile aggiungere la colonnashortName
prima della colonna value
o scambiare le colonne key
e value
nella tabella demoKeyVal
. Ciò comporterebbe un errore.
Quando Terraform elabora questo file (nosql_override.tf
), analizza internamente l'istruzione DDL (istruzione CREATE TABLE) e la confronta con la definizione di tabella esistente, genera un'istruzione ALTER TABLE equivalente e la applica.
Passo 2: aggiornare il piano di esecuzione
Nota
Queste istruzioni non si applicano alle configurazioni memorizzate nei sistemi di controllo del codice sorgente. Se si utilizzano sistemi di controllo del codice sorgente come GitHub e Gitlab per gestire i file di configurazione di terraform, è possibile saltare questo passaggio e passare direttamente al Passo 3. La versione più recente della configurazione viene utilizzata automaticamente da qualsiasi job in esecuzione nello stack associato.terraform.zip
. Il file terraform.zip
aggiornato contiene i file riportati di seguito.
provider.tf
nosql.tf
nosql_override.tf or override.tf
terraform.tfvars
variables.tf
oci resource-manager stack update
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq
--config-source terraform.zip
{
"data": {
"compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
"config-source": {
"config-source-type": "ZIP_UPLOAD",
"working-directory": null
},
"defined-tags": {},
"description": null,
"display-name": "ormstack20220117104810",
"freeform-tags": {},
"id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
"lifecycle-state": "ACTIVE",
"stack-drift-status": "NOT_CHECKED",
"terraform-version": "1.0.x",
"time-created": "2022-01-17T10:48:10.878000+00:00",
"time-drift-last-checked": null,
"variables": {}
},
"etag": "068e7b962aa43c7b3e7bf5c24b2d7f937db0901a784a9dce8715d76d78ad30f3"
}
È stato aggiornato uno stack esistente con il nuovo file zip aggiornato contenente uno o più file di configurazione terraform di override.
Passo 3: generare un piano di esecuzione
oci resource-manager job create-plan-job
–-stack-id <stack_OCID>
--display-name "<friendly_name>"
oci resource-manager job create-plan-job
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq
{
"data": {
"apply-job-plan-resolution": null,
"cancellation-details": {
"is-forced": false
},
"compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
"config-source": {
"config-source-record-type": "ZIP_UPLOAD"
},
"defined-tags": {},
"display-name": "ormjob20220124122310",
"failure-details": null,
"freeform-tags": {},
"id": "ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia",
"job-operation-details": {
"operation": "PLAN",
"terraform-advanced-options": {
"detailed-log-level": null,
"is-refresh-required": true,
"parallelism": 10
}
},
"lifecycle-state": "ACCEPTED",
"operation": "PLAN",
"resolved-plan-job-id": null,
"stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
"time-created": "2022-01-24T12:23:10.366000+00:00",
"time-finished": null,
"variables": {},
"working-directory": null
},
"etag": "b77d497287af3dd2d166871457d880ffee9952ee2c9a44e8f9dfa3e02b974c95"
}
"id": "ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia",
"job-operation-details": {
"operation": "PLAN"
...
}
Passo secondario 3.1: Revisione del piano di esecuzione
oci resource-manager job get-job-logs
--job-id <plan_job_OCID>
oci resource-manager job get-job-logs
--job-id ocid1.ormjob.oc1.phx.aaaaaaaagke5ajwwchvxkql2c56qoohhvc2dxu5fnqswnpw4hsombrfijnia
...
{
"level": "INFO",
"message": " # data.oci_nosql_table.nosql_demo will be read during apply",
"timestamp": "2022-01-24T12:23:36.445000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " <= data \"oci_nosql_table\" \"nosql_demo\" {",
"timestamp": "2022-01-24T12:23:36.445000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\" -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.445000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ id = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\" -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.445000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ is_auto_reclaimable = true -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.445000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " - \"orcl-cloud.free-tier-retained\" = \"true\"",
"timestamp": "2022-01-24T12:23:36.446000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " # data.oci_nosql_table.nosql_demoKeyVal will be read during apply",
"timestamp": "2022-01-24T12:23:36.446000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " <= data \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
"timestamp": "2022-01-24T12:23:36.446000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\" -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.446000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ id = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\" -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ is_auto_reclaimable = true -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " # oci_nosql_table.nosql_demo will be updated in-place",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ resource \"oci_nosql_table\" \"nosql_demo\" {",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, fullName STRING, PRIMARY KEY(SHARD(ticketNo)))\" -> \"ALTER TABLE demo (DROP fullName)\"",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " # oci_nosql_table.nosql_demoKeyVal will be updated in-place",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ resource \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
"timestamp": "2022-01-24T12:23:36.447000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, PRIMARY KEY(SHARD(key)))\" -> \"ALTER TABLE demoKeyVal (ADD shortName STRING)\"",
"timestamp": "2022-01-24T12:23:36.448000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ nosql_kv_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\" -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.448000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ nosql_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\" -> (known after apply)",
"timestamp": "2022-01-24T12:23:36.448000+00:00",
"type": "TERRAFORM_CONSOLE"
},
...
demo
e demoKeyVal
aggiungendo e rilasciando le colonne.{
...
"message": "Plan: 0 to add, 2 to change, 0 to destroy.",
...
}
Passo 4: eseguire un job di candidatura
- Per specificare un job di piano ("applica" un piano di esecuzione), utilizzare
FROM_PLAN_JOB_ID
:oci resource-manager job create-apply-job --stack-id <stack_OCID> --execution-plan-strategy FROM_PLAN_JOB_ID --execution-plan-job-id <plan_job_OCID> --display-name "Example Apply Job"
- Per approvare automaticamente il job di applicazione (nessun job piano specificato), utilizzare
AUTO_APPROVED
:oci resource-manager job create-apply-job --stack-id <stack_OCID> --execution-plan-strategy AUTO_APPROVED --display-name "Example Apply Job"
oci resource-manager job create-apply-job
--stack-id ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq
--execution-plan-strategy AUTO_APPROVED
--display-name "Update NoSQL Tables Using Terraform"
{ "data": { "apply-job-plan-resolution": { "is-auto-approved": true, "is-use-latest-job-id": null, "plan-job-id": null }, "cancellation-details": { "is-forced": false }, "compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya", "config-source": { "config-source-record-type": "ZIP_UPLOAD" }, "defined-tags": {}, "display-name": "Update NoSQL Tables Using Terraform", "failure-details": null, "freeform-tags": {}, "id": "ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq", "job-operation-details": { "execution-plan-job-id": null, "execution-plan-strategy": "AUTO_APPROVED", "operation": "APPLY", "terraform-advanced-options": { "detailed-log-level": null, "is-refresh-required": true, "parallelism": 10 } }, "lifecycle-state": "ACCEPTED", "operation": "APPLY", "resolved-plan-job-id": null, "stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq", "time-created": "2022-01-24T12:36:52.911000+00:00", "time-finished": null, "variables": {}, "working-directory": null }, "etag": "b2af026af48897c7839c347e06a8c40ec3ce1cac08a3da2f0c6ee74fb07078ab" }
Passo secondario 4.1: verifica dello stato del job
oci resource-manager job get
--job-id <job_OCID>
oci resource-manager job get
--job-id ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq
{
"data": {
"apply-job-plan-resolution": {
"is-auto-approved": true,
"is-use-latest-job-id": null,
"plan-job-id": null
},
"cancellation-details": {
"is-forced": false
},
"compartment-id": "ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya",
"config-source": {
"config-source-record-type": "ZIP_UPLOAD"
},
"defined-tags": {},
"display-name": "ALTER NoSQL Table Schema",
"failure-details": null,
"freeform-tags": {},
"id": "ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq",
"job-operation-details": {
"execution-plan-job-id": null,
"execution-plan-strategy": "AUTO_APPROVED",
"operation": "APPLY",
"terraform-advanced-options": {
"detailed-log-level": null,
"is-refresh-required": true,
"parallelism": 10
}
},
"lifecycle-state": "SUCCEEDED",
"operation": "APPLY",
"resolved-plan-job-id": null,
"stack-id": "ocid1.ormstack.oc1.phx.aaaaaaaa7jrci2s5iav5tdxpl6ucwo2dwazzrdkfhs6bxiohgcpkscmr57bq",
"time-created": "2022-01-20T11:14:13.916000+00:00",
"time-finished": "2022-01-20T11:14:51.921000+00:00",
"variables": {},
"working-directory": null
},
"etag": "13b1253bd5e6ca78778b4cf6aad38d262b1476aae06e6f36b40b5f914016b899--gzip"
}
{
...
"lifecycle-state": "SUCCEEDED",
...
}
Passo 4.2: Visualizzare il log per un job
oci resource-manager job get-job-logs-content
--job-id <job_OCID>
oci resource-manager job get-job-logs-content
--job-id ocid1.ormjob.oc1.phx.aaaaaaaacmnanu2qd34x7l5uicgpdfpjbsgh5swddmtslb3qmbzg3dmuc3bq
...
{
"level": "INFO",
"message": "oci_nosql_table.nosql_demoKeyVal: Refreshing state... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "oci_nosql_table.nosql_demo: Refreshing state... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "plan. Resource actions are indicated with the following symbols:",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ update in-place",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "Terraform will perform the following actions:",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " # data.oci_nosql_table.nosql_demo will be read during apply",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " <= data \"oci_nosql_table\" \"nosql_demo\" {",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " + compartment_id = \"ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " + table_name_or_id = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " <= data \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " + compartment_id = \"ocid1.compartment.oc1..aaaaaaaawrmvqjzoegxbsixp5k3b5554vlv2kxukobw3drjho3f7nf5ca3ya\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " + table_name_or_id = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " # oci_nosql_table.nosql_demo will be updated in-place",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ resource \"oci_nosql_table\" \"nosql_demo\" {",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, fullName STRING, PRIMARY KEY(SHARD(ticketNo)))\" -> \"ALTER TABLE demo (DROP fullName)\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " id = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " name = \"demo\"",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " # oci_nosql_table.nosql_demoKeyVal will be updated in-place",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ resource \"oci_nosql_table\" \"nosql_demoKeyVal\" {",
"timestamp": "2022-01-20T11:14:26.632000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " ~ ddl_statement = \"CREATE TABLE if not exists demoKeyVal (key INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1 NO CYCLE), value JSON, PRIMARY KEY (key))\" -> \"ALTER TABLE demoKeyVal (ADD shortName STRING)\"",
"timestamp": "2022-01-20T11:14:26.633000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " id = \"ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq\"",
"timestamp": "2022-01-20T11:14:26.633000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": " name = \"demoKeyVal\"",
"timestamp": "2022-01-20T11:14:26.633000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "Plan: 0 to add, 2 to change, 0 to destroy.",
"timestamp": "2022-01-20T11:14:26.633000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "oci_nosql_table.nosql_demoKeyVal: Modifying... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
"timestamp": "2022-01-20T11:14:27.633000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "oci_nosql_table.nosql_demo: Modifying... [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
"timestamp": "2022-01-20T11:14:27.633000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "oci_nosql_table.nosql_demo: Modifications complete after 9s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
"timestamp": "2022-01-20T11:14:35.634000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "data.oci_nosql_table.nosql_demo: Reading...",
"timestamp": "2022-01-20T11:14:35.634000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "data.oci_nosql_table.nosql_demo: Read complete after 0s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyasvdkoclhgryulgzox3nvlxb2bqtlxxsrvrc4zxr6lo4a]",
"timestamp": "2022-01-20T11:14:35.634000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "data.oci_nosql_table.nosql_demoKeyVal: Reading...",
"timestamp": "2022-01-20T11:14:44.636000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "data.oci_nosql_table.nosql_demoKeyVal: Read complete after 0s [id=ocid1.nosqltable.oc1.phx.amaaaaaau7x7rfyaqgpbjucp3s6jjzpnar4lg5yudxhwlqrlbd54l3wdo7hq]",
"timestamp": "2022-01-20T11:14:44.636000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "Apply complete! Resources: 0 added, 2 changed, 0 destroyed.",
"timestamp": "2022-01-20T11:14:44.636000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "nosql_kv_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demoKeyVal(key INTEGER, value JSON, shortName STRING, PRIMARY KEY(SHARD(key)))\"",
"timestamp": "2022-01-20T11:14:44.636000+00:00",
"type": "TERRAFORM_CONSOLE"
},
{
"level": "INFO",
"message": "nosql_table_ddl_statement = \"CREATE TABLE IF NOT EXISTS demo(ticketNo INTEGER, contactPhone STRING, confNo STRING, gender STRING, bagInfo JSON, PRIMARY KEY(SHARD(ticketNo)))\"",
"timestamp": "2022-01-20T11:14:44.636000+00:00",
"type": "TERRAFORM_CONSOLE"
},
...
demo
e demoKeyVal
.{
...
"message": "Apply complete! Resources: 0 added, 2 changed, 0 destroyed.",
...
}
Abbiamo coperto molti dettagli in questo tutorial. Abbiamo creato i file di configurazione terraform di override necessari per aggiornare lo schema delle tabelle di database NoSQL nel cloud OCI, quindi abbiamo utilizzato l'interfaccia CLI di OCI Resource Manager per aggiornare lo stack esistente, generare un piano di esecuzione ed eseguire un job di applicazione nel piano di esecuzione.