LoginSignup
1
0

LambdaのPublic IPの一覧がほしかったので、調べてみました。

リンク先の記事にあるように、
AWSのPublic IPの一覧は、下記のURLにjson形式で公開されています。

が、大方の予想通り、あまりにも巨大でブラウザで見るにはとてもつらいため
必要なデータだけ抽出するようなPythonスクリプトを作成しました。

import requests

REGION = "us-west-1"
SERVICE = "EC2"

ip_ranges = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json').json()['prefixes']

ips = [item['ip_prefix'] for item in ip_ranges if item["region"] == REGION and item["service"] == SERVICE]

print("データ数 = ",len(ips))

for ip in ips:
    print(str(ip), ",")

2行目、3行目で抽出したいリージョンとサービスを指定します。

ちなみにLambdaのPublic IPは、「EC2」のサービスとして含まれているとのことでした。
(EC2とLambdaはハードウェアリソース一緒なんかな。)


実行結果

$ python aws_ips.py 
データ数 =  47
192.31.212.0/24 ,
99.77.132.0/24 ,
64.252.118.0/24 ,
64.252.122.0/24 ,
(中略)
52.52.0.0/15 ,
208.78.134.0/24 ,
54.176.0.0/15 ,
52.94.248.128/28 ,

やったね!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0