• Deploy a lambda function using terraform

    3 min read

    AWS Lambda terraform aws_lambda_function archive_file

    To be able to deploy a lambda function there are several pieces that need to be deployed:

    • IAM roles: It might need to access to the AWS API, so we need to create an IAM role to control it's privileges
    • Triggering: We might want the function to get triggered with some event (that's what we are going to do on this post) or a load balancer
    • Code: What we want to execute
    • Lambda function itself


  • Configure an AWS Load Balancer to target an Autoscaling Group using terraform

    3 min read

    Terraform AWS load balancer target auto scaling group

    It's quite convenient to be able to configure a AWS Load Balancer to target an Auto Scaling Group so we don't have to handle how instances are getting in and out of this load balancer. This can be done easily using terraform as follows


  • Enable access logs for an AWS ALB using terraform

    2 min read

    To be able to collect access logs it might be just more convenient to be able to enable them at the load balancer level rather than having to aggregate logs from all the backend services. If we are using an AWS ALB we can configure it to push it's logs to an S3 bucket


  • How to update terraform modules

    5 min read

    terraform init upgrade git

    When we change the location of any terraform module we need to run terraform init again to be able to pick up the right version:

    $ terraform plan
    Acquiring state lock. This may take a few moments...
    Releasing state lock. This may take a few moments...
    │ Error: Module source has changed
    │   on main.tf line 17, in module "terraform-module":
    │   17:   source = "git::ssh://git@github.com/pet2cattle/terraform-module.git?ref=1.0.2"
    │ The source address was changed since this module was installed. Run "terraform init" to install all modules required by this configuration.


  • How to test terraform's HCL code

    2 min read

    terraform console HCL

    To be able to learn about new terraform functions we can use terraform output to learn how a variable is modified. But this can take a while if we have a lot of resources to compute.

    Instead, if we know the values we want to use beforehand it might be easier and quicker to use terraform console



Older content...