Created
April 25, 2017 21:47
-
-
Save ziggythehamster/0befb3b3fda2f2ac9f568225a4b23114 to your computer and use it in GitHub Desktop.
Amazon SSM Docker Inventory Collectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This script will make an API call to Docker and use JQ to output a document that SSM can | |
# pick up as custom inventory. | |
# TODO: mounts | |
curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" "http:/v1.24/containers/json" | jq '{ SchemaVersion: "1.0", TypeName: "Custom:DockerContainers", Content: [.[] | { Id: .Id, Name: .Names[0] | ltrimstr("/"), State: .State, Status: .Status, Created: .Created | todateiso8601, BoundPorts: .Ports | [ .[] | select(.PublicPort != null) | [.IP, (.PublicPort | tostring), (.PrivatePort | tostring)] | join(":") ] | join(", "), NetworkMode: .HostConfig.NetworkMode, ECSTaskARN: .Labels["com.amazonaws.ecs.task-arn"], ECSTaskFamily: .Labels["com.amazonaws.ecs.task-definition-family"], ECSTaskVersion: .Labels["com.amazonaws.ecs.task-definition-version"] }] }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment