https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda
Creates a Lambda function that when invoked triggers a rolling restart of an autoscaling group
https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda
auto-scaling-group aws lambda terraform terraform-module
Last synced: about 13 hours ago
JSON representation
Creates a Lambda function that when invoked triggers a rolling restart of an autoscaling group
- Host: GitHub
- URL: https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda
- Owner: rhythmictech
- License: mit
- Created: 2020-01-23T15:01:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-06-07T20:27:06.000Z (almost 4 years ago)
- Last Synced: 2026-04-01T02:41:21.794Z (26 days ago)
- Topics: auto-scaling-group, aws, lambda, terraform, terraform-module
- Language: HCL
- Homepage: https://registry.terraform.io/modules/rhythmictech/asg-rolling-restart-lambda/aws
- Size: 61.5 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# 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.
[](https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda/actions?query=workflow%3Atflint+event%3Apush+branch%3Amaster)
[](https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda/actions?query=workflow%3Atfsec+event%3Apush+branch%3Amaster)
[](https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda/actions?query=workflow%3Ayamllint+event%3Apush+branch%3Amaster)
[](https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda/actions?query=workflow%3Amisspell+event%3Apush+branch%3Amaster)
[](https://github.com/rhythmictech/terraform-aws-asg-rolling-restart-lambda/actions?query=workflow%3Apre-commit-check+event%3Apush+branch%3Amaster)

## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13.4 |
## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | n/a |
| [external](#provider\_external) | n/a |
| [null](#provider\_null) | n/a |
| [random](#provider\_random) | n/a |
## Modules
| Name | Source | Version |
|------|--------|---------|
| [lambda\_version](#module\_lambda\_version) | rhythmictech/find-release-by-semver/github | ~> 1.1 |
| [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1 |
## Resources
| Name | Type |
|------|------|
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
| [aws_iam_role_policy_attachment.lambda-execution-role-attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_lambda_function.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [null_resource.lambda_zip](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [random_uuid.lambda_uuid](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.lambda_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.lambda_policy_doc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [external_external.sha](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [asg\_name](#input\_asg\_name) | Name of the ASG to execute the rolling restart against | `string` | n/a | yes |
| [lambda\_version\_constraint](#input\_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](#input\_loglevel) | Logging level for the rolling restart lambda function. | `string` | `"INFO"` | no |
| [name](#input\_name) | Name to be used for resources | `string` | `"rolling-restart-lambda"` | no |
| [tags](#input\_tags) | Map of tags that should be added to stuff | `map(any)` | n/a | yes |
## Outputs
| Name | Description |
|------|-------------|
| [function\_arn](#output\_function\_arn) | ARN of the Lambda function |
| [function\_name](#output\_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.
- [pre-commit](https://pre-commit.com)
- [terraform](https://terraform.io)
- [tfenv](https://github.com/tfutils/tfenv)
- [terraform-docs](https://github.com/segmentio/terraform-docs)
- [tfsec](https://github.com/tfsec/tfsec)
- [tflint](https://github.com/terraform-linters/tflint)
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.