|
Hello everyone! I'm trying to use ministack to study terraform with AWS, and I'm facing problems with re-run to create an EC2 minstask env: docker run -p 4566:4566 nahuelnucera/ministackterraform version: Terraform v1.14.8
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v6.40.0Terraform file: terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "6.40.0"
}
}
}
# Configure the AWS Provider
provider "aws" {
region = "us-east-1"
}
resource "aws_vpc" "my_vpc" {
cidr_block = "10.0.0.0/16"
enable_dns_support = false
enable_dns_hostnames = false
enable_network_address_usage_metrics = false
tags = {
Name = "my_vpc"
Environment = "dev"
ManagedBy = "Terraform"
}
}
resource "aws_subnet" "subnet1" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "10.0.1.0/24"
tags = {
Name = "subnet1"
Environment = "dev"
ManagedBy = "Terraform"
}
}
resource "aws_internet_gateway" "gw" {
vpc_id = aws_vpc.my_vpc.id
tags = {
Name = "gw"
Environment = "dev"
ManagedBy = "Terraform"
}
}
resource "aws_route_table" "default_route_table" {
vpc_id = aws_vpc.my_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.gw.id
}
tags = {
Name = "default_route_table"
Environment = "dev"
ManagedBy = "Terraform"
}
}
resource "aws_route_table_association" "default_rta" {
subnet_id = aws_subnet.subnet1.id
route_table_id = aws_route_table.default_route_table.id
}
resource "aws_instance" "my_instance" {
vpc_security_group_ids = [aws_security_group.allow_tls.id]
subnet_id = aws_subnet.subnet1.id
associate_public_ip_address = true
#ami = data.aws_ami.ubuntu.id
ami = "ami-0123456789abcdef0"
instance_type = "t3.micro"
depends_on = [ aws_security_group.allow_tls ]
}
resource "aws_security_group" "allow_tls" {
name = "allow_tls"
description = "Allow TLS inbound traffic and all outbound traffic"
vpc_id = aws_vpc.my_vpc.id
ingress {
description = "Allow TLS inbound traffic"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
description = "Allow TLS inbound traffic"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
First time run: Plan: 7 to add, 0 to change, 0 to destroy.
aws_vpc.my_vpc: Creating...
aws_vpc.my_vpc: Creation complete after 0s [id=vpc-a04cddf50f3ccbcba]
aws_internet_gateway.gw: Creating...
aws_subnet.subnet1: Creating...
aws_security_group.allow_tls: Creating...
aws_subnet.subnet1: Creation complete after 0s [id=subnet-332202df4977ec141]
aws_internet_gateway.gw: Creation complete after 0s [id=igw-253e1773d18e0ef4b]
aws_route_table.default_route_table: Creating...
aws_route_table.default_route_table: Creation complete after 1s [id=rtb-06bb5eba9139ed2b6]
aws_route_table_association.default_rta: Creating...
aws_security_group.allow_tls: Creation complete after 1s [id=sg-000dbd6b61e0ed082]
aws_instance.my_instance: Creating...
aws_route_table_association.default_rta: Creation complete after 0s [id=rtbassoc-5af498d0c6a89bb5a]
aws_instance.my_instance: Still creating... [00m10s elapsed]
aws_instance.my_instance: Creation complete after 10s [id=i-7fdf169955ee51240]
Apply complete! Resources: 7 added, 0 changed, 0 destroyed.second time run with the same configuration: Plan: 1 to add, 4 to change, 1 to destroy.
╷
│ Error: reading EC2 Instance (i-282634ffb0b7f265b) launch template: reading EC2 Instance (i-282634ffb0b7f265b) launch template ID tag: too many results: wanted 1, got 12
│
│ with aws_instance.my_instance,
│ on main.tf line 67, in resource "aws_instance" "my_instance":
│ 67: resource "aws_instance" "my_instance" {
│
╵
Any ideas what I could be doing wrong? |
Answered by
Nahuel990
Apr 16, 2026
Replies: 2 comments
|
Hi @Nahuel990, now it's working fine. Plan: 2 to add, 0 to change, 2 to destroy.
aws_instance.my_instance: Destroying... [id=i-6117d59305379fd7a]
aws_instance.my_instance: Still destroying... [id=i-6117d59305379fd7a, 00m10s elapsed]
aws_instance.my_instance: Destruction complete after 10s
aws_security_group.allow_tls: Destroying... [id=sg-8a43671212e303636]
aws_security_group.allow_tls: Destruction complete after 0s
aws_security_group.allow_tls: Creating...
aws_security_group.allow_tls: Creation complete after 0s [id=sg-7293114958fd0fdf1]
aws_instance.my_instance: Creating...
aws_instance.my_instance: Still creating... [00m10s elapsed]
aws_instance.my_instance: Creation complete after 11s [id=i-3b8e0a866b7745f06]
Apply complete! Resources: 2 added, 0 changed, 2 destroyed.Thanks a lot for the quick answer and the fix. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @doug2901 we fixed that this morning (it was an issue with Ministack) could you try with latest version?