[英]How can I run a powershell script on a target VM using Terraform's aws_ssm_document
How can I run a powershell script on a target VM using Terraform's aws_ssm_document?如何使用 Terraform 的 aws_ssm_document 在目标 VM 上运行 powershell 脚本? AWS has AWS-RunPowerShellScript in what looks like a aws_ssm_document command using the portal.
AWS 在使用门户的 aws_ssm_document 命令中具有AWS-RunPowerShellScript 。 It would be ideal if I could create/run this aws_ssm_document using a powershell script and the Terraform file function.
如果我可以使用 powershell 脚本和 Terraform 文件 function 创建/运行此 aws_ssm_document,那将是理想的。
The AWS-RunPowerShellScript document is available, so it should be possible to use the aws_ssm_document passing json, to create a document and aws_ssm_association to apply the document to a VM. AWS-RunPowerShellScript文档可用,因此应该可以使用传递 json 的aws_ssm_document创建文档并使用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": []
}
}
I need an example using AWS-RunPowerShellScript in Terraform.我需要一个在 Terraform 中使用AWS-RunPowerShellScript的示例。
You can't execute any SSM run commands from terraform natively.您无法从 terraform 本地执行任何 SSM 运行命令。 This is not supported :
这不受支持:
Instead, you can use local-exec to execute AWS CLI's send-command .相反,您可以使用local-exec来执行 AWS CLI 的send-command 。 The other possibility is AWS SDK to do same, but using a lambda function with aws_lambda_invocation .
另一种可能性是 AWS SDK 做同样的事情,但使用 lambda function 和aws_lambda_invocation 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.