Skip to content

Instantly share code, notes, and snippets.

@noid11
Created January 4, 2021 10:14
Show Gist options
  • Save noid11/bbd6ff50742443735a66c616ccdaa559 to your computer and use it in GitHub Desktop.
Save noid11/bbd6ff50742443735a66c616ccdaa559 to your computer and use it in GitHub Desktop.
テキストファイルから1行読み取って任意のコマンドで使うシェルスクリプト例

以下のような NLB の ARN リストを格納したテキストファイル (my-nlb-arn-list.txt) があるとして

arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:loadbalancer/net/my-nlb-v1/776ab4bf27401940
arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:loadbalancer/net/my-nlb-v2/03f5ebb8e36740c8
arn:aws:elasticloadbalancing:ap-northeast-1:123456789012:loadbalancer/net/my-nlb-v3/eea5669793704be8

以下のようなシェルスクリプト (create-vpc-links.sh) を実装することで、各 NLB を使用して VPC リンクを作成できる

#!/bin/zsh

count=1
while read line
do
    aws apigateway create-vpc-link --name my-vpc-link-v$count --target-arns $line
    count=`echo "$count+1" | bc`
done < ./my-nlb-arn-list.txt

実行

sh create-vpc-links.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment