Open ic32k opened 1 month ago
Change this:
resource "aws_launch_configuration" "ecs_launch_config" {
image_id = data.aws_ami.ecs_optimized_ami.id
iam_instance_profile = aws_iam_instance_profile.ecs-instance-profile.name
security_groups = [aws_security_group.ecs_sg.id]
user_data = data.template_file.user_data.rendered
instance_type = "t2.micro"
}
resource "aws_autoscaling_group" "ecs_asg" {
name = "ECS-lab-asg"
vpc_zone_identifier = [aws_subnet.lab-subnet-public-1.id]
launch_configuration = aws_launch_configuration.ecs_launch_config.name
desired_capacity = 1
min_size = 0
max_size = 1
}
For this:
resource "aws_launch_template" "ecs_launch_template" {
name_prefix = "ecs-lab-launch-template-"
image_id = data.aws_ami.ecs_optimized_ami.id
instance_type = "t2.micro"
iam_instance_profile {
name = aws_iam_instance_profile.ecs-instance-profile.name
}
vpc_security_group_ids = [aws_security_group.ecs_sg.id]
# Encode the user_data in base64
user_data = base64encode(data.template_file.user_data.rendered)
}
resource "aws_autoscaling_group" "ecs_asg" {
name = "ECS-lab-asg"
vpc_zone_identifier = [aws_subnet.lab-subnet-public-1.id]
desired_capacity = 1
min_size = 0
max_size = 1
# Reference the launch template instead of the launch configuration
launch_template {
id = aws_launch_template.ecs_launch_template.id
version = "$Latest"
}
}
Hello,
Yesterday installed AWSGoat module1 without issues, but today I wanted to run the module2 and this error is shown at Terraform run:
aws_ecs_service.worker: Creation complete after 1s [id=arn:aws:ecs:us-east-1:318030154911:service/ecs-lab-cluster/ecs_service_worker] ╷ │ Error: Error creating launch configuration: UnsupportedOperation: The Launch Configuration creation operation is not available in your account. Use launch templates to create configuration templates for your Auto Scaling groups. │ status code: 400, request id: 2e6cb191-b4b8-48a0-b7f8-46be0044fa81 │ │ with aws_launch_configuration.ecs_launch_config, │ on main.tf line 351, in resource "aws_launch_configuration" "ecs_launch_config": │ 351: resource "aws_launch_configuration" "ecs_launch_config" { │ ╵ Error: Process completed with exit code 1.