Skip to content

rhythmictech/terraform-aws-asg-rolling-restart-lambda

Repository files navigation

terraform-aws-asg-rolling-restart-lambda

This module creates a lambda that uses an ASG's healthchecks to do a rolling restart of its instances. Note that there are other strategies to handle this, including what is now native ASG functionality. However, this module still has some advantages and is therefore not deprecated.

tflint tfsec yamllint misspell pre-commit-check follow on Twitter

Requirements

Name Version
terraform >= 0.13.4

Providers

Name Version
aws n/a
external n/a
null n/a
random n/a

Modules

Name Source Version
lambda_version rhythmictech/find-release-by-semver/github ~> 1.1
tags rhythmictech/tags/terraform ~> 1.1

Resources

Name Type
aws_iam_role.this resource
aws_iam_role_policy.this resource
aws_iam_role_policy_attachment.lambda-execution-role-attach resource
aws_lambda_function.this resource
null_resource.lambda_zip resource
random_uuid.lambda_uuid resource
aws_caller_identity.current data source
aws_iam_policy_document.lambda_assume_role_policy data source
aws_iam_policy_document.lambda_policy_doc data source
aws_region.current data source
external_external.sha data source

Inputs

Name Description Type Default Required
asg_name Name of the ASG to execute the rolling restart against string n/a yes
lambda_version_constraint NPM style version constraint to apply when looking for the correct version of the lambda code string "~1.0.1-rc9" no
loglevel Logging level for the rolling restart lambda function. string "INFO" no
name Name to be used for resources string "rolling-restart-lambda" no
tags Map of tags that should be added to stuff map(any) n/a yes

Outputs

Name Description
function_arn ARN of the Lambda function
function_name Name of the Lambda function

Getting Started

This workflow has a few prerequisites which are installed through the ./bin/install-x.sh scripts and are linked below. The install script will also work on your local machine.

We use tfenv to manage terraform versions, so the version is defined in the versions.tf and tfenv installs the latest compliant version. pre-commit is like a package manager for scripts that integrate with git hooks. We use them to run the rest of the tools before apply. terraform-docs creates the beautiful docs (above), tfsec scans for security no-nos, tflint scans for best practices.