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
aws ecs list-task-definitions --status active | jq -r '.taskDefinitionArns[]' | cut -d'/' -f2 | while read taskDefinition; do | |
echo -ne "$taskDefinition - " ; aws ecs describe-task-definition --task-definition $taskDefinition | jq -r '.taskDefinition.containerDefinitions[] | "\(.name) - \(.memory) - \(.memoryReservation)"' | |
done |
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
aws ecs list-services --cluster $ECS_CLUSTER_NAME | jq -r '.serviceArns[]' | while read service ; do | |
aws ecs describe-services --services $service --cluster $ECS_CLUSTER_NAME | jq -r '.services[] | "\(.serviceName) - \(.desiredCount) - \(.deploymentConfiguration.minimumHealthyPercent),\(.deploymentConfiguration.maximumPercent)"' | |
done |
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
aws ecs list-services --cluster $ECS_CLUSTER_NAME | jq -r '.serviceArns[]' | while read service ; do | |
aws ecs describe-services --services $service --cluster $ECS_CLUSTER_NAME | jq -r '.services[] | "\(.serviceName) - \(.placementConstraints[].type) - \(.placementConstraints[].expression)"' | |
done |
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
terragrunt plan | egrep '(new resource required)|container_definitions' | sed -n '$!N;s/\x1b\[[0-9;]*m//g;s/\n/;/;s/.*aws_ecs_task_definition.//g;s/ *(new resource required)//g;s/ *container_definitions: *"//gp;;s/" *(forces new resource)//g' | while read task_definition; do | |
echo -e "\nDIFF for: \033[0;31m$(echo $task_definition | cut -d';' -f1)\033[0m\n$(diff <(echo $task_definition | cut -d';' -f2- | sed 's/\\"/"/g;s/^ //g;s/ => /\n/g;s/"\[/\[/g;s/\]"/\]/g;s/ *(forces new resource)//g' | head -1 | jq) <(echo $task_definition | cut -d';' -f2- | sed 's/\\"/"/g;s/^ //g;s/ => /\n/g;s/"\[/\[/g;s/\]"/\]/g;s/ *(forces new resource)//g' | tail -1 | jq))" | egrep -v '\+\+\+|\-\-\-' | egrep '^(\+|\-|DIFF for)' | |
done |
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/bash | |
ecsServiceName=$1 | |
environment=$2 | |
taskNameEcsCluster=$(aws ecs list-clusters | jq -r '.clusterArns[]' | grep $environment | while read cluster; do aws ecs list-services --cluster $cluster | jq -r '.serviceArns[]' | grep "$ecsServiceName$" && echo $cluster; done | rev | cut -d'/' -f1 | rev | sed 'N;s/\n/ /') | |
echo "taskNameEcsCluster: ${taskNameEcsCluster}" | |
taskName=$(echo $taskNameEcsCluster | cut -d' ' -f1) | |
echo "taskName: ${taskName}" | |
ecsCluster=$(echo $taskNameEcsCluster | cut -d' ' -f2) | |
echo "ecsCluster: ${ecsCluster}" | |
ec2Address=$(aws ecs describe-tasks --task $(aws ecs list-tasks --cluster $ecsCluster | jq -r '.taskArns[]' | grep $(aws ecs describe-services --services $taskName --cluster $ecsCluster | jq -r '.services[].events[] | "\(.id) \(.message)"' | grep 'has started' | head -1 | grep -o "[0-9a-f]\{32\}")) --cluster $ecsCluster | jq -r '.tasks[].containers[] | (.networkInterfaces[0].privateIpv4Address, .networkBindings[0].bindIP) | select(length > 0)') |
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
totalNumberOfUntagged=0 | |
while read repository; do | |
numberOfUntagged=$(aws ecr list-images --repository-name ${repository} --filter tagStatus=UNTAGGED --query 'imageIds[*]' | jq -r '.[].imageDigest' | wc -l) | |
if [[ ${numberOfUntagged} -gt 0 ]]; then | |
echo "${repository} - ${numberOfUntagged}" | |
totalNumberOfUntagged=$((totalNumberOfUntagged + numberOfUntagged)) | |
fi | |
done < <(aws ecr describe-repositories | jq -r '.repositories[].repositoryName' | sort) | |
echo ${totalNumberOfUntagged} |
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
aws ecr describe-repositories | jq -r '.repositories[].repositoryName' | sort | while read repository; do | |
totalSizeOfUntagged=0 | |
while read imageSizeInBytes; do | |
totalSizeOfUntagged=$((totalSizeOfUntagged + imageSizeInBytes)) | |
done < <(aws ecr describe-images --repository-name ${repository} --filter tagStatus=UNTAGGED | jq -r '.imageDetails[].imageSizeInBytes') | |
if [[ ${totalSizeOfUntagged} -gt 0 ]]; then | |
echo -ne "${repository} - " | |
echo ${totalSizeOfUntagged} | awk '{ print $1/1024/1024 " MB" }' | |
fi | |
done |
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/bash | |
awsRegion=$1 | |
instanceType=$2 | |
url=https://banzaicloud.com/cloudinfo/api/v1/providers/amazon/services/compute/regions/${awsRegion}/products | |
curl -ksLX GET ${url} | jq ".products[] | select(.type | contains(\"${instanceType}\")) | .onDemandPrice" |
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
aws es list-domain-names | jq -r .DomainNames[].DomainName | while read dn; do echo -ne "$dn - " ; curl -sk https://$(aws es describe-elasticsearch-domain --domain-name ${dn} | jq -r .DomainStatus.Endpoints.vpc)/_cluster/health | jq .status ; done |
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
AWS_PROFILE=${AWS_PROFILE:-default} | |
EKS_CLUSTER_NAME= | |
KUBECONFIG=/root/.kube/config | |
TF_STATE=$(terragrunt output -json config_map_aws_auth | jq '.[].metadata[]') | |
CONFIG_MAP_NAMESPACE=$(echo "${TF_STATE}" | jq -r '.namespace') | |
CONFIG_MAP_NAME=$(echo "${TF_STATE}" | jq -r '.name') | |
curl -k \ | |
-H "Authorization: Bearer $(AWS_PROFILE=${AWS_PROFILE} aws eks get-token --cluster-name ${EKS_CLUSTER_NAME} | jq -r .status.token)" \ | |
-H 'Accept: application/json' \ | |
$(yq e '.clusters[].cluster.server' ${KUBECONFIG})/api/v1/namespaces/${CONFIG_MAP_NAMESPACE}/configmaps/${CONFIG_MAP_NAME} |
OlderNewer