Skip to content

Instantly share code, notes, and snippets.

@jsyi
jsyi / eb-environment-arn
Created January 5, 2018 09:50
List AWS Elastic Beanstalk Environment ARNs
aws elasticbeanstalk describe-environments | jq ".Environments[].EnvironmentArn"
@jsyi
jsyi / cwl-last-used.sh
Last active July 11, 2024 01:12
Use AWS CLI to query AWS CloudWatch Logs and determine the most recent entry into a Log Group
aws logs describe-log-groups | jq ".logGroups[].logGroupName" | grep -E "homeplus|mcdonalds" | xargs -n 1 -t aws logs describe-log-streams --query "logStreams[*].lastEventTimestamp" --log-group | jq "max/1000|floor" | xargs -t -n 1 date -r
# aws logs describe-log-groups | jq ".logGroups[].logGroupName"
# Get LogGroup names
# grep -E "homeplus|mcdonalds"
# (Optional) Filter LogGroup names
# xargs -n 1 -t aws logs describe-log-streams --query "logStreams[*].lastEventTimestamp" --log-group | jq "max/1000|floor"
# Get last event timestamp for each LogGroup.
@jsyi
jsyi / bamboo-branch_update_results.sh
Created November 27, 2017 07:17
Bamboo build task script for updating Github branch status after build/tests are complete.
#!/bin/bash
cd ${bamboo.build.working.directory}
REPO_URL=${bamboo.planRepository.1.repositoryUrl}
[[ $REPO_URL =~ github.com\/(.*).git ]]
STATUS_UPDATE_URL="https://api.github.com/repos/${BASH_REMATCH[1]}/statuses/${bamboo.repository.revision.number}"
if ls **/test-reports/*.xml 1> /dev/null 2>&1; then
curl -H "Authorization: token ${bamboo.githubStatusUpdateTokenForMeshkoreaDev}" --request POST --data '{"state": "success", "context": "bamboo/build", "description": "Bamboo build Completed!", "target_url": "${bamboo.buildResultsUrl}"}' $STATUS_UPDATE_URL > /dev/null
else
@jsyi
jsyi / eb-versions.sh
Last active November 27, 2017 07:14
See how many application versions each Elastic Beanstalk application is using from the command line. Useful for monitoring how close we are to AWS Service Limits.
#!/bin/bash
# Requires AWS CLI Tools (https://aws.amazon.com/cli) and jq (https://stedolan.github.io/jq)
# AWS CLI must be configured with access key with approperiate role/permissions
aws elasticbeanstalk describe-application-versions --query "ApplicationVersions[*].ApplicationName" | jq '{"total": length, "lists": group_by(.)} | {"Applications": [ (.lists[] | {"Application": .[0], "Versions": length })], "Total Versions": .total }'