recursive.codes

recursive.codes

recursive.codes


The Personal Blog of Todd Sharp

Automatic Autonomous Wallet Download & Configuration with Micronaut

Posted By: Todd Sharp on 3/4/2021 3:54 GMT
Tagged: Cloud, Developers, Java

Back in September, we announced the Micronaut Oracle Cloud Infrastructure module to help developers easily integrate with the OCI SDK as well as use Micronaut for their serverless Oracle Functions. Today, I’m super excited to tell you about an enhancement to that module that is guaranteed to make your life easier and your application more secure when it’s time to connect your Micronaut applications with Autonomous Database - automatic wallet download. That’s right, you no longer have to manually download your wallet and worry about how to distribute it with your application. Just configure your application to use the OCI SDK module, provide your Autonomous DB OCID, DB username and password and Micronaut will download the wallet, store it in memory, and handle creating your connect string and connecting to the DB. Let’s look at a quick example.

Configure Micronaut OCI Module

To get started, include a dependency on the module in your build.gradle:

Now determine which type of auth provider you’ll use. Since I have the OCI CLI configured locally, I use a ConfigFileAuthenticationDetailsProvider, so I add the following to my src/main/resources/application.yml file.

When I deploy to the cloud, I use a InstancePrincipalsAuthenticationDetailsProvider by creating a file called src/main/resources/application-oraclecloud.yml which Micronaut is intelligent enough to use once I deploy to the Oracle Cloud.

Next, add a dependency on the ATP module:

And don’t forget your OJDBC drivers:

And something for connection pooling:

Finally, add a datasource. As mentioned above, you’ll need to provide the OCID for your DB, a schema user and password and a strong password that will be used to encrypt the keys in your wallet.

That’s it! Now start your app and you should notice an entry in the console output when the connection is configured:

Summary

In this post, we looked at how to configure a Micronaut application to securely connect to an Autonomous DB instance by automatically downloading, storing and configuring a wallet. To read more about this feature, please refer to the Micronaut documentation.

Photo by Almos Bechtold on Unsplash



Related Posts

Querying Autonomous Database from an Oracle Function (The Quick, Easy & Completely Secure Way)

Querying Autonomous Database from an Oracle Function (The Quick, Easy & Completely Secure Way)

I've written many blog posts about connecting to an Autonomous DB instance in the past. Best practices evolve as tools, services, and frameworks become...

Sending Email With OCI Email Delivery From Micronaut

Sending Email With OCI Email Delivery From Micronaut

Email delivery is a critical function of most web applications in the world today. I've managed an email server in the past - and trust me - it's not fun...

Brain to the Cloud - Part III - Examining the Relationship Between Brain Activity and Video Game Performance

Brain to the Cloud - Part III - Examining the Relationship Between Brain Activity and Video Game Performance

In my last post, we looked at the technical aspects of my Brain to the Cloud project including much of the code that was used to collect and analyze the...

Note: Comments are currently closed on this blog. Disqus is simply too bloated to justify its use with the low volume of comments on this blog. Please visit my contact page if you have something to say!