将参数添加到SSM维护窗口任务
我正在尝试通过在S3中执行脚本来使用SSM Run命令 - 我已经尝试对其进行编码,现在已经手动进行了所有作品。
我坚持将参数添加到SSM Manintenance窗口任务。
这是下面的snippet。我正在添加3个参数,并计划/应用运行正常,但更改并未反映在控制台中!
resource "aws_ssm_maintenance_window_task" "task" {
max_concurrency = "2"
max_errors = "1"
task_arn = "AWS-RunRemoteScript"
task_type = "RUN_COMMAND"
window_id = aws_ssm_maintenance_window.taskuploadmaintenancewindow.id
targets {
key = "WindowTargetIds"
values = [aws_ssm_maintenance_window_target.taskuploadmaintenancewindowtarget.id]
}
task_invocation_parameters {
run_command_parameters {
parameter {
name = "SourceType"
values = ["S3"]
}
parameter {
name = "SourceInfo"
values = ["{\"path\":\"https://mybucket.s3.ap-northeast-1.amazonaws.com/myscript.sh\"}"]
}
parameter {
name = "commands"
values = ["myscript.sh"]
}
}
}
I'm trying to use the SSM Run Command by executing a script in S3 - I've tested this all works manually now I'm trying to code it.
I'm stuck with adding parameters to an SSM manintenance window task.
Following this example - https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_maintenance_window_task
Here is the snippet below. I'm adding 3 parameters and plan/apply runs fine but the changes are not reflected in the console!
resource "aws_ssm_maintenance_window_task" "task" {
max_concurrency = "2"
max_errors = "1"
task_arn = "AWS-RunRemoteScript"
task_type = "RUN_COMMAND"
window_id = aws_ssm_maintenance_window.taskuploadmaintenancewindow.id
targets {
key = "WindowTargetIds"
values = [aws_ssm_maintenance_window_target.taskuploadmaintenancewindowtarget.id]
}
task_invocation_parameters {
run_command_parameters {
parameter {
name = "SourceType"
values = ["S3"]
}
parameter {
name = "SourceInfo"
values = ["{\"path\":\"https://mybucket.s3.ap-northeast-1.amazonaws.com/myscript.sh\"}"]
}
parameter {
name = "commands"
values = ["myscript.sh"]
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了。 “命令”需要作为命令
行,我的工作方式是返回SSM Run命令,构建新命令并滚动到底部并查看AWS CLI CONFIC的语法,它为您构建:
因此,现在更改案例/命令行有效。我希望有一天对某人有帮助。
Worked it out.. It's a bit silly but those parameters need to be camel case & 'commands' needed to be commandLine
The way I worked this out was to go back into SSM Run Command, build out a new command and scroll to the bottom and review the syntax of the AWS CLI config it builds for you:
So now changing the case/commandLine works. I hope this helps someone one day.
顺便说一句,我发现输入SourceInfo时没有处理可怕的格式,而是可以将其包装在Terraform的Jsonencode中。
By the way, I found out that instead of dealing with the horrendous format when inputting sourceInfo, you can wrap it in jsonencode in Terraform.