![](/img/trans.png)
[英]How can I run a powershell script on a target VM using Terraform's aws_ssm_document
[英]How to pass a powershell command to AWS SSM Document/Run Command using Terraform?
我正在嘗試利用 AWS-RunPowerShellScript SSM 文檔並通過它傳遞命令,以在 Windows EC2 實例上運行。 我無法弄清楚如何將以下命令傳遞給 Terraform。
命令powershell.exe -ExecutionPolicy Bypass -file "C:\aws\1-start-ebs-snapshot.ps1"
我需要使用下面的 SSM 文檔在 EC2 實例上運行命令。
resource "aws_ssm_document" "run_powershell_cmd" {
name = "AWS-RunPowerShellScript"
document_type = "Command"
}
以下對我有用:
resource aws_ssm_document run_powershell_cmd {
name = "run_powershell_cmd"
document_type = "Command"
content = <<DOC
{
"schemaVersion": "1.2",
"description": "execute pwsh command",
"parameters": {
},
"runtimeConfig": {
"aws:runPowerShellScript": {
"properties": [
{
"id": "0.aws:runPowerShellScript",
"runCommand": ["powershell.exe -ExecutionPolicy Bypass -file 'C:\\aws\\1-start-ebs-snapshot.ps1'"]
}
]
}
}
}
DOC
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.