[英]How to set EC2 hostname programmatically (from outside the instance)?
This page in the docs describes how to set the hostname of an EC2 instance by logging in and running:文档中的此页面描述了如何通过登录并运行来设置 EC2 实例的主机名:
sudo hostnamectl set-hostname webserver.mydomain.com
sudo reboot
Is there a way to do this programmatically from outside the instance?有没有办法从实例外部以编程方式执行此操作? I have multiple instances that I need to do this for and logging into each one is not possible.我有多个实例需要执行此操作,并且无法登录到每个实例。
I'm using Boto3 but can't find the right command.我正在使用 Boto3,但找不到正确的命令。
Usually you would use AWS Systems Manager Run Command for such tasks:通常,您会使用AWS Systems Manager Run Command执行此类任务:
AWS Systems Manager Run Command lets you remotely and securely manage the configuration of your managed instances. AWS Systems Manager Run Command 让您可以远程安全地管理托管实例的配置。 Run Command enables you to automate common administrative tasks and perform ad hoc configuration changes at scale. Run Command 使您能够自动执行常见的管理任务并大规模执行临时配置更改。
This would require making your instances to be recognized by AWS Systems Manager (SSM) which requires three things:这需要让 AWS Systems Manager (SSM) 识别您的实例,这需要三件事:
AmazonSSMManagedInstanceCore
managed policy具有AmazonSSMManagedInstanceCore
托管策略的实例角色
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.