简体   繁体   English

如何使用 Ruby 从 EC2 实例获取特定标签值

[英]How do I get a specific tag value from an EC2 instance using Ruby

Basically I want to get a specific tag value from an EC2 Instance.基本上我想从 EC2 实例中获取特定的标签值。 The EC2 instance has a releaseId tag key I want to retrieve, which is an integer. EC2 实例有一个我要检索的releaseId标记键,它是 integer。 How do I get the releaseId value from the instance.如何从实例中获取 releaseId 值。

require 'rubygems'
require 'aws-sdk'
require 'net/http'

metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'
instance_id = Net::HTTP.get( URI.parse( metadata_endpoint + 'instance-id' ) )

I have very limited Ruby knowledge and any guidance will be appreciated.我的 Ruby 知识非常有限,我们将不胜感激。 After I get the current EC2 instance_id, what do I do to get the value.获取当前 EC2 instance_id 后,我该怎么做才能获取该值。

Tag values are not accessible via instance metadata service.无法通过实例元数据服务访问标签值。 You have to use the public EC2 API DescribeTags .您必须使用公共 EC2 API DescribeTags

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Ruby in Chef标记EC2实例? - How can I tag an EC2 instance using Ruby in Chef? 使用ruby SDK,如何获得针对我的AWS EC2实例签名的SSL证书? - Using the ruby SDK, how can I get an SSL certificate signed for my AWS EC2 instance? 如何在Ruby中仅从字符串(EC2盒的控制台输出)中获取新行? - How do I get only the new lines from a string (an EC2 box' console output) in Ruby? 无法从 Amazon EC2 实例下的一台 FTP 服务器使用 Ruby 获取二进制文件 - Cannot get binaryfile using Ruby from one FTP server under Amazon EC2 instance 如何在ruby中连接到EC2 Cassandra实例 - How to connect to an EC2 cassandra instance in ruby 如何使用RUBBER EC2 ruby​​ / rails部署工具指定数据库连接参数? - How do I specify database connection parameters using the RUBBER EC2 ruby / rails deployment tool? 如何将文件从一个Rails应用程序复制到AWS EC2实例 - How do I copy a file from one rails application to aws ec2 instance 如何使用正则表达式在Ruby中获取价值标签? - How do get value tag in Ruby using regex? 使用Ruby中的SCP / SSH和Amazon EC2实例中的pem文件 - Using SCP/SSH in Ruby with a pem file in an Amazon EC2 instance 如何使用 v2 ruby​​ sdk 为 ec2 实例分配 IP 地址 - how to assign an ip address to an ec2 instance using the v2 ruby sdk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM