简体   繁体   English

创建 EC2 实例并将其附加到特定的 ECS 集群

[英]Creating EC2 instance and attaching it to a specific ECS cluster

I am using the AWS PHP SDK to create an ECS Cluster.我正在使用 AWS PHP SDK 创建 ECS 集群。

I am also using the AWS PHP SDK to create EC2 Instances.我还使用 AWS PHP SDK 创建 EC2 实例。

I can't find API calls to create an instance, specify particular options (for instance on the spot) and adding it to the cluster I am creating.我找不到 API 调用来创建实例、指定特定选项(例如当场)并将其添加到我正在创建的集群中。 Any ideas?有任何想法吗?

There is no API call for that.没有 API 要求。 Instead, you specify which cluster a given instance belongs to using user data , as explained in AWS docs .相反,您可以使用用户数据指定给定实例属于哪个集群,如AWS 文档中所述。 So your newly launch EC2 instances should have user data in the following form:因此,您新启动的 EC2 实例应具有以下形式的用户数据:

#!/bin/bash
echo "ECS_CLUSTER=MyCluster" >> /etc/ecs/ecs.config

As well as proper IAM instance role allowing the ECS agent to register with your ECS cluster.以及适当的 IAM 实例角色,允许 ECS 代理向您的 ECS 集群注册。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM