• Kubernetes: get logs from an already restarted container

    2 min read

    If we need to investigate why a container keeps restarting, a good place to start is taking a look at the logs when it crashes. Since Kubernetes will automatically restart a failed container, if we use kubectl logs we will get the logs of the restarted container instead of the one that have crashed:

    $ kubectl logs ampa-7d98c84675-dpzjw -c ampa 
    [2021-10-15 14:20:41 +0000] [1] [INFO] Starting gunicorn 20.0.4
    [2021-10-15 14:20:41 +0000] [1] [INFO] Listening at: (1)
    [2021-10-15 14:20:41 +0000] [1] [INFO] Using worker: sync
    [2021-10-15 14:20:41 +0000] [8] [INFO] Booting worker with pid: 8

    How can we retrieve the logs of the previous container?


  • How to override a provider with a local version

    2 min read

    If we are modifying a provider, to be able to properly test it we might want to run a terraform plan or apply using this provider. To be able to override a given provider using this method (dev_overrides) we will need to use terraform v0.14 or later


  • Terrafrom: Ignore changes on some of the managed resources

    2 min read

    Some of the resources we create using terraform might be externally changed, for example an AutoScalingGroup desired_capacity can be changed externally (not modifying terraform's state) in order to handle more traffic. That's the case for the worker's ASG on an EKS cluster, which will be usually modified by the cluster autoscaler

    Note: Objects have changed outside of Terraform
    Terraform detected the following changes made outside of Terraform since the last "terraform apply":
      # module.eks.aws_autoscaling_group.workers["pet2cattle_eu-west-1a"] has been changed
      ~ resource "aws_autoscaling_group" "workers" {
          ~ desired_capacity          = 7 -> 6
            id                        = "pet2cattle_eu-west-1a2021082509502468370000000a"
            name                      = "pet2cattle_eu-west-1a2021082509502468370000000a"
            # (22 unchanged attributes hidden)
            # (16 unchanged blocks hidden)
    Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.


  • How to write a string replacement browser plugin

    2 min read

    If you want to write a browser plugin that replaces strings on webpages the easiest method is by doing it using Javascript. So, to replace a in a webpage a string for another we can use the following Javascript code:

    document.body.innerHTML = document.body.innerHTML.replace(/\bA\b/g, "B");


  • How to use terraform's nonsensitive() function

    2 min read

    Starting terraform 0.15 variables can be marked as sensitive, so it won't appear in plain text as a terraform output unless we explicitly request them. But we can also make the variable as non sensitive using the nonsensitive() function



Older content...