diff --git a/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/main.tf b/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/main.tf new file mode 100644 index 0000000..687cb37 --- /dev/null +++ b/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/main.tf @@ -0,0 +1,39 @@ +# Copyright © 2023, Oracle and/or its affiliates. +# All rights reserved. Licensed under the Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl. + +locals { + adw_download_wallet = { for key, value in var.adw_params : key => value if value.create_local_wallet == true } +} + +resource "oci_database_autonomous_database_wallet" "autonomous_database_wallet" { + for_each = var.adw_params + autonomous_database_id = oci_database_autonomous_database.adw[each.key].id + password = each.value.database_wallet_password + base64_encode_content = "true" +} + +resource "local_file" "autonomous_data_warehouse_wallet_file" { + for_each = local.adw_download_wallet + content_base64 = oci_database_autonomous_database_wallet.autonomous_database_wallet[each.key].content + filename = "${path.cwd}/wallet_${each.value.db_name}.zip" +} + +resource "oci_database_autonomous_database" "adw" { + for_each = var.adw_params + admin_password = each.value.database_admin_password + compartment_id = each.value.compartment_id + compute_model = each.value.compute_model + compute_count = each.value.compute_count + data_storage_size_in_tbs = each.value.size_in_tbs + db_name = each.value.db_name + display_name = each.value.db_name + db_workload = each.value.db_workload + db_version = each.value.db_version + license_model = each.value.license_model + is_mtls_connection_required = each.value.is_mtls_connection_required + subnet_id = each.value.subnet_id + nsg_ids = each.value.nsg_ids + defined_tags = each.value.defined_tags + is_auto_scaling_enabled = each.value.enable_auto_scaling + is_free_tier = each.value.is_free_tier +} diff --git a/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/outputs.tf b/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/outputs.tf new file mode 100644 index 0000000..60e26a4 --- /dev/null +++ b/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/outputs.tf @@ -0,0 +1,49 @@ +# Copyright © 2023, Oracle and/or its affiliates. +# All rights reserved. Licensed under the Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl. + +output "atp_db_id" { + value = { + for adw in oci_database_autonomous_database.adw: + adw.display_name => adw.id + } +} + +output "ad" { + value = { + for idx, ad in oci_database_autonomous_database.adw: + ad.db_name => { "connection_strings" : ad.connection_strings.0.all_connection_strings} + } +} + +output "db_connection" { + value = one([ for b in oci_database_autonomous_database.adw : b.connection_strings]) +} + +output "private_endpoint_ip" { + value = one([for b in oci_database_autonomous_database.adw : b.private_endpoint_ip]) +} + +output "private_endpoint" { + value = ([for b in oci_database_autonomous_database.adw : b.private_endpoint]) +} + +output "url" { + value = [for b in oci_database_autonomous_database.adw : b.connection_urls.0.sql_dev_web_url] +} + +output "graph_studio_url" { + value = [for b in oci_database_autonomous_database.adw : b.connection_urls.0.graph_studio_url] +} + +output "machine_learning_user_management_url" { + value = [for b in oci_database_autonomous_database.adw : b.connection_urls.0.machine_learning_user_management_url] +} + +output "adb_wallet_content" { +value = oci_database_autonomous_database_wallet.autonomous_database_wallet["adw"].content +} + +output "database_fully_qualified_name" { + value = lower(trimsuffix(trimprefix(join("\n", [for b in oci_database_autonomous_database.adw : b.connection_urls.0.graph_studio_url]), "https://"), "/graphstudio/")) +} + diff --git a/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/variables.tf b/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/variables.tf new file mode 100644 index 0000000..0c664ad --- /dev/null +++ b/cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus/variables.tf @@ -0,0 +1,24 @@ +# Copyright © 2023, Oracle and/or its affiliates. +# All rights reserved. Licensed under the Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl. + +variable "adw_params" { + type = map(object({ + compartment_id = string + compute_model = string + compute_count = number + size_in_tbs = number + db_name = string + db_workload = string + db_version = string + license_model = string + database_admin_password = string + database_wallet_password = string + enable_auto_scaling = bool + is_free_tier = bool + create_local_wallet = bool + is_mtls_connection_required = bool + subnet_id = string + nsg_ids = list(string) + defined_tags = map(string) + })) +} diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/README.md b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/README.md index c31ffbb..e81e0c5 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/README.md +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/README.md @@ -232,7 +232,7 @@ Now, you'll want a local copy of this repo. You can make that with the commands: ## Prerequisites -- Install Terraform v0.13 or greater: https://www.terraform.io/downloads.html +- Install Terraform v0.15 or greater: https://www.terraform.io/downloads.html - Install Python 3.6: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7 - Generate an OCI API Key - Create your config under \$home*directory/.oci/config (run \_oci setup config* and follow the steps) @@ -373,7 +373,8 @@ The ADW subsystem / module is able to create ADW/ATP databases. * Parameters: * __db_name__ - The database name. The name must begin with an alphabetic character and can contain a maximum of 14 alphanumeric characters. Special characters are not permitted. The database name must be unique in the tenancy. * __db_password__ - The password must be between 12 and 30 characters long, and must contain at least 1 uppercase, 1 lowercase, and 1 numeric character. It cannot contain the double quote symbol (") or the username "admin", regardless of casing. The password is mandatory if source value is "BACKUP_FROM_ID", "BACKUP_FROM_TIMESTAMP", "DATABASE" or "NONE". - * __db_cpu_core_count__ - The number of OCPU cores to be made available to the database. For Autonomous Databases on dedicated Exadata infrastructure, the maximum number of cores is determined by the infrastructure shape. See Characteristics of Infrastructure Shapes for shape details. + * __db_compute_model__ - The compute model of the Autonomous Database. This is required if using the computeCount parameter. If using cpuCoreCount then it is an error to specify computeModel to a non-null value. + * __db_compute_count__ - The compute amount available to the database. Minimum and maximum values depend on the compute model and whether the database is on Shared or Dedicated infrastructure. For an Autonomous Database on Shared infrastructure, the 'ECPU' compute model requires values in multiples of two. Required when using the computeModel parameter. When using cpuCoreCount parameter, it is an error to specify computeCount to a non-null value. * __db_size_in_tbs__ - The size, in gigabytes, of the data volume that will be created and attached to the database. This storage can later be scaled up if needed. The maximum storage value is determined by the infrastructure shape. See Characteristics of Infrastructure Shapes for shape details. * __db_workload__ - The Autonomous Database workload type. The following values are valid: - OLTP - indicates an Autonomous Transaction Processing database @@ -398,12 +399,17 @@ variable "db_name" { variable "db_password" { type = string - default = "" + default = "WlsAtpDb1234#" } -variable "db_cpu_core_count" { +variable "db_compute_model" { + type = string + default = "ECPU" +} + +variable "db_compute_count" { type = number - default = 1 + default = 4 } variable "db_size_in_tbs" { @@ -423,7 +429,7 @@ variable "db_version" { variable "db_enable_auto_scaling" { type = bool - default = true + default = false } variable "db_is_free_tier" { @@ -433,21 +439,22 @@ variable "db_is_free_tier" { variable "db_license_model" { type = string - default = "LICENSE_INCLUDED" + default = "BRING_YOUR_OWN_LICENSE" } variable "tag" { type = string - default = "graph-get-started" # default = "movieapp" + default = "graph-get-started" + # default = "end-to-end" + # default = "gen-ai" } variable "run_post_load_procedures" { type = bool - default = false - # default = true + #default = false + default = true } - ``` ## Running the code diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/locals.tf b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/locals.tf index a6489b4..b150fbb 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/locals.tf +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/locals.tf @@ -33,13 +33,14 @@ data "oci_identity_region_subscriptions" "home_region_subscriptions" { locals{ ad_names = compact(data.template_file.ad_names.*.rendered) - conn_db = module.adw_database_private_endpoint.db_connection[0].profiles[1].value + conn_db = module.adw_ecpus.db_connection[0].profiles[1].value # Create Autonomous Data Warehouse adw_params = { adw = { - compartment_id = var.compartment_id, - cpu_core_count = var.db_cpu_core_count + compartment_id = var.compartment_id + compute_model = var.db_compute_model + compute_count = var.db_compute_count size_in_tbs = var.db_size_in_tbs db_name = var.db_name db_workload = var.db_workload @@ -60,7 +61,3 @@ locals{ # End } - - - - diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/main.tf b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/main.tf index d6da940..bedea71 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/main.tf +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/main.tf @@ -2,7 +2,7 @@ # All rights reserved. Licensed under the Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl. # Create ADW Database with Endpoint in private subnet or public ADW -module "adw_database_private_endpoint" { - source = "../../../cloud-foundation/modules/cloud-foundation-library/database/adw_private_endpoint" +module "adw_ecpus" { + source = "../../../cloud-foundation/modules/cloud-foundation-library/database/adw_ecpus" adw_params = local.adw_params } \ No newline at end of file diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/outputs.tf b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/outputs.tf index 543a020..2c18660 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/outputs.tf +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/outputs.tf @@ -11,30 +11,30 @@ output "adb_user_name" { value = "MOVIESTREAM" } -output "adb_user__password" { +output "adb_user_password" { value = "watchS0meMovies#" } output "ADW_Database_db_connection" { - value = module.adw_database_private_endpoint.db_connection + value = module.adw_ecpus.db_connection } -output "ADW_Database_private_endpoint_ip" { - value = module.adw_database_private_endpoint.private_endpoint_ip +output "ADW_Database_ip" { + value = module.adw_ecpus.private_endpoint_ip } output "Database_Actions" { - value = module.adw_database_private_endpoint.url + value = module.adw_ecpus.url } output "graph_studio_url" { - value = module.adw_database_private_endpoint.graph_studio_url + value = module.adw_ecpus.graph_studio_url } output "machine_learning_user_management_url" { - value = module.adw_database_private_endpoint.machine_learning_user_management_url + value = module.adw_ecpus.machine_learning_user_management_url } output "database_fully_qualified_name" { - value = module.adw_database_private_endpoint.database_fully_qualified_name + value = module.adw_ecpus.database_fully_qualified_name } diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provider.tf b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provider.tf index da03537..3daf300 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provider.tf +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provider.tf @@ -2,11 +2,11 @@ # All rights reserved. Licensed under the Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl. terraform { - required_version = ">= 1.1.0" + required_version = ">= 1.2.0" required_providers { oci = { source = "oracle/oci" - version = ">= 4.37.0" + version = ">= 5.9.0" } } } diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provisioners.tf b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provisioners.tf index b2841b8..4b8e96e 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provisioners.tf +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/provisioners.tf @@ -16,9 +16,7 @@ resource "null_resource" "sqlcl-create-usr" { rm -rf tables.sql EOT } - -depends_on = [module.adw_database_private_endpoint] - +depends_on = [module.adw_ecpus] } resource "local_file" "this" { diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/schema.yaml b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/schema.yaml index 64966c0..b49f56a 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/schema.yaml +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/schema.yaml @@ -23,7 +23,8 @@ groupings: - db_version - db_size_in_tbs - db_enable_auto_scaling - - db_cpu_core_count + - db_compute_model + - db_compute_count - db_workload - tag - run_post_load_procedures @@ -84,12 +85,12 @@ variables: enum: - LICENSE_INCLUDED - BRING_YOUR_OWN_LICENSE - default: BRING_YOUR_OWN_LICENSE + default: LICENSE_INCLUDED required: true visible: eq: - db_is_free_tier - - "false" + - false db_password: title: Database Admin Password description: "Provide admin password. Constraints: 12 - 30 characters. At least one uppercase letter, one lowercase letter, and one number. No special characters." @@ -124,38 +125,46 @@ variables: - 52 - 128 default: 1 - visible: true required: true + visible: + eq: + - db_is_free_tier + - false db_enable_auto_scaling: title: Indicates if auto scaling is enabled for the Autonomous Database CPU core count. description: "Indicates if auto scaling is enabled for the Autonomous Database CPU core count. " type: enum enum: - - "true" - - "false" - default: "false" + - true + - false + default: false required: true - visible: true - db_cpu_core_count: - title: The number of OCPU cores to be made available to the database - description: "The number of OCPU cores to enable. Available cores are subject to your tenancy's service limits." + visible: + eq: + - db_is_free_tier + - false + db_compute_model: + title: "The compute model of the Autonomous Database ECPUs" + description: "The compute model of the Autonomous Database ECPUs" type: enum enum: - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 - - 10 - - 11 - - 12 - default: 1 + - "ECPU" + default: "ECPU" required: true - visible: true + visible: + eq: + - db_is_free_tier + - false + db_compute_count: + title: The number of ECPUs cores to be made available to the database + description: "The number of ECPU cores to enable. For ECPUs count needs to be minimum 2 and maximum 512 ECPUs" + type: string + default: 4 + required: true + visible: + eq: + - db_is_free_tier + - false db_workload: title: Autonomous Database Type of workload. description: "Autonomous Database Type of workload." @@ -173,6 +182,7 @@ variables: - "movieapp" - "graph-get-started" - "end-to-end" + - "gen-ai" default: "end-to-end" required: true visible: true diff --git a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/variables.tf b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/variables.tf index 0dc3cea..fe1f70b 100644 --- a/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/variables.tf +++ b/cloud-foundation/solutions/Deploy-Autonomous-Database-and-the-MovieStream-data-sets-for-Oracle-LiveLabs/variables.tf @@ -3,7 +3,7 @@ terraform { - required_version = ">= 0.14.0" + required_version = ">= 0.15.0" } variable "tenancy_ocid" { @@ -48,9 +48,14 @@ variable "db_password" { default = "WlsAtpDb1234#" } -variable "db_cpu_core_count" { +variable "db_compute_model" { + type = string + default = "ECPU" +} + +variable "db_compute_count" { type = number - default = 1 + default = 4 } variable "db_size_in_tbs" { @@ -70,7 +75,7 @@ variable "db_version" { variable "db_enable_auto_scaling" { type = bool - default = true + default = false } variable "db_is_free_tier" { @@ -83,11 +88,12 @@ variable "db_license_model" { default = "LICENSE_INCLUDED" } - variable "tag" { type = string - #default = "graph-get-started" - default = "end-to-end" + # default = "movieapp" + default = "graph-get-started" + # default = "end-to-end" + # default = "gen-ai" } variable "run_post_load_procedures" {