如何将lambda中的变量引用到AWS-RunShellScript命令

zsohkypk  于 2023-01-26  发布在  Shell
关注(0)|答案(1)|浏览(110)

我尝试将变量account_id传递给lambda函数内的shell脚本,此lambda将在该帐户的示例上运行该脚本

import sys
import logging
import datetime
import boto3
import botocore
import time
import json
from os import getenv

region = 'ap-southeast-2'
boto3.setup_default_session(region_name=region)
account_id = 123454

def handler(event, context):
client = boto3.client('ssm')

instance_name_list=\[12345678890,0000000000\]
if instance_name_list:
try:
response = client.send_command(
Targets=\[
{
'Key': 'InstanceIds',
'Values': instance_name_list
},
\],
DocumentName='AWS-RunShellScript',
Parameters={
'commands': \[

                      # shell command
                      'echo {account_ID}',
    
                      
                  ]
              }
          )

实现这一目标的正确途径是什么?

相关问题