I'm trying to use a local shell processor script at the end of our Packer build that gets the latest AMI ID and then pushes this to a specific SSM param.
So far I can get the latest AMI without issue doing
AWS_PROFILE=myprofile AWS_DEFAULT_REGION=us-east-1 aws ec2 describe-images --owners self --filters "Name=name,Values=my-eks-*" --query 'reverse(sort_by(Images,&CreationDate))[:1].{id:ImageId,date:CreationDate}' --output json | grep "ami-"
The above code successfully prints the latest AMI I want to push to SSM. I'm just having trouble thinking of a way to get this output successfully to SSM within the same script. Any ideas?