Skip to content

bug: EC2 DescribeInstances without any parameters does not work #6076

@trivelt

Description

@trivelt

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I'm trying to list EC2 instances without InstanceIds parameter (which is not mandatory) and I use for example:

aws --endpoint-url=http://localhost:4566 ec2 describe-instances --region=eu-west-2

Localstack returns the following error:

An error occurred (InvalidSubnetID.NotFound) when calling the DescribeInstances operation: The subnet ID 'subnet-f4a71320' does not exist

It happens after terminating the instance and deleting a subnet used by that instance.

Expected Behavior

The result should be similar to the output produced by the real AWS, which lists all EC2 instances in a specified region (using filters if specified), even if some subnets were deleted.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

  1. Initially describe-instances works as expected
aws --endpoint-url=http://localhost:4566 ec2 describe-instances --region=eu-west-2
  1. Create new VPC
aws --endpoint-url=http://localhost:4566 ec2 create-vpc --cidr-block "10.1.0.0/16"
# Created VPC with vpc-id = vpc-dea45193
  1. Create new subnet
aws --endpoint-url=http://localhost:4566 ec2 create-subnet --vpc-id vpc-dea45193 --cidr-block "10.1.1.0/27" --tag-specifications "ResourceType=subnet,Tags=[{Key=Name,Value=my-ipv4-subnet}]"
# Created subnet with subnet-id = 9303cf84
  1. Create new instance using the subnet created above
aws --endpoint-url=http://localhost:4566 ec2 run-instances --image-id ami-0abcdef1234567890  --instance-type t2.micro --key-name MyKeyPair --subnet-id subnet-9303cf84
# Created instance with instance-id = i-a74fe925c78dbb733
  1. Terminate instance
aws --endpoint-url=http://localhost:4566 ec2 terminate-instances --instance-ids i-a74fe925c78dbb733
  1. Delete subnet
aws --endpoint-url=http://localhost:4566 ec2 delete-subnet --subnet-id subnet-9303cf84
  1. Now describe-instance raises an error:
aws --endpoint-url=http://localhost:4566 ec2 describe-instances --region=eu-west-2
> An error occurred (InvalidSubnetID.NotFound) when calling the DescribeInstances operation: The subnet ID 'subnet-9303cf84' does not exist

How are you starting localstack

docker compose up

docker-compose.yml file contains:

version: '3.3'
services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_container}"
    image: localstack/localstack:0.14.2
    network_mode: bridge
    ports:
      - "127.0.0.1:4566:4566"
      - "127.0.0.1:4571:4571"
    environment:
      - SERVICES=s3,sts,iam,ec2,cloudformation
      - DATA_DIR=${DATA_DIR- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - HOST_TMP_FOLDER=${TMPDIR:-/tmp/}localstack
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${TMPDIR:-/tmp}/localstack:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

Client commands

aws --endpoint-url=http://localhost:4566 ec2 describe-instances --region=eu-west-2

Environment

- OS: macOS 12.0
- LocalStack: 0.14.2

Anything else?

No response

Metadata

Metadata

Labels

aws:ec2Amazon Elastic Compute Cloudstatus: resolved/fixedResolved with a fix or an implementationtype: bugBug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions