【发布时间】:2021-04-04 22:47:43
【问题描述】:
如何使用 Terraform 的 aws_ssm_document 在目标 VM 上运行 powershell 脚本? AWS 有 AWS-RunPowerShellScript,看起来像使用门户的 aws_ssm_document 命令。 如果我可以使用 powershell 脚本和 Terraform 文件函数创建/运行这个 aws_ssm_document,那将是理想的。
AWS-RunPowerShellScript 文档可用,因此应该可以使用 aws_ssm_document 传递 json 来创建文档和 aws_ssm_association将文档应用到 VM。
{
"Document": {
"Hash": "2142e42a19e0955cc09e43600bf2e633df1917b69d2be9693737dfd62e0fdf61",
"HashType": "Sha256",
"Name": "AWS-RunPowerShellScript",
"Owner": "Amazon",
"CreatedDate": "2017-08-31T16:52:31.357000-04:00",
"Status": "Active",
"DocumentVersion": "1",
"Description": "Run a PowerShell script or specify the paths to scripts to run.",
"Parameters": [
{
"Name": "commands",
"Type": "StringList",
"Description": "(Required) Specify the commands to run or the paths to existing scripts on the instance."
},
{
"Name": "workingDirectory",
"Type": "String",
"Description": "(Optional) The path to the working directory on your instance.",
"DefaultValue": ""
},
{
"Name": "executionTimeout",
"Type": "String",
"Description": "(Optional) The time in seconds for a command to be completed before it is considered to have failed. Default is 3600 (1 hour). Maximum is 172800 (48 hours).",
"DefaultValue": "3600"
}
],
"PlatformTypes": [
"Windows",
"Linux",
"MacOS"
],
"DocumentType": "Command",
"SchemaVersion": "1.2",
"LatestVersion": "1",
"DefaultVersion": "1",
"DocumentFormat": "JSON",
"Tags": []
}
}
我需要一个在 Terraform 中使用 AWS-RunPowerShellScript 的示例。
【问题讨论】:
标签: amazon-web-services amazon-ec2 terraform