如何以编程方式设置 EC2 主机名(从实例外部)?
How to set EC2 hostname programmatically (from outside the instance)?
文档中的 page 描述了如何通过登录和 运行:
设置 EC2 实例的主机名
sudo hostnamectl set-hostname webserver.mydomain.com
sudo reboot
有没有办法从实例外部以编程方式执行此操作?我有多个实例需要执行此操作,但无法登录到每个实例。
我正在使用 Boto3,但找不到正确的命令。
通常你会使用 AWS Systems Manager Run Command 来完成这样的任务:
AWS Systems Manager Run Command lets you remotely and securely manage the configuration of your managed instances. Run Command enables you to automate common administrative tasks and perform ad hoc configuration changes at scale.
这需要让您的实例被 AWS Systems Manager (SSM) 识别,这需要三件事:
- 与 SSM 服务的网络连接。
- 已安装 SSM 代理并 运行 - 通用官方 AMI(ubuntu、亚马逊 linux、...)已安装 运行 和设置。
- 具有
AmazonSSMManagedInstanceCore
托管策略的实例角色
文档中的 page 描述了如何通过登录和 运行:
设置 EC2 实例的主机名sudo hostnamectl set-hostname webserver.mydomain.com
sudo reboot
有没有办法从实例外部以编程方式执行此操作?我有多个实例需要执行此操作,但无法登录到每个实例。
我正在使用 Boto3,但找不到正确的命令。
通常你会使用 AWS Systems Manager Run Command 来完成这样的任务:
AWS Systems Manager Run Command lets you remotely and securely manage the configuration of your managed instances. Run Command enables you to automate common administrative tasks and perform ad hoc configuration changes at scale.
这需要让您的实例被 AWS Systems Manager (SSM) 识别,这需要三件事:
- 与 SSM 服务的网络连接。
- 已安装 SSM 代理并 运行 - 通用官方 AMI(ubuntu、亚马逊 linux、...)已安装 运行 和设置。
- 具有
AmazonSSMManagedInstanceCore
托管策略的实例角色