Skip to content

Instantly share code, notes, and snippets.

@hideokamoto
Created March 22, 2017 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hideokamoto/6e8a33deec02cf4d843896a67f3b4c04 to your computer and use it in GitHub Desktop.
Save hideokamoto/6e8a33deec02cf4d843896a67f3b4c04 to your computer and use it in GitHub Desktop.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: |
WP VERSIONS
Resources:
GetAllWpVersion:
Type: "AWS::SSM::Document"
Properties:
DocumentType: "Command"
Content:
schemaVersion: "1.2"
description: "Get AMIMOTO's WP Versions"
runtimeConfig:
aws:runShellScript:
properties:
- id: 0.aws:runShellScript
runCommand:
- REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e "s/.$//g")
- INSTANCEID=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/instance-id)
- ITEMS=$(find . -type f -name 'wp-load.php' -exec bash -c '_wp=$(echo {} | sed -e s/[^\/]*$//); jo wp_version=$(sudo -u ec2-user /usr/local/bin/wp core version --path=${_wp}) domain=${_wp}' \;)
- QUERY=$(jo -a $(jo CaptureTime=$(date +%Y-%m-%dT%H:%M:%SZ) TypeName=Custom:WPVersionsList Content=$(jo -a ${ITEMS}) SchemaVersion=\"1.0\") | sed 's/\\"//g')
- aws ssm put-inventory --instance-id "${INSTANCEID}" --items "$(echo ${QUERY})" --region "${REGION}"
workingDirectory: "/var/www/vhosts/"
timeoutSeconds: "300"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment