Posts

How to create pipeline variables from terraform output

I show you how to transform terraform output into pipeline variables from script Intro This is how to set pipeline variable from script. You can read more here echo "##vso[task.setvariable variable=varname]value" Terraform output can be outputted as json content. terraform output -json > sample.json Suppose the terraform output looks like below: { "app_service" : { "name" : "myapp" , "fqdn" : "myapp.azurewebsites.net" } , "database" : { "name" : "example" , "server_fqdn" : "myserver.database.windows.net" , "connection_string" : "server=myserver.database.windows.net, initial catalog=example" } , "application_insights_key" : "12345" } You have to think how to transform json representation into pipeline variables. The solution has to work with a

How to extract data from terraform output

You need to deploy changes to app service and database in your CD pipeline. As part of your CD pipeline first you deploy changes to infrastructure and after that you update app service and run migrations against your database instance. Assume that only terraform knows the details about infrastructure. And the only way to extract this information is by calling terraform output command. In this post I show you how you can extract data from terraform output. Let’s say you have the following terraform output (JSON format) { "app_service" : { "name" : "myapp" , "fqdn" : "myapp.azurewebsites.net" } , "database" : { "name" : "example" , "server_fqdn" : "myserver.database.windows.net" , "connection_string" : "server=myserver.database.windows.net, initial catalog=example" } , "applicati

How to create end user certificate

I show you how to generate end user certificate signed by intermediate certificate in PEM format. You need to execute 3 steps Create intermediate certificate Create certificate signing request CSR Sign the certificate Create intermediate certificate (self signed) First you need to generate certificate that will be used for signing. For test purposes you generate self signed cert. Let’s execute command that creates private key along with public cert. openssl req -newkey rsa:2048 -keyout server.key -x509 -new -nodes -out server.pem \ -subj "/CN=domain.com/O=owner" -days 365 Create certificate signing request CSR Second you need to create signing request for your end user certificate. openssl req -new -newkey rsa:2048 -nodes -keyout client.key -out client_csr.pem \ -subj "/CN=client.com/O=client" The command produces request in pem format: -----BEGIN CERTIFICATE REQUEST----- MIICazCCAVMCAQAwJjETMBEGA1UEAwwKY2xpZW50LmNvbTEPMA0GA1UECgwGY2xp ZW50MIIBIjANB

Struct as Value Object

In C# you have two choices for representing value objects, either use class or struct.  In this article we look closer into struct as base building block for value objects. I would like to show you benefits and drawbacks of using structs so it will be easier to you to make decision what you should choose. Why are you want to make a value object as struct?  You can say for performance reasons. That makes sense as internally structures are allocated in memory stack. Thus structure allocation and deallocation is cheaper and faster operation in comparison to reference types.  On the other hand when you compare structures then you can fall into the trap. Default implementation of Equals and GetHashCode might not be so performant to you. Internally it can use reflection for comparing struct fields which may impact performance noticeably when you deal with huge collections or dictionaries. Fortunately it is enough to override Equals and GetHashCode and ideally implement IEquatable interface t