我想使用对流层库编写python脚本。这是为了在json中生成cloudformation脚本。
{
"schemaVersion": "2.2",
"Description": "Harden instance",
"Parameters": {
"domainpassword": {
"Default": "AutoADJoinSSMParameterPassword",
"Description": "Parameter store name to retrieve domain user password with join privileges.",
"Type": "String"
}
"mainSteps": [
{
"action": "aws:runPowerShellScript",
"name": "runPowerShellWithSecureString",
"precondition": {
"StringEquals": [
"platformType",
"Windows"
]
},
"inputs": {
"runCommand": [
"$domain = (Get-SSMParameterValue -Name domainName).Parameters[0].Value",
"$username = (Get-SSMParameterValue -Name domainJoinUserName).Parameters[0].Value",
"$password = (Get-SSMParameterValue -Name domainJoinPassword -WithDecryption $True).Parameters[0].Value | ConvertTo-SecureString -asPlainText -Force",
"$credential = New-Object System.Management.Automation.PSCredential($username,$password)",
"Add-Computer -DomainName $domain -Credential $credential -ErrorAction Stop",
"Restart-Computer -force"
]
}
}
]
}
我可以使用以下脚本检索一些详细信息
from troposphere import Ref, Template, Parameter
from troposphere.constants import STRING
import troposphere.ssm as ssm
t = Template()
t.set_description("Harden instance")
domainpassword = t.add_parameter(Parameter(
"domainpassword",
Type=STRING,
Default="AutoADJoinSSMParameterPassword",
Description="Parameter store name to retrieve domain user password with join privileges.",
))
上面的脚本产生输出
{
"Description": "Harden instance",
"Parameters": {
"domainpassword": {
"Default": "AutoADJoinSSMParameterPassword",
"Description": "Parameter store name to retrieve domain user password with join privileges.",
"Type": "String"
}
},
"Resources": {}
}
请协助使用对流层库获取“ mainSteps”部分。