I have my terraform configured for AWS. I have automated 2 EC2 Instance and 2 ECS Optimized Instance.
I am getting **Error launching source instance: timeout while waiting for the state to become 'success' (timeout: 15s)** for all the 4 Instances while I do terraform apply.
I found on some blog that it may be because of inconsistent AMI or misspelled AMI id.
Hence, I have fixed the typo in my AMI id and able to launch 2 instances. However, still, I got the timeout error for the other two instances.
I am using terraform version: 0.9.6 My TF code for ec2 creation:
resource "aws_instance" "node1" {
# ECS-optimized AMI for us-west-2
ami = "ami-62d35c02"
instance_type = "t2.medium"
availability_zone = "us-west-2a"
security_groups = [
"${aws_security_group.sg.name}"
]
key_name = "key"
tags {
Name = "Node Server 1"
}
user_data = <<EOF
#!/bin/bash
echo ECS_CLUSTER=uat >> /etc/ecs/ecs.config
EOF
iam_instance_profile = "${aws_iam_instance_profile.ecs.name}"
}
resource "aws_instance" "node2" {
# ECS-optimized AMI for us-west-2
ami = "ami-62d35c02"
instance_type = "t2.medium"
availability_zone = "us-west-2b"
security_groups = [
"${aws_security_group.sg.name}"
]
key_name = "key"
tags {
Name = "Node Server 2"
}
user_data = <<EOF
#!/bin/bash
echo ECS_CLUSTER=uat >> /etc/ecs/ecs.config
EOF
iam_instance_profile = "${aws_iam_instance_profile.ecs.name}"
}
resource "aws_instance" "mongo" {
ami = "ami-63ad4b1b"
instance_type = "t2.medium"
availability_zone = "us-west-2c"
security_groups = [
"${aws_security_group.sg.name}"
]
key_name = "key"
tags {
Name = "MongoDB Server"
}
}
resource "aws_instance" "mysql" {
ami = "ami-22ac4a5a"
instance_type = "t2.medium"
availability_zone = "us-west-2c"
security_groups = [
"${aws_security_group.sg.name}"
]
key_name = "key"
tags {
Name = "MySQL Server"
}
}
Can someone please help me.
Thanks in advance.
It is possible to identify the underlying issue using the Terraform Debug Logs. When I had this error, in my case the issue was that AWS did not have enough capacity for the instance type I was choosing in the availability zone I configured.
A good approach to debug this error would be the following:
TF_LOG environment variable to enable Terraform Debug Logs. This can be done with the following command on Linux or Mac:export TF_LOG=DEBUG
terraform apply command.yes and hit Enter if the plan is okay for you.[DEBUG] entries a few lines above it to identify the underlying issue. To give an example, in my case I found the following:[DEBUG] plugin.terraform-provider-aws_v1.58.0_x4:
<Response>
<Errors>
<Error>
<Code>InsufficientInstanceCapacity</Code>
<Message>We currently do not have sufficient t3.medium capacity in the Availability Zone you requested (us-west-1a). Our system will be working on provisioning additional capacity. You can currently get t3.medium capacity by not specifying an
Availability Zone in your request or choosing us-west-1b.</Message>
</Error>
</Errors>
<RequestID>...</RequestID>
</Response>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With