EC2インスタンスがSDB,S3のエンドポイントにアクセスできるか簡易チェック

#!/usr/bin/perl
use Socket;

print "Content-type: text/htmlnn";
print `curl -s http://169.254.169.254/latest/meta-data/instance-id` . "n";
print "<br />";
print `date`;
print "<br />Port check SimpleDB End point: ";
print IsPort(80, 'sdb.ap-northeast-1.amazonaws.com') && IsPort(443, 'sdb.ap-northeast-1.amazonaws.com')  ? "OK" : "NG";
print "n<br />Port check S3 End point: ";
print IsPort(80, 's3-ap-northeast-1.amazonaws.com') && IsPort(443, 's3-ap-northeast-1.amazonaws.com')  ? "OK" : "NG";