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. 

Tuesday, June 22, 2021

Bigquery row level security

Bye bye authorised views.. https://cloud.google.com/bigquery/docs/row-level-security-intro

Monday, December 28, 2020

Confluent Cloud Kafka vs Google Cloud Pubsub Feature compare 2020

FeatureConfluent Cloud KafkaGoogle Cloud PubsubNotes
Data RetentionSet retention per topic in Confluent Cloud, including unlimited retention with log compaction.Retains unacknowledged messages in persistent storage for 7 days from the moment of publication. There is no limit on the number of retained messages. Have to write custom subscriber/publisher to save beyond 7 days [L] + ongoing BAU [S]
ReplayA consumer request an "offset", however the retention period is dictated by the broker config"Snapshots" can be created for later replay by these are limited to 7 days as per retention policy. As per above, a custom subscriber/publisher to save/replay message. [L] + ongoing BAU [S]
Message OrderingYes, within a partition, In general, messages are written to the broker in the same order that they are received by the producer client.No, Pub/Sub provides a highly-available, scalable message delivery service. The tradeoff for having these properties is that the order in which messages are received by subscribers is not guaranteed. While the lack of ordering may sound burdensome, there are very few use cases that actually require strict ordering.
Delivery SemanticsExactly-once delivery semanticsAt-least-once, exactly once possible with dataflow
LatencyAdvertised at being able to "Achieve sub 30 ms latency at scale", no mention of this in SLA.Pub/Sub does not guarantee message delivery latency
Uptime"Service Level" Monthly Uptime Percentage of at least 99.95%.Is this 99.95% of GCP's 99.95%?"Service Level Objective" Monthly Uptime Percentage to Customer of at least 99.95%Both offer credits to account if not met but this is unlikely to be suitable for an enterprise org
Schema RegistryYes for Avro schemas and very new (GA August 2019)No, Data Catalog is in beta and could be used to build one [XL]
IAM / ACL"Preview" for Role/SAML, ACLs You are provided auth keys that you need to store/share/rotate. These could be stored in Cloud KMS, however, this would need to be automated [XL] + ongoing BAU [M]Standard Google IAM
EncryptionYes in transit and at rest with NO payload encryption. Clients are responsible for writing custom encryption/decryption connecting to (e.g) Cloud KMS. A custom library would need to be written that is used by everyone for publishing and subcribing [L]Cloud KMS(HSM/Software/BYOK/External Key Manager) with CMEK
VPC SecurityUnknown/No, can Confluent Cloud be made to respect VPC service controls?VPC Service Controls protection applies to all push and pull operations except existing Pub/Sub push subscriptions
Stream Processing"fully-managed KSQL", no kafka streams, would have to run Kafka Streams/Storm cluster connecting to Confleunt Cloud which is likely to introduce latencyApache Beam / Cloud Dataflow fully managed
Costs per 130GB$37$39Based on example calc on confluent and google pricing calc
Priority QueuesYesNo, but can segregate by topic
Multi-zone high availabilityNot advertised "Contact Confluent"Yes

Tuesday, August 25, 2020

multi language beam pipelines

https://cloud.google.com/blog/products/data-analytics/multi-language-sdks-for-building-cloud-pipelines

Saturday, July 25, 2020

Saturday, June 13, 2020

Misconfigured Kubeflow workloads are a security risk

welcome to the cloud - https://www.microsoft.com/security/blog/2020/06/10/misconfigured-kubeflow-workloads-are-a-security-risk/

Friday, June 12, 2020

Wednesday, April 29, 2020

Calling Native Libraries from Java

A couple of options I've used and seen: 

Friday, April 10, 2020

Google Cloud IAM Madness

After the recent GCP outage related to IAM, I found some odd behaviour with gsutil/gcloud. A script that had faithfully run for many months stopped working with:

ServiceException: 401 Anonymous caller does not have storage.buckets.list access to project xxxx

I tried recreating the service account key used for the operation with no luck. To fix the problem, I had to create a new bucket!

gsutil mb -b on -l us-east1 gs://my-awesome-bucket123ed321/
Creating gs://my-awesome-bucket123ed321/...
gsutil ls
gs://my-awesome-bucket123ed321/
gs://<my_original_bucket_I_couldnt_see>/

Wierd!!!!


Wednesday, February 05, 2020

Cloud Billing Budget API in beta

You can finally set budgets via the API in GCP. This is a huge relief to all those org admins out there who have had to do this manually.

AND, hold on to your hats, there's terraform support as well! 

Looks like Christmas came late....


data "google_billing_account" "account" {
  provider = google-beta
  billing_account = "000000-0000000-0000000-000000"
}

resource "google_billing_budget" "budget" {
  provider = google-beta
  billing_account = data.google_billing_account.account.id
  display_name = "Example Billing Budget"
  amount {
    specified_amount {
      currency_code = "USD"
      units = "100000"
    }
  }
  threshold_rules {
      threshold_percent =  0.5
  }
}

Friday, November 08, 2019

Running Flink in Production

This is a great watch for those beginning their journey with Flink.


Saturday, August 17, 2019

Saturday, April 20, 2019

Terraform init in the real world

Rather than fully configuring your backend.tf in a file.
terraform {
 backend "gcs" {
   bucket  = "my-bucket-123"
  prefix  = "terraform/state" 
}
I prefer to use the command line in order avoid polluting the code with any environment specific names.

terraform init \    
           -backend-config="bucket=my-bucket-123" \     
           -backend-config="prefix=terraform/state
As Google Cloud Storage buckets are unique across all projects, they will change as you move from project to project.