-
-
Save yasudacloud/de6924c9f51576f73e5cedd49ffc799a to your computer and use it in GitHub Desktop.
ec2 describe script
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 | |
set -e | |
# AWS CLIを使用してEC2インスタンス情報を取得 | |
aws_output=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value | [0]]' --output json) | |
# TypeScriptファイルへの変換 | |
typescript_code=$(echo "$aws_output" | jq -r '. | map({"name": .[0][1], "value": .[0][0]}) | .') | |
echo "export const instances = $typescript_code;" > functions/resources.ts | |
cat functions/resources.ts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment