Skip to content

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.

License

Notifications You must be signed in to change notification settings

skip-pay/terraform-aws-asg-instance-refresh

 
 

Repository files navigation

Requirements

Name Version
terraform >= 0.13
aws >= 3.0

Providers

Name Version
aws >= 3.0

Modules

No modules.

Resources

Name Type
aws_cloudwatch_event_rule.rule resource
aws_cloudwatch_event_target.refresh_lambda resource
aws_iam_role.lambda resource
aws_iam_role_policy.lambda resource
aws_lambda_function.refresh resource
aws_lambda_permission.allow_cloudwatch_events resource
aws_autoscaling_group.group data source
aws_caller_identity.current data source
aws_iam_policy_document.assume_role data source
aws_iam_policy_document.lambda data source
aws_lambda_layer_version.sentry data source
aws_region.current data source

Inputs

Name Description Type Default Required
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 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 Set to true if your ASG uses ARM instances in the default launch template string false no
autoscaling_group_name Name of the auto scaling group to refresh string n/a yes
cloudwatch_event_rule_name Name of the CloudWatch Event Rule string "ASGRefreshInstancesEventRule" no
cloudwatch_event_rule_schedule_expression Schedule expression for CloudWatch Event Rule string "cron(0 0 * * ? *)" no
describe_instance_refreshes_max_records Page size for boto3 when calling autoscaling:DescribeInstanceRefreshes (max is 100) number 100 no
instance_refresh_instance_warmup Instance warmup time for instance refresh number 300 no
instance_refresh_min_healthy_percentage Minimum healthy percentage for instance refresh number 90 no
instance_refresh_skip_matching Skip matching instances for instance refresh bool false no
lambda_architecture Set CPU architecture for the Lambda function. Valid values are "x86_64" and "arm64". string "x86_64" no
lambda_description Description of the Lambda function string "Keeps ASG Launch Template updated with most recent AMI read from SSM Parameter" no
lambda_name Name of the Lambda function string "ASGRefreshInstances" no
lambda_role_description Role description for the Lambda function string "" no
lambda_role_name Role name for the Lambda function string "ASGRefreshInstancesLambdaRole" no
lambda_timeout Timeout for Lambda function in seconds number 60 no
lambda_runtime Lambda Function runtime string python3.11 no
launch_template_source_version Source version for the new launch template string "$Default" no
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 List of Launch Template ARNs to allow access to list(string)
[
"*"
]
no
sentry_dsn n/a string null no
sentry_environment n/a string null no
sentry_lambda_layer_version n/a number 11 no
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 n/a

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 53.9%
  • Python 46.1%