[英]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.