Tuesday, February 22, 2022

Reverse engineering an existing GCP project with terraformer

It can be tough to try to reverse engineer an existing project that has never used terraform. Terraformer can look at an existing project and generate the corresponding terraform code for you. 

I tried it out on an existing legacy project which used Google Cloud Storage, BigQuery and various service accounts. The setup was a little tricky so I put together a script to simply things. The script assumes you have gcloud setup or a service account key/impersonation and you may need to adjust the --resources parameter.



You may be in for a shock when you examine the generated code. Terraform works well when you think of you application are modules. A module that groups together a variety of resources (gcs bucket + service account + compute engine) that forms part of the application is far more valuable then simply considering each resource by itself. Terraformer has no idea how these resources are used or grouped. So you might need to consider refactoring the generated code into more manageable modules.

I would definitely use the tool again on projects where there is no Terraform or where there has been significant infrastructure drift. There's also Pulumi, maybe for another day.

Monday, January 31, 2022

Raspberry Pi/Raspbian - chromium/chromedriver crash after upgrade to 99.0.4844.51

Upgraded to chromedriver 99.0.4844.51 on Raspbian(bullseye) and seeing this in your chromedriver.log?
[0312/111354.689372:ERROR:egl_util.cc(74)] Failed to load GLES library: /usr/lib/chromium-browser/libGLESv2.so: /usr/lib/chromium-browser/libGLESv2.so: cannot open shared object file: No such file or directory [0312/111354.709636:ERROR:viz_main_impl.cc(188)] Exiting GPU process due to errors during initialization [0312/111354.735541:ERROR:gpu_init.cc(454)] Passthrough is not supported, GL is disabled, ANGLE is
Add "--disable-gpu" as an option when setting up the browser. e.g. for selenium/java:
ChromeOptions options = new ChromeOptions() options.addArguments("--disable-gpu")
It looks like the behaviour has changed as this "shouldn't" be required. More about flags here

Tuesday, January 11, 2022

Undelete bigquery table

One hour ago:
bq cp mydataset.table@-3600000 mydataset.table_restored
Absolute (ms since UNIX epoch) GMT: Wednesday, 26 May 2021 13:41:53 = 1622036513000 https://www.epochconverter.com/
bq cp mydataset.table@1622036513000 mydataset.table_restored
More on Bigquery time travel

Wednesday, December 15, 2021

Java 17

Java SE 17 is upon us, and with it comes a whole host of new features and changes. We'll take a look at a few in this article. 

Pseudo-Random Number Generators (PRNGs) are getting a major update in Java with the release of JEP 356. New interfaces and implementations make it easier to use different algorithms interchangeably and offer better support for stream-based programming. This is a great improvement for Java developers who require randomness in their applications. 

The JDK is constantly evolving and improving, and part of that process is ensuring that internal APIs are properly encapsulated. JEP 403 represents a step in that direction, by removing the –illegal-access flag. This will prevent JDK users from accessing internal APIs, except for critical ones like sun.misc.Unsafe.  

Features developer by Project Panana enable easier access to C libraries from Java code. The Foreign Function and Memory API is eventually due to replace the JNI API.