简体   繁体   English

使用 boto3 创建 SSM 文档以关闭微服务及其关联的 EC2 实例

[英]create SSM document with boto3 that shuts down microservices and their associated EC2 instances

I have been assigned a task to develop a solution that shut down all microservice processes running on a given EC2 instance in parallel and then shut down the EC2 instance itself and do this on a set of EC2 instances in parallel.我被分配了一项任务来开发一个解决方案,该解决方案并行关闭在给定 EC2 实例上运行的所有微服务进程,然后关闭 EC2 实例本身,并在一组 EC2 实例上并行执行此操作。 This is supposed to take input from a YAML configuration file (let's call it the parent) similar to the following that identifies the mount point of the micro services:这应该从 YAML 配置文件(我们称之为父文件)获取输入,类似于以下标识微服务挂载点的配置文件:

fabric: usprod1
sequence:
  stateless:
    - admin-portal
    - dashboard
    - haraka
    - vm-prometheus
    - watchtower-server
    - web-analytics-service
  dbclusters:
    - kafka
    - druid
    - rabbitmq
  zkclusters:
    - zookeeper
  shared:
    - eureka
  bootstrap:
    - consul
    - census

My solution is supposed to create "child" SSM documents that correspond to each mount point within a service group where there might be multiple EC2 instances associated with each mount point.我的解决方案应该创建与服务组中的每个挂载点相对应的“子”SSM 文档,其中可能有多个 EC2 实例与每个挂载点相关联。 I've reviewed the following web pages, but they don't give me any insight as to how I'm supposed to use the parent YAML file to generate the children:我已经查看了以下 web 页,但它们没有告诉我应该如何使用父 YAML 文件生成子文件:

How do I pass multiple parameters to AWS SSM send_command with Boto3 https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html 如何使用 Boto3 将多个参数传递给 AWS SSM send_command https://docs.aws.amazon.com/systems-manager/latest/userguide/create-ssm-document-api.html

This case can be tackled using few approaches but I would suggest do some reading on Lambda or Step Functions first and then you should be good to go.这种情况可以使用几种方法来解决,但我建议先阅读 Lambda 或Step Functions ,然后再阅读 go。

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

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