首页 \ 问答 \ 如何在启动时通过AWS CLI获取公共IP(How to get Public IP via AWS CLI while launching)

如何在启动时通过AWS CLI获取公共IP(How to get Public IP via AWS CLI while launching)

我的AWS命令是:

> aws ec2 run-instances --image-id ami-346b2354 --count 1 --instance-type c4.large --key-name my-cali-key --security-group-ids sg-a168c7c4

当我触发它时,它返回的JSON数据只有私有IP地址而不是公共IP地址。

 ................ DATA  OMITTED................... 

                "Groups": [
                    {
                        "GroupName": "launch-wizard-1", 
                        "GroupId": "sg-a168c7c4"
                    }
                ], 
                "SubnetId": "subnet-cb2524ae", 
                "OwnerId": "012710546082", 
                "PrivateIpAddress": "172.31.17.252"
            }

 ..................... DATA OMITTED ....................

(图像)使用Public IP浏览器外观相同的实例

但是,当我在浏览器中看到时,我立即注意到自动关联的公共IP地址。 如何获取已启动实例的公共IP? 请不要对弹性IP及其与实例的关联感到困惑。 我知道将弹性IP联系起来,但这里的需求是不同的。


My AWS Command is:

> aws ec2 run-instances --image-id ami-346b2354 --count 1 --instance-type c4.large --key-name my-cali-key --security-group-ids sg-a168c7c4

When I trigger this, the JSON data that it returns has only the Private IP address and NOT the Public IP address.

 ................ DATA  OMITTED................... 

                "Groups": [
                    {
                        "GroupName": "launch-wizard-1", 
                        "GroupId": "sg-a168c7c4"
                    }
                ], 
                "SubnetId": "subnet-cb2524ae", 
                "OwnerId": "012710546082", 
                "PrivateIpAddress": "172.31.17.252"
            }

 ..................... DATA OMITTED ....................

(Image) Browser look of the same instance with Public IP

However when I see in the browser I immediately notice a Public IP address being associated automatically. How Can I fetch the public IP of launched instances? Kindly do not get confused with elastic-IP and its association with instances. I know to associate an elastic-IP but the need here is different.


原文:https://stackoverflow.com/questions/37267678
更新时间:2022-01-01 06:01

最满意答案

根据我的经验,Moodle并不是将您自己的代码移植到最简单或最透明的系统。 单个实体具有许多不同的表条目。 例如,课程将出现在mdl_lessons,mdl_course_modules,mdl_grade项目和其他项目中。 我建议尽可能多地使用Moodle自己的API。 如果你不能这样做,你可以尝试通过标准接口添加课程进行逆向工程,然后检查SQL日志以查看它所创建的表条目。

关于modinfo的令人眼花缭乱的混乱, moodle论坛上的这篇文章说它是自动生成的。 这篇文章解释说,一旦课程的课程和活动全部到位,你可以调用rebuild_course_cache($courseid)来重新填充modinfo。


In my experience, Moodle is not the simplest or the most transparent system to graft your own code onto. An individual entity has many different table entries. For example, a lesson will appear in mdl_lessons, mdl_course_modules, mdl_grade items, and others. I would suggest using Moodle's own API for as much as possible. If you can't do that, you could try reverse-engineering it by adding a course through the standard interface, then checking your SQL log to see what table entries it made.

Regarding the bewildering mess that is modinfo, this post on the moodle forums says that it's automatically generated. This post explains that once a course's lessons and activities are all in place, you can call rebuild_course_cache($courseid) to repopulate modinfo.

相关问答

更多
  • 根据我的经验,Moodle并不是将您自己的代码移植到最简单或最透明的系统。 单个实体具有许多不同的表条目。 例如,课程将出现在mdl_lessons,mdl_course_modules,mdl_grade项目和其他项目中。 我建议尽可能多地使用Moodle自己的API。 如果你不能这样做,你可以尝试通过标准接口添加课程进行逆向工程,然后检查SQL日志以查看它所创建的表条目。 关于modinfo的令人眼花缭乱的混乱, moodle论坛上的这篇文章说它是自动生成的。 这篇文章解释说,一旦课程的课程和活动全部到 ...
  • XXXXXXX是您为插件添加新版本号的地方。 因此,以今天的日期为例,编辑插件的version.php,将版本号设置为2014092900(2014年9月29日,版本00),然后在插件的upgrade.php脚本中放入相同的版本号,而不是'XXXXXXXX'位(我假设你已经创建了函数'xmldb_MYPLUGINTYPE_MYPLUGINNAME_upgrade($ olversion = 0)'来放入这个升级代码)。 The XXXXXXX is where you put the new version ...
  • 我认为这对你有帮助 - $query_catetories = mysql_query('SELECT cc.id, cc.parent, cc.name FROM mdl_course_categories cc '); $categories = mysql_fetch_all($query_catetories); $tmp_categories = array(); foreach ($categories AS $row) { $row['id'] = (int) $row['id' ...
  • 经过更多的调查。 我发现这是由于“OS X上的mysql获取所需的sock文件的位置有点不对”。 一旦我创建了mysql sock文件所需的sym链接,一切正常。 有关详情,请参阅链接问题 After more investigation. I found that this was due to "mysql on OS X gets the locations of the required sock file a bit wrong". Once I created the sym links req ...
  • 所以我自己得到了答案 必须删除导致错误的mdl_pma_history表。 我遵循的步骤如下。 将表导出到.sql文件 删除表,因为它不允许脚本运行 一旦脚本(查找和替换)成功导入表后返回 完成。 So I got the answer on my own Had to delete the mdl_pma_history table that was causing the error. The Steps i followed are as follows. Exported the table to ...
  • 这个错误: PHP Warning: require(../config.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/moodle24/sbs_android_app/database_manipulation.php on line 2 表示脚本找不到名为config.php的文件。 ../config.php表示该脚本将尝试在脚本的父目录中打开一个名为config.php的文件 ...
  • 如果您运行Ubuntu(通过标记判断),您需要将项目目录放在/var/www 。 Apache无法访问指定目录中的项目文件夹,除非您更改用户/组等。 你尝试过的是web文件夹的普通apache默认位置,但Ubuntu喜欢改变一些东西。 if youre running Ubuntu (judging by the tag), you need to put your project directory inside /var/www. Apache cant access project folders i ...
  • 您是否已按照FreeTDS用户指南中的说明构建了支持FreeTDS的PHP? Have you built PHP with support for FreeTDS as described in the FreeTDS User Guide?
  • 问题是您的$ user对象包括不是mdl_user表中的字段的配置文件字段(例如'profile_field_ssocity')。 $ DB-> insert_record()将插入单个记录,因此用于插入此对象的对象必须具有所有映射到记录所插入的表的属性。 如果您还需要存储配置文件字段数据,则需要包含一个脚本,该脚本具有用于执行此操作的功能: require_once $CFG->dirroot . '/user/profile/lib.php'; profile_save_data($usernew); ...
  • 最好将课程ID传递给您的信息页面。 在原始页面中显示链接: $url = new moodle_url('\local\yourplugin\information.php', array('id' => $course->id)); echo html_writer::link($url, get_string('informationlink', 'local_yourplugin')); 然后在您的information.php页面中: $courseid = required_param('id' ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)