Description
I copied and pasted the book code into three files and ran the following commands and the apply failed. Error at the end was about the auto scaling launch configuration. Googling it looks like this is deprecated. What should I use instead?
PS C:\Users\cliff\Desktop\TerraformUpAndRunning\Chp2> terraform init
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 4.0"...
- Installing hashicorp/aws v4.67.0...
- Installed hashicorp/aws v4.67.0 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
PS C:\Users\cliff\Desktop\TerraformUpAndRunning\Chp2> terraform apply
data.aws_vpc.default: Reading...
data.aws_vpc.default: Read complete after 1s [id=vpc-0118d7f9580308e88]
data.aws_subnets.default: Reading...
data.aws_subnets.default: Read complete after 0s [id=us-east-2]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
- create
Terraform will perform the following actions:
aws_autoscaling_group.example will be created
- resource "aws_autoscaling_group" "example" {
-
arn = (known after apply)
-
availability_zones = (known after apply)
-
default_cooldown = (known after apply)
-
desired_capacity = (known after apply)
-
force_delete = false
-
force_delete_warm_pool = false
-
health_check_grace_period = 300
-
health_check_type = "ELB"
-
id = (known after apply)
-
launch_configuration = (known after apply)
-
max_size = 10
-
metrics_granularity = "1Minute"
-
min_size = 2
-
name = (known after apply)
-
name_prefix = (known after apply)
-
predicted_capacity = (known after apply)
-
protect_from_scale_in = false
-
service_linked_role_arn = (known after apply)
-
target_group_arns = (known after apply)
-
vpc_zone_identifier = [
- "subnet-06c7bc763b4a2960a",
- "subnet-098cf693702d30bc5",
- "subnet-0e5c7a8e7cb7d9225",
]
-
wait_for_capacity_timeout = "10m"
-
warm_pool_size = (known after apply)
-
tag {
- key = "Name"
- propagate_at_launch = true
- value = "terraform-asg-example"
}
}
-
aws_launch_configuration.example will be created
- resource "aws_launch_configuration" "example" {
-
arn = (known after apply)
-
associate_public_ip_address = (known after apply)
-
ebs_optimized = (known after apply)
-
enable_monitoring = true
-
id = (known after apply)
-
image_id = "ami-0fb653ca2d3203ac1"
-
instance_type = "t2.micro"
-
key_name = (known after apply)
-
name = (known after apply)
-
name_prefix = (known after apply)
-
security_groups = (known after apply)
-
user_data = "67e34b406ab639a606a64fe06965b26bf8036a9c"
-
ebs_block_device (known after apply)
-
metadata_options (known after apply)
-
root_block_device (known after apply)
}
-
aws_lb.example will be created
- resource "aws_lb" "example" {
-
arn = (known after apply)
-
arn_suffix = (known after apply)
-
desync_mitigation_mode = "defensive"
-
dns_name = (known after apply)
-
drop_invalid_header_fields = false
-
enable_deletion_protection = false
-
enable_http2 = true
-
enable_tls_version_and_cipher_suite_headers = false
-
enable_waf_fail_open = false
-
enable_xff_client_port = false
-
id = (known after apply)
-
idle_timeout = 60
-
internal = (known after apply)
-
ip_address_type = (known after apply)
-
load_balancer_type = "application"
-
name = "terraform-asg-example"
-
preserve_host_header = false
-
security_groups = (known after apply)
-
subnets = [
- "subnet-06c7bc763b4a2960a",
- "subnet-098cf693702d30bc5",
- "subnet-0e5c7a8e7cb7d9225",
]
-
tags_all = (known after apply)
-
vpc_id = (known after apply)
-
xff_header_processing_mode = "append"
-
zone_id = (known after apply)
-
subnet_mapping (known after apply)
}
-
aws_lb_listener.http will be created
- resource "aws_lb_listener" "http" {
-
arn = (known after apply)
-
id = (known after apply)
-
load_balancer_arn = (known after apply)
-
port = 80
-
protocol = "HTTP"
-
ssl_policy = (known after apply)
-
tags_all = (known after apply)
-
default_action {
-
order = (known after apply)
-
type = "fixed-response"
-
fixed_response {
- content_type = "text/plain"
- message_body = "404: page not found"
- status_code = "404"
}
}
}
-
-
aws_lb_listener_rule.asg will be created
- resource "aws_lb_listener_rule" "asg" {
-
arn = (known after apply)
-
id = (known after apply)
-
listener_arn = (known after apply)
-
priority = 100
-
tags_all = (known after apply)
-
action {
- order = (known after apply)
- target_group_arn = (known after apply)
- type = "forward"
}
-
condition {
- path_pattern {
- values = [
- "*",
]
}
}
}
- "*",
- values = [
- path_pattern {
-
aws_lb_target_group.asg will be created
- resource "aws_lb_target_group" "asg" {
-
arn = (known after apply)
-
arn_suffix = (known after apply)
-
connection_termination = false
-
deregistration_delay = "300"
-
id = (known after apply)
-
ip_address_type = (known after apply)
-
lambda_multi_value_headers_enabled = false
-
load_balancing_algorithm_type = (known after apply)
-
load_balancing_cross_zone_enabled = (known after apply)
-
name = "terraform-asg-example"
-
port = 8080
-
preserve_client_ip = (known after apply)
-
protocol = "HTTP"
-
protocol_version = (known after apply)
-
proxy_protocol_v2 = false
-
slow_start = 0
-
tags_all = (known after apply)
-
target_type = "instance"
-
vpc_id = "vpc-0118d7f9580308e88"
-
health_check {
- enabled = true
- healthy_threshold = 2
- interval = 15
- matcher = "200"
- path = "/"
- port = "traffic-port"
- protocol = "HTTP"
- timeout = 3
- unhealthy_threshold = 2
}
-
stickiness (known after apply)
-
target_failover (known after apply)
}
-
aws_security_group.alb will be created
- resource "aws_security_group" "alb" {
- arn = (known after apply)
- description = "Managed by Terraform"
- egress = [
- {
- cidr_blocks = [
- "0.0.0.0/0",
]
- "0.0.0.0/0",
- from_port = 0
- ipv6_cidr_blocks = []
- prefix_list_ids = []
- protocol = "-1"
- security_groups = []
- self = false
- to_port = 0
(1 unchanged attribute hidden)
] - cidr_blocks = [
- {
- id = (known after apply)
- ingress = [
- {
- cidr_blocks = [
- "0.0.0.0/0",
]
- "0.0.0.0/0",
- from_port = 80
- ipv6_cidr_blocks = []
- prefix_list_ids = []
- protocol = "tcp"
- security_groups = []
- self = false
- to_port = 80
(1 unchanged attribute hidden)
] - cidr_blocks = [
- {
- name = "terraform-example-alb"
- name_prefix = (known after apply)
- owner_id = (known after apply)
- revoke_rules_on_delete = false
- tags_all = (known after apply)
- vpc_id = (known after apply)
}
aws_security_group.instance will be created
- resource "aws_security_group" "instance" {
- arn = (known after apply)
- description = "Managed by Terraform"
- egress = (known after apply)
- id = (known after apply)
- ingress = [
- {
- cidr_blocks = [
- "0.0.0.0/0",
]
- "0.0.0.0/0",
- from_port = 8080
- ipv6_cidr_blocks = []
- prefix_list_ids = []
- protocol = "tcp"
- security_groups = []
- self = false
- to_port = 8080
(1 unchanged attribute hidden)
] - cidr_blocks = [
- {
- name = "terraform-example-instance"
- name_prefix = (known after apply)
- owner_id = (known after apply)
- revoke_rules_on_delete = false
- tags_all = (known after apply)
- vpc_id = (known after apply)
}
Plan: 8 to add, 0 to change, 0 to destroy.
Changes to Outputs:
- alb_dns_name = (known after apply)
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_lb_target_group.asg: Creating...
aws_security_group.instance: Creating...
aws_security_group.alb: Creating...
aws_lb_target_group.asg: Creation complete after 1s [id=arn:aws:elasticloadbalancing:us-east-2:043309363086:targetgroup/terraform-asg-example/c7b53e0db5b9c21a]
aws_security_group.instance: Creation complete after 2s [id=sg-06de222277c569059]
aws_launch_configuration.example: Creating...
aws_security_group.alb: Creation complete after 3s [id=sg-043099eacdec032e5]
aws_lb.example: Creating...
aws_lb.example: Still creating... [10s elapsed]
aws_lb.example: Still creating... [20s elapsed]
aws_lb.example: Still creating... [30s elapsed]
aws_lb.example: Still creating... [40s elapsed]
aws_lb.example: Still creating... [50s elapsed]
aws_lb.example: Still creating... [1m0s elapsed]
aws_lb.example: Still creating... [1m10s elapsed]
aws_lb.example: Still creating... [1m20s elapsed]
aws_lb.example: Still creating... [1m30s elapsed]
aws_lb.example: Still creating... [1m40s elapsed]
aws_lb.example: Still creating... [1m50s elapsed]
aws_lb.example: Still creating... [2m0s elapsed]
aws_lb.example: Still creating... [2m10s elapsed]
aws_lb.example: Still creating... [2m20s elapsed]
aws_lb.example: Still creating... [2m30s elapsed]
aws_lb.example: Still creating... [2m40s elapsed]
aws_lb.example: Still creating... [2m50s elapsed]
aws_lb.example: Creation complete after 2m52s [id=arn:aws:elasticloadbalancing:us-east-2:043309363086:loadbalancer/app/terraform-asg-example/d1a655f2186fdd51]
aws_lb_listener.http: Creating...
aws_lb_listener.http: Creation complete after 0s [id=arn:aws:elasticloadbalancing:us-east-2:043309363086:listener/app/terraform-asg-example/d1a655f2186fdd51/7b44a3efd8898dbc]
aws_lb_listener_rule.asg: Creating...
aws_lb_listener_rule.asg: Creation complete after 0s [id=arn:aws:elasticloadbalancing:us-east-2:043309363086:listener-rule/app/terraform-asg-example/d1a655f2186fdd51/7b44a3efd8898dbc/632188ec1b6c47bb]
╷
│ Error: creating Auto Scaling Launch Configuration (terraform-20241113002735313500000001): UnsupportedOperation: The Launch Configuration creation operation is not available in your account. Use launch templates to create configura
tion templates for your Auto Scaling groups.
│ status code: 400, request id: 5ad8d31c-9281-49b1-857e-f979a388e989
│
│ with aws_launch_configuration.example,
│ on main.tf line 16, in resource "aws_launch_configuration" "example":
│ 16: resource "aws_launch_configuration" "example" {
│
╵