This file contains hidden or 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 support describe-trusted-advisor-check-result --check-id eW7HH0l7J9 --query 'result.sort_by(flaggedResources[?status!="ok"],&metadata[2])[].metadata' --output table --region us-east-1 |
This file contains hidden or 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 | |
| cluster=default | |
| container_instance= # container instance guid | |
| tasks=$(aws --region us-west-2 ecs list-tasks --container-instance $container_instance --cluster $cluster | jq -r '.taskArns | map(.[40:]) | reduce .[] as $item (""; . + $item + " ")') | |
| for task in $tasks; do | |
| aws --region us-west-2 ecs stop-task --task $task --cluster $cluster | |
| done | |
| aws --region us-west-2 ecs deregister-container-instance --cluster $cluster --container-instance $container_instance |
This file contains hidden or 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 | |
| cluster=default | |
| container_instance= # container instance guid | |
| tasks=$(aws --region us-west-2 ecs list-tasks --container-instance $container_instance --cluster $cluster | jq -r '.taskArns | map(.[40:]) | reduce .[] as $item (""; . + $item + " ")') | |
| for task in $tasks; do | |
| aws --region us-west-2 ecs stop-task --task $task --cluster $cluster | |
| done | |
| aws --region us-west-2 ecs deregister-container-instance --cluster $cluster --container-instance $container_instance |
This file contains hidden or 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
| yum install jq | |
| curl 127.0.0.1:51678/v1/tasks | jq '[.Tasks[] | {task: "\(.Family):\(.Version)",status: "\(.KnownStatus) -> \(.DesiredStatus)", dockerId: .Containers[0] | .DockerId}] | sort_by(.task,.dockerId)' |
This file contains hidden or 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
| version: 0.1 | |
| # REQUIRED ENVIRONMENT VARIABLES | |
| # AWS_KEY - AWS Access Key ID | |
| # AWS_SEC - AWS Secret Access Key | |
| # AWS_REG - AWS Default Region (e.g. us-west-2) | |
| # AWS_OUT - AWS Output Format (e.g. json) | |
| # AWS_PROF - AWS Profile name (e.g. central-account) | |
| # IMAGE_REPO_NAME - Name of the image repo (e.g. my-app) | |
| # IMAGE_TAG - Tag for the image (e.g. latest) |
This file contains hidden or 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
| # See https://forums.aws.amazon.com/thread.jspa?threadID=222215 | |
| aws_login=$(aws ecr get-login --region us-east-1); | |
| if echo "$aws_login" | grep -q -E '^docker login -u AWS -p \S{1092} -e none https://[0-9]{12}.dkr.ecr.\S+.amazonaws.com$'; then $aws_login; fi |
This file contains hidden or 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 | |
| REPOSITORY=[[[[[ecr_registrory_name]]]]] | |
| IMAGE=$REPOSITORY:latest | |
| AWS_REGION=[[[[[your_region]]]]] | |
| # docker login | |
| aws ecr get-login --region $AWS_REGION | |
| # docker build |
This file contains hidden or 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 | |
| # | |
| # 前準備として、移行先に各イメージのレポジトリを作成しておく必要あり。 | |
| # $from、$to、$aws_account_id、$images は適宜変更する。 | |
| # | |
| set -e | |
| from="us-east-1" | |
| to="ap-northeast-1" | |
| aws_account_id="" |
This file contains hidden or 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 -ex | |
| # Warning: use with caution! Once ran, this script is going to wipeout all | |
| # images that you own into your AWS ECR. | |
| aws ecr describe-repositories | jq '.repositories[].repositoryName' | sed s/\"//g | while read repository_name; do | |
| batch_delete_string='' | |
| aws ecr list-images --repository-name "${repository_name}" | \ | |
| jq '.imageIds[].imageTag' | while read image_tag; do | |
| batch_delete_string="imageTag=${image_tag} " |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: UTF-8 -*- | |
| import argparse | |
| import boto3 | |
| parser = argparse.ArgumentParser(description='Cleanup Docker images form ECR.') | |
| parser.add_argument('--repository-name', metavar='repo', dest='repository_name', required=True, help='Repository name') | |
| parser.add_argument('--registry-id', metavar='registry', dest='registry_id', required=False, help='Registry ID.If you do not specify a registry, the default registry is assumed.') | |
| parser.add_argument('--delete', dest='delete', required=False, default=False, action='store_true', help='If set to true, delete the untagged images. Otherwise (default), only list them') |