0

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.

I am able to successfully grab the task via the Get-ECSTaskDefinitionDetail cmdlet but I'm stuck on what to do next.

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. All my attempts with the Register-ECSTaskDefinition Cmdlet seem to fail as it wants individual arguments for each parameter instead of a json upload.

Any advice would be appreciated. Thanks,

gd125
  • 11
  • 3
  • It's not "only available via CLI, it is also available via API". Any reason you have to use the Powershell tools, instead of the standard AWS CLI tool? https://docs.aws.amazon.com/cli/latest/reference/ecs/register-task-definition.html The standard tool supports passing in JSON. – Mark B Oct 04 '22 at 17:31
  • Ended up going this route. Thanks for the advice – gd125 Oct 06 '22 at 17:07

1 Answers1

0

I don't have one to test with, but most AWS cmdlets return objects which can be piped to each other. Get-ECSTaskDefinitionDetail does too, returning an DescribeTaskDefinitionResponse object, with what looks like all the right properties to auto-fill the registration. Try out

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

Or it might require using this .TaskDefinition property:

$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.


That said, it's pretty awkward that it won't take json when two of its parameters do. Might be worth reopening this feature request:

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

Cpt.Whale
  • 4,784
  • 1
  • 10
  • 16