IAMユーザの作成
AWSコンソールからIAMユーザを作成する。
今回の例では、AmazonS3ReadOnlyAccessポリシーをアタッチしておく。
接続確認
コマンドラインからprofileを設定
$ aws configure --profile test-user
S3にアクセスしてみる。
$ aws --profile test-user s3 ls 2016-02-20 15:50:19 xxxxxxxxxxxxx 2016-02-20 16:10:29 yyyyyyyyyyyyy
IPアドレス制限をかける
AmazonS3ReadOnlyAccessをコピーして以下のようなポリシーを作る。(xx.xx.xx.xxのところは自分のIPアドレスを入れる){
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": "*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"xx.xx.xx.xx/32"
]
}
}
}
]
}
AmazonS3ReadOnlyAccessをデタッチして、上記で作成したポリシーを代わりにアタッチする。
指定したアドレスから接続確認
S3にアクセスできることを確認。$ aws --profile test-user s3 ls 2016-02-20 15:50:19 xxxxxxxxxxxxx 2016-02-20 16:10:29 yyyyyyyyyyyyy
指定したアドレス以外から接続
S3にアクセスできないことを確認。$ aws --profile test-user s3 ls A client error (AccessDenied) occurred when calling the ListBuckets operation: Access Denied
初めまして。
返信削除AWS、便利ですよね。