如何在启动时通过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 ....................
但是,当我在浏览器中看到时,我立即注意到自动关联的公共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
最满意答案
根据我的经验,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创建PHP课程时,我该如何处理数据库?(What should I do with the database when I create a course in PHP with Moodle?)[2024-03-28]
根据我的经验,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 ...
-
使用php显示Moodle数据库数据为ul li [duplicate](Displaying Moodle database data as ul li using php [duplicate])[2024-03-29]
我认为这对你有帮助 - $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' ... -
Moodle数据库连接错误(Moodle database connection error)[2023-09-11]
经过更多的调查。 我发现这是由于“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的文件 ...
-
我怎样才能启用moodle?(How can I enable moodle?)[2021-11-27]
如果您运行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 ... -
与SQL Server的Moodle(Moodle with SQL Server)[2023-06-27]
您是否已按照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); ...
-
Moodle |(Moodle | Getting course data moodle)[2022-10-14]
最好将课程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' ...