简体   繁体   English

使用 Powershell 更新 AWS ECS 任务定义

[英]Update AWS ECS Task Definition with Powershell

long story short, I need to update my ECS Task definition via powershell in order to increase the "EphemeralStorage_SizeInGiB" which is only available via the AWS cli.长话短说,我需要通过 powershell 更新我的 ECS 任务定义,以增加只能通过 AWS cli 获得的“EphemeralStorage_SizeInGiB”。

I am able to successfully grab the task via the Get-ECSTaskDefinitionDetail cmdlet but I'm stuck on what to do next.我能够通过 Get-ECSTaskDefinitionDetail cmdlet 成功获取任务,但我不知道下一步该做什么。

I was able to convert that output to JSON and update the ephemeral storage field in the json file but cannot figure how to send that back to AWS.我能够将 output 转换为 JSON 并更新 json 文件中的临时存储字段,但不知道如何将其发送回 AWS。 All my attempts with the Register-ECSTaskDefinition Cmdlet seem to fail as it wants individual arguments for each parameter instead of a json upload.我对 Register-ECSTaskDefinition Cmdlet 的所有尝试似乎都失败了,因为它需要每个参数单独的 arguments 而不是 json 上传。

Any advice would be appreciated.任何意见,将不胜感激。 Thanks,谢谢,

I don't have one to test with, but most AWS cmdlets return objects which can be piped to each other.我没有可用于测试的工具,但大多数AWS cmdlet 返回的对象可以通过管道传递给彼此。 Get-ECSTaskDefinitionDetail does too, returning an DescribeTaskDefinitionResponse object, with what looks like all the right properties to auto-fill the registration. Get-ECSTaskDefinitionDetail也这样做,返回一个DescribeTaskDefinitionResponse object,其中包含自动填充注册的所有正确属性。 Try out试用

Get-ECSTaskDefinitionDetail -TaskDefinition $ARN | 
  Register-ECSTaskDefinition -EphemeralStorage_SizeInGiB $newSize

Or it might require using this .TaskDefinition property:或者它可能需要使用这个.TaskDefinition属性:

$Response = Get-ECSTaskDefinitionDetail -TaskDefinition $ARN
$Response.TaskDefinition | Register-ECSTaskDefinition -EphemeralStorage_SizeInGiB $newSize

and maybe it's that easy?也许就这么简单?

note that you must not use -Select in the Get command, or it will return a different object type.请注意,您不能在 Get 命令中使用-Select ,否则它将返回不同的 object 类型。


That said, it's pretty awkward that it won't take json when two of its parameters do.也就是说,当它的两个参数需要时,它不会采用 json,这很尴尬。 Might be worth reopening this feature request:可能值得重新打开此功能请求:

https://github.com/aws/aws-tools-for-powershell/issues/184 https://github.com/aws/aws-tools-for-powershell/issues/184

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM