Search code examples
amazon-web-servicesamazon-ecsaws-fargate

Getting the latest fargate platform version value using the AWS SDK


I'm trying to build some automation software that checks if resources are up to date, specifically getting the latest version value which is 1.4 atm. Can't seem to find a way of doing this through the sdk for fargate

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html


Solution

  • The syntax may vary depending on the language you are using but in general you'd first list the tasks running in your cluster and then you'd describe them. This is how it works from the CLI, you can use the same process for the specific language you plan to use:

    $ aws ecs list-tasks --cluster mywebapp
    {
        "taskArns": [
            "arn:aws:ecs:us-west-2:123456789:task/mywebapp/0f66dab0699543dbb1153f850f3a2610",
            "arn:aws:ecs:us-west-2:123456789:task/mywebapp/11ca1f4d41524f3b941bb8b281fde2a6",
            "arn:aws:ecs:us-west-2:123456789:task/mywebapp/b4c093d37bcf4b85b50d8c757c93b376",
            "arn:aws:ecs:us-west-2:123456789:task/mywebapp/b50130ed847647e387f87c50431f30e0"
        ]
    }
    

    And then you iterate through the tasks describing them. This is how you'd describe one of them and how you'd filter the returning json:

    $ aws ecs describe-tasks --cluster mywebapp --tasks b50130ed847647e387f87c50431f30e0 | jq .tasks[0].platformVersion                                     
    "1.4.0"
    

    This task is on PV 1.4.

    [UPDATED ANSWER]: there were some misinterpretation going on on my side. The actual question is "I have a list of all tasks PV versions already, how can I know what the latest version is?". The correct answer is that we don't publish that info. One reason why we don't do that is because the PV is somewhat static and we have not announced a lot of them since we introduced Fargate 4 years ago. One way to address this would be to create an SSM parameter store entry like we do for AMIs. However there is a school of thought that this could be a bazooka to shoot a fly for a version number that changes so rarely. Happy to hear your feedback re this.