https://github.com/druids/terraform-aws-asg-instance-refresh
Terraform module providing a simple AWS Lambda function to update Launch Template for Auto Scaling Group to use the latest AMI stored in SSM Parameter.
https://github.com/druids/terraform-aws-asg-instance-refresh
aws aws-autoscaling aws-autoscaling-group aws-autoscaling-instance-refresh aws-lambda devops-tools hacktoberfest python terraform terraform-aws terraform-module
Last synced: 7 months ago
JSON representation
Terraform module providing a simple AWS Lambda function to update Launch Template for Auto Scaling Group to use the latest AMI stored in SSM Parameter.
- Host: GitHub
- URL: https://github.com/druids/terraform-aws-asg-instance-refresh
- Owner: druids
- License: mit
- Created: 2020-09-15T14:58:28.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T14:12:39.000Z (11 months ago)
- Last Synced: 2024-08-07T16:05:18.745Z (11 months ago)
- Topics: aws, aws-autoscaling, aws-autoscaling-group, aws-autoscaling-instance-refresh, aws-lambda, devops-tools, hacktoberfest, python, terraform, terraform-aws, terraform-module
- Language: HCL
- Homepage:
- Size: 60.5 KB
- Stars: 8
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13 |
| [aws](#requirement\_aws) | >= 3.0 |## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | >= 3.0 |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [aws_cloudwatch_event_rule.rule](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource |
| [aws_cloudwatch_event_target.refresh_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource |
| [aws_iam_role.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy) | resource |
| [aws_lambda_function.refresh](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_permission.allow_cloudwatch_events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
| [aws_autoscaling_group.group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/autoscaling_group) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_lambda_layer_version.sentry](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_layer_version) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [ami\_ssm\_parameter](#input\_ami\_ssm\_parameter) | Name of SSM parameter containing the current AMI | `string` | `"/aws/service/ecs/optimized-ami/amazon-linux-2/recommended"` | no |
| [ami\_ssm\_parameter\_arm](#input\_ami\_ssm\_parameter\_arm) | Name of SSM parameter containing the current AMI (ARM) | `string` | `"/aws/service/ecs/optimized-ami/amazon-linux-2/arm64/recommended"` | no |
| [auto\_scaling\_group\_is\_arm\_default](#input\_auto\_scaling\_group\_is\_arm\_default) | Set to true if your ASG uses ARM instances in the default launch template | `string` | `false` | no |
| [autoscaling\_group\_name](#input\_autoscaling\_group\_name) | Name of the auto scaling group to refresh | `string` | n/a | yes |
| [cloudwatch\_event\_rule\_name](#input\_cloudwatch\_event\_rule\_name) | Name of the CloudWatch Event Rule | `string` | `"ASGRefreshInstancesEventRule"` | no |
| [cloudwatch\_event\_rule\_schedule\_expression](#input\_cloudwatch\_event\_rule\_schedule\_expression) | Schedule expression for CloudWatch Event Rule | `string` | `"cron(0 0 * * ? *)"` | no |
| [describe\_instance\_refreshes\_max\_records](#input\_describe\_instance\_refreshes\_max\_records) | Page size for boto3 when calling autoscaling:DescribeInstanceRefreshes (max is 100) | `number` | `100` | no |
| [instance\_refresh\_instance\_warmup](#input\_instance\_refresh\_instance\_warmup) | Instance warmup time for instance refresh | `number` | `300` | no |
| [instance\_refresh\_min\_healthy\_percentage](#input\_instance\_refresh\_min\_healthy\_percentage) | Minimum healthy percentage for instance refresh | `number` | `90` | no |
| [instance\_refresh\_skip\_matching](#input\_instance\_refresh\_skip\_matching) | Skip matching instances for instance refresh | `bool` | `false` | no |
| [lambda\_architecture](#input\_lambda\_architecture) | Set CPU architecture for the Lambda function. Valid values are "x86\_64" and "arm64". | `string` | `"x86_64"` | no |
| [lambda\_description](#input\_lambda\_description) | Description of the Lambda function | `string` | `"Keeps ASG Launch Template updated with most recent AMI read from SSM Parameter"` | no |
| [lambda\_name](#input\_lambda\_name) | Name of the Lambda function | `string` | `"ASGRefreshInstances"` | no |
| [lambda\_role\_description](#input\_lambda\_role\_description) | Role description for the Lambda function | `string` | `""` | no |
| [lambda\_role\_name](#input\_lambda\_role\_name) | Role name for the Lambda function | `string` | `"ASGRefreshInstancesLambdaRole"` | no |
| [lambda\_timeout](#input\_lambda\_timeout) | Timeout for Lambda function in seconds | `number` | `60` | no |
| [lambda\_runtime](#input\_lambda\_runtime) | Lambda Function runtime | `string` | `python3.11` | no |
| [launch\_template\_source\_version](#input\_launch\_template\_source\_version) | Source version for the new launch template | `string` | `"$Default"` | no |
| [launch\_template\_version\_description](#input\_launch\_template\_version\_description) | Description of the new launch template version in Python's f-string format | `string` | `"Automated AMI refresh to \"{image_id}\""` | no |
| [launch\_templates\_arns](#input\_launch\_templates\_arns) | List of Launch Template ARNs to allow access to | `list(string)` |[| no |
"*"
]
| [sentry\_dsn](#input\_sentry\_dsn) | n/a | `string` | `null` | no |
| [sentry\_environment](#input\_sentry\_environment) | n/a | `string` | `null` | no |
| [sentry\_lambda\_layer\_version](#input\_sentry\_lambda\_layer\_version) | n/a | `number` | `11` | no |
| [update\_mixed\_instances\_policy\_overriden\_launch\_templates](#input\_update\_mixed\_instances\_policy\_overriden\_launch\_templates) | If you do not want to also update launch templates that override the default launch template, set this to false | `bool` | `true` | no |## Outputs
| Name | Description |
|------|-------------|
| [asg\_arn](#output\_asg\_arn) | n/a |