简体   繁体   中英

Creating EC2 instance and attaching it to a specific ECS cluster

I am using the AWS PHP SDK to create an ECS Cluster.

I am also using the AWS PHP SDK to create EC2 Instances.

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. Any ideas?

There is no API call for that. Instead, you specify which cluster a given instance belongs to using user data , as explained in AWS docs . So your newly launch EC2 instances should have user data in the following form:

#!/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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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