简体   繁体   中英

Pass local variable value in AWS SSM Send Command

I am working on an automation of Certificates on AWS EC2 and the Certificates are dumped on the EC2 using SSM. The script is written in Python, which creates a SSM session and executes the commmand to dump the Certificate.

The base64 Certificate is in a python variable (let's say "Cert" variable). How do i pass the value of this variable in the AWS SSM Send command function of boto3 ?

code:


Cert="-----BEGIN CERTIFICATE-----........."

    response = ssm_client.send_command(
        InstanceIds=[
            healthy_instance[0] 
            ],
                 DocumentName="AWS-RunShellScript",
                 Parameters={
                     'commands':[
                         '**Command to be added here**'
                         ]
                     },
        )

您可以使用f"some command text {Cert} more optional text"格式化字符串 –

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