aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 77 forks source link

Get-EC2instancestatus not returning an object despite Get-EC2Instance returning one #235

Closed rileysea closed 2 years ago

rileysea commented 2 years ago

Description

Using Get-EC2Instancestatus without a parameter and with the InstanceId parameter does not return any objects in the eu-west-1 region for me.

However, using Get-EC2Instance does.

Reproduction Steps

$instances = (get-ec2instance -Region eu-west-1).Instances
$instances.count = 4
$instances | % {Get-EC2InstanceStatus -InstanceID $_.InstanceId -Region 'eu-west-1'}

I also noticed you can't pipe the two functions together

(get-ec2instance -Region eu-west-1).Instances | Get-EC2Instancestatus -InstanceId $_.InstanceId

Logs

Environment

Resolution


This is a :bug: bug-report

ashishdhingra commented 2 years ago

Hi @rileysea,

Good afternoon.

Thanks for reporting the issue. On looking further, here are my findings:

Based on above reference from service API pages, only the running instances would be returned when you use Get-EC2InstanceStatus CmdLet. You could change the default behavior by using -IncludeAllInstance parameter with value $true to have it return status of all instances. I'm assuming this is true even if you specify -InstanceId parameter.

Kindly note that the above PowerShell CmdLets are autogenerated and the behavior is controlled by the EC2 service API. The behavior could not be changed by service team since it would be a breaking change for existing customers.

Please review the results of your call to Get-EC2Instance -Region eu-west-1 to see if it includes other instances (apart from running). If yes, please try the following:

Thanks, Ashish

rileysea commented 2 years ago

That seemed to work - thanks Ashish

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.