diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4395e67..15d3d3e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
- rev: v1.79.1
+ rev: v1.83.4
hooks:
- id: terraform_fmt
- id: terraform_validate
@@ -23,7 +23,7 @@ repos:
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
+ rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
diff --git a/README.md b/README.md
index c959556..3cf9d9f 100644
--- a/README.md
+++ b/README.md
@@ -202,7 +202,7 @@ Note: the default behavior of the module is to create an autoscaling group and l
- Create the autoscaling policies:
-```
+```hcl
scaling_policies = {
my-policy = {
policy_type = "TargetTrackingScaling"
@@ -226,14 +226,14 @@ Note: the default behavior of the module is to create an autoscaling group and l
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.13.1 |
-| [aws](#requirement\_aws) | >= 4.57 |
+| [terraform](#requirement\_terraform) | >= 1.0 |
+| [aws](#requirement\_aws) | >= 5.0 |
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | >= 4.57 |
+| [aws](#provider\_aws) | >= 5.0 |
## Modules
@@ -251,7 +251,6 @@ No modules.
| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_launch_template.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/launch_template) | resource |
-| [aws_default_tags.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/default_tags) | data source |
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
@@ -309,8 +308,8 @@ No modules.
| [instance\_type](#input\_instance\_type) | The type of the instance. If present then `instance_requirements` cannot be present | `string` | `null` | no |
| [kernel\_id](#input\_kernel\_id) | The kernel ID | `string` | `null` | no |
| [key\_name](#input\_key\_name) | The key name that should be used for the instance | `string` | `null` | no |
-| [launch\_template](#input\_launch\_template) | Name of an existing launch template to be used (created outside of this module) | `string` | `null` | no |
| [launch\_template\_description](#input\_launch\_template\_description) | Description of the launch template | `string` | `null` | no |
+| [launch\_template\_id](#input\_launch\_template\_id) | ID of an existing launch template to be used (created outside of this module) | `string` | `null` | no |
| [launch\_template\_name](#input\_launch\_template\_name) | Name of launch template to be created | `string` | `""` | no |
| [launch\_template\_use\_name\_prefix](#input\_launch\_template\_use\_name\_prefix) | Determines whether to use `launch_template_name` as is or create a unique name beginning with the `launch_template_name` as the prefix | `bool` | `true` | no |
| [launch\_template\_version](#input\_launch\_template\_version) | Launch template version. Can be version number, `$Latest`, or `$Default` | `string` | `null` | no |
diff --git a/examples/complete/README.md b/examples/complete/README.md
index 7f80502..e69f257 100644
--- a/examples/complete/README.md
+++ b/examples/complete/README.md
@@ -29,22 +29,22 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.13.1 |
-| [aws](#requirement\_aws) | >= 4.22 |
+| [terraform](#requirement\_terraform) | >= 1.0 |
+| [aws](#requirement\_aws) | >= 5.0 |
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | >= 4.22 |
+| [aws](#provider\_aws) | >= 5.0 |
## Modules
| Name | Source | Version |
|------|--------|---------|
-| [alb](#module\_alb) | terraform-aws-modules/alb/aws | ~> 6.0 |
-| [alb\_http\_sg](#module\_alb\_http\_sg) | terraform-aws-modules/security-group/aws//modules/http-80 | ~> 4.0 |
-| [asg\_sg](#module\_asg\_sg) | terraform-aws-modules/security-group/aws | ~> 4.0 |
+| [alb](#module\_alb) | terraform-aws-modules/alb/aws | ~> 8.0 |
+| [alb\_http\_sg](#module\_alb\_http\_sg) | terraform-aws-modules/security-group/aws//modules/http-80 | ~> 5.0 |
+| [asg\_sg](#module\_asg\_sg) | terraform-aws-modules/security-group/aws | ~> 5.0 |
| [complete](#module\_complete) | ../../ | n/a |
| [default](#module\_default) | ../../ | n/a |
| [disabled](#module\_disabled) | ../../ | n/a |
@@ -54,8 +54,9 @@ Note that this example may create resources which cost money. Run `terraform des
| [instance\_requirements\_accelerators](#module\_instance\_requirements\_accelerators) | ../../ | n/a |
| [launch\_template\_only](#module\_launch\_template\_only) | ../../ | n/a |
| [mixed\_instance](#module\_mixed\_instance) | ../../ | n/a |
+| [step\_scaling\_alarm](#module\_step\_scaling\_alarm) | terraform-aws-modules/cloudwatch/aws//modules/metric-alarm | ~> 4.3 |
| [target\_tracking\_customized\_metrics](#module\_target\_tracking\_customized\_metrics) | ../../ | n/a |
-| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |
+| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
| [warm\_pool](#module\_warm\_pool) | ../../ | n/a |
## Resources
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 918e7fd..c179c5c 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -271,6 +271,23 @@ module "complete" {
target_value = 800
}
}
+ scale-out = {
+ name = "scale-out"
+ adjustment_type = "ExactCapacity"
+ policy_type = "StepScaling"
+ estimated_instance_warmup = 120
+ step_adjustment = [
+ {
+ scaling_adjustment = 1
+ metric_interval_lower_bound = 0
+ metric_interval_upper_bound = 10
+ },
+ {
+ scaling_adjustment = 2
+ metric_interval_lower_bound = 10
+ }
+ ]
+ }
}
}
@@ -713,7 +730,7 @@ module "external" {
# Launch template
create_launch_template = false
- launch_template = aws_launch_template.this.name
+ launch_template_id = aws_launch_template.this.id
tags = local.tags
}
@@ -780,7 +797,7 @@ module "default" {
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
- version = "~> 3.0"
+ version = "~> 5.0"
name = local.name
cidr = local.vpc_cidr
@@ -789,15 +806,12 @@ module "vpc" {
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)]
- enable_dns_hostnames = true
- enable_dns_support = true
-
tags = local.tags
}
module "asg_sg" {
source = "terraform-aws-modules/security-group/aws"
- version = "~> 4.0"
+ version = "~> 5.0"
name = local.name
description = "A security group"
@@ -867,7 +881,7 @@ resource "aws_iam_role" "ssm" {
module "alb_http_sg" {
source = "terraform-aws-modules/security-group/aws//modules/http-80"
- version = "~> 4.0"
+ version = "~> 5.0"
name = "${local.name}-alb-http"
vpc_id = module.vpc.vpc_id
@@ -880,7 +894,7 @@ module "alb_http_sg" {
module "alb" {
source = "terraform-aws-modules/alb/aws"
- version = "~> 6.0"
+ version = "~> 8.0"
name = local.name
@@ -916,21 +930,26 @@ resource "aws_ec2_capacity_reservation" "targeted" {
instance_match_criteria = "targeted"
}
-# resource "aws_licensemanager_license_configuration" "test" {
-# license_count = 1
-# license_count_hard_limit = true
-# license_counting_type = "Socket"
-# name = "test-license"
-
-# license_rules = [
-# "#allowedTenancy=EC2-DedicatedHost",
-# "#maximumSockets=2",
-# "#minimumSockets=2",
-# ]
-# }
-
resource "aws_sqs_queue" "this" {
name = local.name
tags = local.tags
}
+
+module "step_scaling_alarm" {
+ source = "terraform-aws-modules/cloudwatch/aws//modules/metric-alarm"
+ version = "~> 4.3"
+
+ alarm_name = "${local.name}-step-scaling"
+ alarm_description = "Step Scaling Alarm Example"
+ comparison_operator = "GreaterThanThreshold"
+ evaluation_periods = 1
+ threshold = 40
+ period = 300
+
+ namespace = "AWS/EC2"
+ metric_name = "CPUUtilization"
+ statistic = "Average"
+
+ alarm_actions = [module.complete.autoscaling_policy_arns["scale-out"]]
+}
diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf
index 947f98d..ddfcb0e 100644
--- a/examples/complete/versions.tf
+++ b/examples/complete/versions.tf
@@ -1,10 +1,10 @@
terraform {
- required_version = ">= 0.13.1"
+ required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 4.22"
+ version = ">= 5.0"
}
}
}
diff --git a/main.tf b/main.tf
index b6ec41a..f46ee09 100644
--- a/main.tf
+++ b/main.tf
@@ -1,15 +1,13 @@
data "aws_partition" "current" {}
-data "aws_default_tags" "current" {}
locals {
create = var.create && var.putin_khuylo
launch_template_name = coalesce(var.launch_template_name, var.name)
- launch_template = var.create_launch_template ? aws_launch_template.this[0].name : var.launch_template
+ launch_template_id = var.create_launch_template ? aws_launch_template.this[0].id : var.launch_template_id
launch_template_version = var.create_launch_template && var.launch_template_version == null ? aws_launch_template.this[0].latest_version : var.launch_template_version
asg_tags = merge(
- data.aws_default_tags.current.tags,
var.tags,
{ "Name" = coalesce(var.instance_name, var.name) },
var.autoscaling_group_tags,
@@ -354,7 +352,7 @@ resource "aws_autoscaling_group" "this" {
for_each = var.use_mixed_instances_policy ? [] : [1]
content {
- name = local.launch_template
+ id = local.launch_template_id
version = local.launch_template_version
}
}
@@ -438,8 +436,8 @@ resource "aws_autoscaling_group" "this" {
launch_template {
launch_template_specification {
- launch_template_name = local.launch_template
- version = local.launch_template_version
+ launch_template_id = local.launch_template_id
+ version = local.launch_template_version
}
dynamic "override" {
@@ -618,7 +616,7 @@ resource "aws_autoscaling_group" "idc" {
for_each = var.use_mixed_instances_policy ? [] : [1]
content {
- name = local.launch_template
+ id = local.launch_template_id
version = local.launch_template_version
}
}
@@ -702,8 +700,8 @@ resource "aws_autoscaling_group" "idc" {
launch_template {
launch_template_specification {
- launch_template_name = local.launch_template
- version = local.launch_template_version
+ launch_template_id = local.launch_template_id
+ version = local.launch_template_version
}
dynamic "override" {
@@ -910,7 +908,7 @@ resource "aws_autoscaling_policy" "this" {
scaling_adjustment = try(each.value.scaling_adjustment, null)
dynamic "step_adjustment" {
- for_each = try([each.value.step_adjustment], [])
+ for_each = try(each.value.step_adjustment, [])
content {
scaling_adjustment = step_adjustment.value.scaling_adjustment
metric_interval_lower_bound = try(step_adjustment.value.metric_interval_lower_bound, null)
diff --git a/variables.tf b/variables.tf
index db96ffd..eda0d9c 100644
--- a/variables.tf
+++ b/variables.tf
@@ -31,8 +31,8 @@ variable "instance_name" {
default = ""
}
-variable "launch_template" {
- description = "Name of an existing launch template to be used (created outside of this module)"
+variable "launch_template_id" {
+ description = "ID of an existing launch template to be used (created outside of this module)"
type = string
default = null
}
diff --git a/versions.tf b/versions.tf
index b44179c..ddfcb0e 100644
--- a/versions.tf
+++ b/versions.tf
@@ -1,10 +1,10 @@
terraform {
- required_version = ">= 0.13.1"
+ required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 4.57"
+ version = ">= 5.0"
}
}
}