• How to override a provider with a local version

    2 min read

    terraform provider development

    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

    14/10/2021

    Read more...
  • 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.
    
    (...)
    

    13/10/2021

    Read more...
  • How to write a string replacement browser plugin

    2 min read

    browser plugin javascript Firefox Chrome

    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");
    

    12/10/2021

    Read more...
  • How to use terraform's nonsensitive() function

    2 min read

    terraform sensitive

    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

    07/10/2021

    Read more...
  • Merging resources from several terraform states

    2 min read

    terraform state merge

    If you have several terraform projects for handling the deployment of a part of the application and you want to consolidate it into a single project, you can create a new terraform state and import all the resources using terraform import or you can use tfstate-merge to copy resources to the new state to consolidate it

    06/10/2021

    Read more...
  • Redirect TF_LOG logs into a file

    3 min read

    terraform TF_LOG TF_LOG_PATH

    When we enable tracing terraform using TF_LOG the output can be overwhelmingly hard to read due to the amount of info it's printed. Using TF_LOG_PATH we can tell terraform to save all the debug info to a file so we can see the usual output and be able to check the logs later on

    05/10/2021

    Read more...
  • Update local kubeconfig to connect to an AWS EKS cluster

    2 min read

    If we want to connect to an AWS EKS cluster using kubectl we need to update our kubeconfig (~/.kube/config) To do se we can use awscli

    04/10/2021

    Read more...
  • Replace a string on commit using a github action

    2 min read

    github replace string commit

    Using a github action we can make it search for a given string an replace it for another when we commit the data. It can be useful to fix common mistakes

    01/10/2021

    Read more...

More recent...

From pet to cattle
Treat your kubernetes clusters like cattle, not pets