OCI's ATP as a second dish

What is your first association in case of ATP term? For me? Hmmm… Adenosine triphosphate, the most energetic organic chemical which fuels up biological forms of life…? That was something I have learned in secondary school long, long time ago. Well… ok…  But here I will be talking about something different! I will try to make you familiar with brand new Oracle Cloud Infrastructure service called Autonomous Transaction Processing (ATP). This new PaaS offering means you can create a database with OLTP capabilities, within a couple of minutes. Most of the tasks are fully automated. Oracle use to define it as self-driven, autonomous, which means it will require minimal effort to maintain. As a developer, you can focus on your tables and data itself. I used to specify ATP as a database container. Additionally, it is possible to provision that autonomous database automatically with Terraform.
For that purpose, I have downloaded the code from Terraform OCI Provider examples, which was published as a part of Terraform OCI Provider GitHub repo. Of course, I have modified it a little bit and here is my small GitHub repo with examples. The first ATP database is here:

MacBook-Pro-Martin:FoggyKitchenATP martinlinxfeld$ more atp.tf
resource "oci_database_autonomous_database" "autonomous_database" {
  admin_password           = "${random_string.autonomous_database_admin_password.result}"
  compartment_id           = "${var.compartment_ocid}"
  cpu_core_count           = "${var.autonomous_database_cpu_core_count}"
  data_storage_size_in_tbs = "${var.autonomous_database_data_storage_size_in_tbs}"
  db_name                  = "${var.autonomous_database_db_name}"
  display_name  = "${var.autonomous_database_display_name}"
  freeform_tags = "${var.autonomous_database_freeform_tags}"
  license_model = "${var.autonomous_database_license_model}"

For accessing ATP from outside, for example from SQLDeveloper I need to have wallet. This wallet will be stored locally on your computer as a file:

MacBook-Pro-Martin:FoggyKitchenATP martinlinxfeld$ more atp_wallet.tf
data "oci_database_autonomous_database_wallet" "autonomous_database_wallet" {
autonomous_database_id = "${oci_database_autonomous_database.autonomous_database.id}"
password = "${random_string.wallet_password.result}"
resource "local_file" "autonomous_database_wallet_file" {
content = "${data.oci_database_autonomous_database_wallet.autonomous_database_wallet.content}"
filename = "${path.module}/foggykitchen_atp_wallet.zip"

Next, I need to create the backup for ATP. Keep in mind it will be a manual backup (there is automated backup already included). This manual backup you can execute before the major change in data just to have additional protection. Then you can manually restore from that backup if something goes wrong with data change. For the purpose of that backup, you need to prepare an object storage bucket. Name of the bucket should be backup_<database_name>:

MacBook-Pro-Martin:FoggyKitchenATP martinlinxfeld$ more atp_backup.tf
data "oci_objectstorage_namespace" "autonomous_database_backup_namespace" {
resource "oci_objectstorage_bucket" "autonomous_database_backup_bucket" {
compartment_id = "${var.compartment_ocid}"
name = "${var.autonomous_database_backup_display_name}"
namespace = "${data.oci_objectstorage_namespace.autonomous_database_backup_namespace.namespace}"
resource "oci_database_autonomous_database_backup" "autonomous_database_backup" {
autonomous_database_id = "${oci_database_autonomous_database.autonomous_database.id}"
display_name = "${var.autonomous_database_backup_display_name}"

Of course, I have variables.tf as well, but you will find it in GitHub repo for this small project. Ok, everything seems to be ready so I can start “terraform apply” command. This is output…
And after 4-5 minutes we have that database up and running, but there is a small problem with initial manual backup. It has failed for some reason:
So let us connect to ATP with SQLDeveloper. Let’s do it just to fix the manual backup configuration according to the documentation’s section written here. Here is SQLDeveloper screenshot with the proper sequence:
Ok, so now manual backup should work fine. You can see that on the screenshot below. I have created another manual backup and it was successful:
Looks like the second dish is ready. I have added some flavoring, but the dish seems to be delicious. 🙂 Go ahead and cook for yourself! 🙂
MasterChef Martin.

2 thoughts on “OCI's ATP as a second dish

Leave a Reply