Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EC2 detach_network_interface should return error when removing the primary network interface #7678

Closed
yairsappir opened this issue May 7, 2024 · 1 comment · Fixed by #7697

Comments

@yairsappir
Copy link

yairsappir commented May 7, 2024

Hi,

It seems that when calling detach_network_interface on the primary network interface (at index 0), AWS throws this error:
botocore.exceptions.ClientError: An error occurred (OperationNotPermitted) when calling the DetachNetworkInterface operation: The network interface at device index 0 and networkCard index 0 cannot be detached.

However, moto does allow it which results in an exception being thrown when calling describe_instances afterwards:

    @property
    def private_ip(self) -> Optional[str]:
>       return self.nics[0].private_ip_address
E       KeyError: 0

..\..\..\..\..\AppData\Local\Programs\Python\Python312\Lib\site-packages\moto\ec2\models\instances.py:240: KeyError
@rafcio19
Copy link
Contributor

rafcio19 commented May 8, 2024

@bblommers I can take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants