Skip to content

Fix Compute.describe_instance_status parser #735

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

Merged
merged 2 commits into from
Apr 21, 2025
Merged

Conversation

kitherill
Copy link
Contributor

Resolves #734

Test script

Gemfile

source 'https://rubygems.org'

gem 'fog-aws', git: 'https://github.com/fog/fog-aws.git'

describe_instance_status.rb

require 'fog/aws'

# Replace this with a real EC2 instance ID
INSTANCE_ID = 'i-*****' # provide instance ID

# Create a connection to EC2 using fog
compute = Fog::AWS::Compute.new(
  aws_access_key_id:     '***', # provide access key ID
  aws_secret_access_key: '***', # provide secret
  region:                'us-east-1' # Change region if needed
)

begin
  response = compute.describe_instance_status('InstanceId' => [INSTANCE_ID])
  statuses = response.body['instanceStatusSet']

  if statuses.empty?
    puts "No status found for instance #{INSTANCE_ID}"
  else
    status = statuses.first
    puts "Instance #{INSTANCE_ID} status:"
    puts "  Instance State: #{status['instanceState']['name']}"
    puts "  System Status:  #{status['systemStatus']['status']}"
    puts "  Instance Status: #{status['instanceStatus']['status']}"
  end
rescue => e
  puts "Error describing instance status: #{e.message}"
end

Verification

Before the fix

Screenshot 2025-04-18 at 12 55 50

After the fix

Screenshot 2025-04-18 at 12 55 10

Copy link
Member

@geemus geemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@geemus
Copy link
Member

geemus commented Apr 18, 2025

Thanks for the fix, I'll plan to release early next week (just in case, as I don't expect to be online as much over the weekend).

@kitherill
Copy link
Contributor Author

Thanks for the fix, I'll plan to release early next week (just in case, as I don't expect to be online as much over the weekend).

Awesome, in this case we can wait and avoid patching locally. Thanks!

@geemus geemus merged commit 6cf9350 into fog:master Apr 21, 2025
3 checks passed
@geemus
Copy link
Member

geemus commented Apr 21, 2025

Released in v3.31.0. Thanks!

kitherill added a commit to engineyard/fog-aws that referenced this pull request Apr 21, 2025
* Fix Compute.describe_instance_status parser

* Update describe_instance_status.rb

(cherry picked from commit 6cf9350)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compute.describe_instance_status() fails
2 participants