Tag tech

.gitattributes

Just like .gitignore, there is another file that you can use in your git repos: The .gitattributes file. You typically place this in the root of your repo. It has lines of the form: pattern attr1 attr2 ... It essentially means that for files that satisfy the regex pattern, apply the attribute attr1, attr2 etc to them. Let’s see some examples. Let’s say our .gitattributes had the line below: *.png binary *.

Trap in bash scripts

You may be familiar with the “set -e” you typically see in bash scripts. It means that the script should exit on error (default behaviour of bash is to keep going) Recently I needed a script to do some cleanup action. i.e. I wanted the script to exit on error, but I also wanted some cleanup action to be performed. A use case might be that if something fails, then before exiting, ship log files to an S3 bucket for troubleshooting.

Adding multiple certs to an ALB

If you are using AWS and ALBs, you have the ability to add multiple certs to the ALB and terminate SSL there. While it is easy to do via the AWS console, their documentation is not that clear as to how to do it in an automated way. The following is the code snippet, written with troposphere, to show you how to do it. First create a HTTS listener with a certificate: def create_lb_listener_https(alb, default_target_group, param_cert_one): return Listener(‘LoadBalancerListenerHTTPS’, Port='443’,Protocol='HTTPS’, LoadBalancerArn=Ref(alb), DefaultActions=[Action(Type='forward’,TargetGroupArn=Ref(default_target_group))],# Note, only one cert ARN can be specified here, else you will get an errorCertificates=[Certificate(CertificateArn=Ref(param_cert_one)),])

Docker image tagging in ECR

AWS provides a docker repository called ECR. This is similar to Docker Hub, Artifactory etc and provides a convenient place to place docker images for later use e.g. deployment. ECR supports Docker Image Manifest V2, Schema 2, providing the ability to add multiple tags per image. I recently ran into an issue wherein I tagged an image with multiple tags at build time and then just pushed one tag, thinking all tags would appear on ECR.