[AWSマイスターシリーズ]Identity and Access Management (IAM)
-
Upload
amazon-web-services-japan -
Category
Technology
-
view
7.240 -
download
7
description
Transcript of [AWSマイスターシリーズ]Identity and Access Management (IAM)
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
AWS マイスターシリーズ
AWS Identity and Access Management
2013.07.24
アマゾンデータサービスジャパン株式会社
ソリューションアーキテクト 片山 暁雄
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
2
アジェンダ
IAMの概要
IAMポリシー
IAMロール
AWS Security Token Service
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
3
アジェンダ
IAMの概要
IAMポリシー
IAMロール
AWS Security Token Service
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
4
AWS Identity and Access Management
AWS操作をよりセキュアに行うための認証・認可の仕組み
AWS利用者の認証と、アクセスポリシーを管理
AWS操作のためのグループ・ユーザーの作成が可能
グループ、ユーザーごとに、実行出来る操作を規定できる
ユーザーごとに認証情報の設定が可能
開発チーム 運用チーム
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
5
IAM動作イメージ APIやマネジメントコンソールからの
アクセスに対して、権限をチェック
全操作可能
S3はすべて操作可能
S3参照だけ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
6
IAM ユーザー
AWS操作用のユーザー • 1AWSアカウントで5000ユーザーまで作成可能
ユーザーごとに設定可能な情報 • ユーザー名
• IAMユーザーの識別と、マネジメントコンソールへのログインに使用
• 128文字までのアルファベット、数字、+=,.@-_
• パス(オプション) • ユーザーにオプションとしてセットできる情報
• パスを元にユーザーの検索が可能
• 組織階層やプロジェクトなどをセット 例)/aws/sa/
• 512文字までのBasic Latin文字(アルファベット、数字、!"#$%&'()=~|-^\@`{[}]*:+;?_)
• 開始と終了が/であること
• 所属グループ • 10のグループまで設定可能
• パーミッション • AWSサービスへのアクセス権限
• JSON形式でポリシーを記述 – 詳細は後述
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
7
IAM ユーザー
認証情報その1
アクセスキーID/シークレットアクセスキー
REST,Query形式のAPI利用時の認証に使用
2つまで生成可能
Active/Inactiveの切り替え
X.509 Certificate
SOAP形式のAPIリクエスト用
OpenSSLなどで証明書を作りアップロード
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
8
マネジメントコンソールへのログイン
IAMユーザーは、AWSアカウントごとに用意された専用URLからログイン
デフォルトは、URLにAWSアカウント名を入れたもの
「Account Alias」でユーザーフレンドリーな名前を指定可能
• ただしS3と同様早い者勝ち
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
9
IAM ユーザー
認証情報その2 AWSマネジメントコンソールへのログインパスワード
デフォルトは未設定(ログインできない) 128文字までのBasic Latin文字 パスワード変更時のポリシー設定が可能
AWSアカウントごとに設定 最低パスワード長、大文字小文字等
MFA(多要素認証) ハードウェアMFAと仮想MFAのいずれかを利用可能
• ハードウェアMFA – Gemalto社からAWS用のデバイスを購入 – http://onlinenoram.gemalto.com/
• 仮想MFA – スマートフォンやPCにインストール – Google Authenticatorなど、TOTP実装のソフトが利用可能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
10
IAM グループ
IAMユーザーをまとめるグループ
• 1AWSアカウントで100グループまで作成可能
グループに設定可能な情報
• グループ名
• グループの識別に使用
• パス(オプション)
• 組織階層などをセット 例)/aws/
• パーミッション
• グループに設定したパーミッションは、IAMユーザーに付与したパーミッションと同時に評価
• 評価方法は後述
Group
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
11
アジェンダ
IAMの概要
IAMポリシー
IAMロール
AWS Security Token Service
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
12
IAM ポリシー
AWSアクセスに対する権限設定
JSON形式のアクセスポリシー言語でアクセス条件を記述 • http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/AccessPolicyLanguage.html
{ "Statement { "Effect": "Allow", "Action": [ " s3:ListBuckets ", " s3:Get * " ], "Resource": [ " arn:aws:s3:::mybucket " ], "Condition": { "StringEquals": { "aws:SourceIP": [“176.32.92.49/32“] } } } ] }
このブロックを1条件として、アクセス権限をチェック
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
13
アクセス条件の記述
{ "Effect": "Allow", "Action": [ " s3:ListBuckets ", " s3:Get * " ], "Resource": [ "arn:aws:s3:::mybucket" ], "Condition": { "StringEquals": { "aws:SourceIP": [“176.32.92.49/32“] } } }
Effect: 許可の設定なら”Allow” 拒否の設定なら”Deny”
Action: 対象となるAWS操作を指定
Resource: 対象となるAWSリソースを指定
Condition: このアクセス制御が有効になる 条件の設定
この例の場合、 「アクセス元IPが176.32.92.49だったら、S3のListBucketsとGet系の操作を許可する」という意味
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
14
Action
「Action」は、操作自体に対する設定
ec2:runInstances
ec2:AttachVolume
s3:CreateBucket
s3:DeleteObject
ワイルドカード指定可能
例)ec2:Describe*
指定の操作以外の場合は「NotAction」を使用
例)“NotAction”: “iam:*” (IAMの操作以外を許可する)
"Action": [ " s3:ListBuckets", " s3:Get*" ]
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
15
Resource
「Resource」は操作対象に対する設定
EC2インスタンス
EBSボリューム
S3バケット
S3オブジェクト
ARN(Amazon Resource Name)で記述
“arn:aws:”で始まる文字列
arn:aws:service:region:account:resource
例) arn:aws:s3:::mybucket http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
指定リソース以外の場合は「NotResource」を使用
• 例) “NotResource” : “arn:aws:s3:::hoge”
"Resource": [ " arn:aws:s3:::mybucket" ]
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
16
AWSサービス Action Resource
IAM ○ ○
Amazon CloudFront ○
Amazon CloudWatch ○
AWS Data Pipeline ○
Amazon EC2 ○ ○
Amazon ElastiCache ○
Amazon Elastic MapReduce ○
Amazon Elastic Transcoder ○
Amazon RDS ○ ○
Amazon Route 53 ○ ○
Amazon S3 / Glacier ○ ○
Amazon Redshift ○
AWS OpsWorks
AWS Storage Gateway ○ ○
Amazon SimpleDB ○ ○
Amazon SES ○
Amazon DynamoDB ○ ○
Amazon SNS ○ ○
Amazon SQS ○ ○
Amazon VPC ○
Auto Scaling ○
AWS CloudFormation ○
AWS Elastic Beanstalk ○
Elastic Load Balancing ○
[NEW!]
EC2とRDSがResourceに対応
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
18
Amazon EC2のリソース指定
以下のリソースの指定が可能 • インスタンスID
• インスタンスプロファイル名
• プレースメントグループ名
• スナップショットID
• EBSボリュームID
リソース指定は以下のAction操作に限られる(2013/7現在)
• RebootInstances,StartInstances,StopInstances,TerminateInstaces
• AttachVolume,DeleteVolume,DetachVolume
• その他APIは順次対応
より詳細な条件(特定のタグのインスタンス等)については、Conditionで指定(後述)
"Resource": [ arn:aws:ec2:::instance/i-123abc" ]
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-policies-for-amazon-ec2.html
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ec2-api-permissions.html
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
19
Condition
Resourceに対するActionを許可(もしくは拒否)するかどうかの条件設定
ポリシー変数(条件キー)に対して、演算子を用いて条件を指定
http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/AccessPolicyLanguage_ElementDescriptions.html#Condition
"Condition": { "StringEquals": {"aws:SourceIP": “176.32.92.49/32“ } }
演算子 ポリシー変数 条件値
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
20
Conditionの演算子
文字列 • 完全一致、部分一致など
数値 • 一致、以上、以下など
日付および時間 • 一致、日付の後先など
ブール IP アドレス • 指定のアドレス、指定範囲など
Amazon リソース名 • 完全一致、部分一致など
...IfExists • 上記演算子に付与。変数がない場合無視
条件キーの有無 http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/AccessPolicyLanguage_ElementDescriptions.html#Condition
"Condition": { "StringEquals": {"aws:SourceIP": “176.32.92.49/32“} }
"Condition": { “streq": {"aws:SourceIP": “176.32.92.49/32“} }
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
21
ポリシー変数
全てのリクエストで利用できる変数 • aws:CurrentTime • aws:EpochTime • aws:principaltype • aws:SecureTransport • aws:SourceIp • aws:UserAgent • aws:userid • aws:username
AWSサービス固有の変数 • s3:prefix • sns:Protocol • ec2:ResourceTag/tag名 など
"Condition": { "StringEquals": {"aws:SourceIP": “176.32.92.49/32“} }
例えば、API呼び出し/コンソール利用を指定のIPアドレスだけに絞りたい場合に
利用
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
22
EC2リソース用のポリシー変数
ec2:AvailabilityZone
ec2:EbsOptimized
ec2:InstanceProfile
ec2:InstanceType
ec2:ParentSnapshot
ec2:PlacementGroup
ec2:Region
ec2:ResourceTag/tag-key
ec2:RootDeviceType
ec2:Tenancy
ec2:VolumeIops
ec2:VolumeSize
ec2:VolumeType
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-policies-for-amazon-ec2.html
2013/7現在
"Condition": { "StringEquals": {“ec2:ResourceTag/Name": “webserver“} }
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
23
複数Conditionの”OR”と”AND” "Condition" : {
"DateGreaterThan" : { "aws:CurrentTime" : "2013-07-16T12:00:00Z" }, "DateLessThan": { "aws:CurrentTime" : "2013-07-16T15:00:00Z" }, "IpAddress" : { "aws:SourceIp" : ["192.168.176.0/24","192.168.143.0/24"] } }
OR
AND
AND
Condition下のブロックはAND、演算子に対する値はOR
この例の場合、「2009/7/17の12:00から15:00の間に、ソースIP192.168.176.0/24もしくは192.168.143.0/24のネットワークからアクセスしたリクエスト」を意味する
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
24
IAMポリシージェネレーター
IAMのウィザード内、もしくは単体のサイトで利用可能
• http://awspolicygen.s3.amazonaws.com/policygen.html
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
25
IAMポリシーのサンプル(1)
{"Version":"2012-10-17", "Statement": [ { "Action": [ "ec2:CreateSnapshot", "ec2:DeleteSnapshot", "ec2:DescribeSnapshotAttribute", "ec2:DescribeSnapshots" ], "Effect": "Allow", "Resource": "*" } ] }
EBSバックアップのみ可能
Versionは付与しなければ、2012-10-17が自動的に追加
される
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
26
IAMポリシーのサンプル(2)
{ "Statement": [ { "Action": [ "ec2:PurchaseReservedInstancesOffering" ], "Effect": "Deny", "Resource": [ "*" ] } ] }
RI購入を禁止する
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
27
{"Version":"2012-10-17", "Statement": [ { "Sid": "AllowGroupToSeeBucketListInTheConsole", "Action": ["s3:ListAllMyBuckets", "s3:GetBucketLocation"], "Effect": "Allow", "Resource": ["arn:aws:s3:::*"] }, { "Sid": "AllowRootAndHomeListingOfCompanyBucket", "Action": ["s3:ListBucket"], "Effect": "Allow", "Resource": ["arn:aws:s3:::my-company"], "Condition":{"StringEquals":{"s3:prefix":["","home/"],"s3:delimiter":["/"]}} }, { "Sid": "AllowListingOfUserFolder", "Action": ["s3:ListBucket"], "Effect": "Allow", "Resource": ["arn:aws:s3:::my-company"], "Condition":{"StringLike":{"s3:prefix":["home/Bob/*"]}} }, { "Sid": "AllowAllS3ActionsInUserFolder", "Action":["s3:*"], "Effect":"Allow", "Resource": ["arn:aws:s3:::my-company/home/Bob/*"] } ] }
IAMポリシーのサンプル(3) “my-company”バケット以下の”home/Bob”以下のみ操作可能
Statementの中で複数ポリシーを書く場合は、Sidを他とかぶらないように設定
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
28
IAMポリシーのサンプル(4)
{"Version":"2012-10-17", "Statement": [ { "Sid": “StrictBucketLocation", "Action": ["s3:CreateBucket"], "Condition": { "StringEquals": { "s3:LocationConstraint": "ap-northeast-1" } }, "Resource": ["*"], "Effect": "Allow" }, { "Sid": "AllowListBucket", "Action": ["s3:ListAllMyBuckets", "s3:GetBucketLocation"], "Effect": "Allow", "Resource": ["arn:aws:s3:::*"] }] }
指定のリージョン以外でバケットを作成できない
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
29
IAMポリシーのサンプル(5)
{"Version": "2012-10-17", "Statement": [ { "Action": ["ec2:StartInstances“,"ec2:StopInstances"], "Resource": [ "arn:aws:ec2:*:*:instance/*" ], "Effect": "Allow", "Condition":{ "StringEquals":{ "ec2:ResourceTag/project":"myapp" } }] }
指定のタグ(キー:project,値:myapp)のついた インスタンスのみ起動/停止可能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
30
IAMポリシーのサンプル(6)
{ "Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action": "rds:CreateDBInstance",
"Resource":"arn:aws:rds:us-east-1:1234567890:db:test*",
"Condition":{"streq":{"rds:DatabaseEngine":"mysql"}},
"Condition":{"streq":{"rds:DatabaseClass": "db.t1.micro"}}
}] }
Mysqlかつt1.microで、“test”で始まる名前のRDSのみ作成可能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
31
サポートと請求画面へのアクセスポリシー
AWSサポートおよび費用請求画面にも、IAMユーザーでアクセス可能
サポートは、”support”のアクションを許可 • 使えなくしたい場合は、Denyを使用
費用請求画面は以下の手順で設定 • ルートアカウントでログインして、セキュリティ質問を設定
• 費用請求画面へのアクセスをアクティブ化
• IAMユーザーに”aws-portal”のアクションを許可
https://aws.amazon.com/jp/premiumsupport/iam/
http://docs.aws.amazon.com/ja_jp/IAM/latest/UserGuide/ControllingAccessWebsite.html
{“Statement”: [{ “Action”: [ “support:*” ], “Effect”: “Allow”, “Resource”: “*” }] }
{"Statement":[{ "Effect":"Allow", "Action": [ "aws-portal:ViewBilling", "aws-portal:ViewUsage"] "Resource":"*" }] }
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
32
ユーザーのStatement ユーザーのStatement
アクセス可否の決定ロジック
アクセス制御の条件は複数設定可能 • ユーザー・グループごとに複数。相反する条件の設定も可能
すべてのアクセスはデフォルトで拒否(デフォルトDeny) • アクセス権限に“Allow”の条件があった場合、アクセス許可
• ただしアクセス権限に1つでも“Deny”の条件があった場合、アクセス拒否(明示的なDeny)
• デフォルトDeny < Allow < 明示的なDeny
グループのStatement
Allow
該当なし
(デフォルトDeny)
結果:Allow
Allow
Allow
結果:Deny
グループのStatement
Deny
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
33
ポリシー適用状態のテスト方法
コマンドラインツール実行時に“--auth-dry-run”と付けることで、実際のサービスを動かす事無く、操作の実行可否の確認が可能
ec2-delete-snapshot snap-xxxxxx --auth-dry-run
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
34
ユーザーベースとリソースベース
ポリシーは、ユーザーやグループ以外に、リソースにも紐付け可能
S3バケット、SQSのキューなどに対してポリシーが適用可能 • 「特定のIPアドレスからしかアクセスできないバケット」などの設
定が可能
ユーザーベース
リソースベース
片山 平山 げんた
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
35
IAMのクロスアカウントアクセス
AWSアカウントを超したアクセス許可 • S3,SQS,SNSなどで利用可能
{ "Statement" : { "Effect":"Allow", "Principal" : { “AWS”:“arn:aws:iam::Account Bの番号:root" }, "Action":"s3:*", "Resource":"arn:aws:s3:::mybucket/*" } }
1.Account Aのバケットに以下のポリシーを設定
2.Account Bに、mybucketへアクセス権限付与
Principalは、実行をしているユーザーに
対する条件設定
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
36
ポリシーの文字数制限
IAMユーザー
• 付与したすべてのポリシーの文字数合計が2,048文字以下
IAMグループ
• 付与したすべてのポリシーの文字数合計が5,120文字以下
IAMロール
• 付与したすべてのポリシーの文字数合計が10,240文字以下
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
37
アジェンダ
IAMの概要
IAMポリシー
IAMロール
AWS Security Token Service
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
38
IAMロールとは?
AWSサービスやアプリケーション等、エンティティに対してAWS操作権限を付与するための仕組み • 例えば実行するアプリケーションにロールを付与する事で、そのアプ
リケーションからAWSを操作出来るようになる
IAMユーザーやグループには紐付かない
設定項目は、ロール名とIAMポリシー
• 最大10,240文字のポリシーが設定可能
EC2ほか、Beanstalk,Data Pipelineなどでも利用
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
39
IAM Role for EC2 instances
プログラム
EC2インスタンスに、指定のロールを付与する機能 EC2起動時にロールを指定すると、認証情報がメタデータに設定される
認証情報はSTS(Security Token Service)で生成
• インスタンス毎に異なるキー
• 有効期限付きで、期限が来るとローテート
アプリケーションから認証情報を取得し、AWSサービスへアクセス • インスタンス内からメタデータにアクセス
• アクセスキーID、シークレットアクセスキー、セッショントークンを取得
• 3つの認証情報でAPI呼び出し
IAM Role
メタデータ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
40
メタデータからの認証情報取得
curl http://169.254.169.254/latest/meta-data/iam/security-credentials/noble
{
"Code" : "Success",
"LastUpdated" : "2012-08-05T13:45:07Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "ASIAJNTWXXXXXXXXX",
"SecretAccessKey" : "zcwQRooukT3jOL9F+4/XXXXXXXXXXXXXXXXXX",
“Token” : “AQoDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"Expiration" : "2012-08-05T20:10:42Z"
Role名
STSのセッショントークン
有効期限
IAM Roleを設定したEC2インスタンス内から取得
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
41
IAMユーザー利用との比較
プログラム
IAM Role
メタデータ
プログラム
メタデータ
IAMロールを利用する事で、インスタンスと鍵管理を分離し、管理の簡素化とキーローテートによる、よりセキュアな運用が可能に
IAMユーザー利用 IAMロール利用
認証情報の 埋め込み
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
42
AWSCredentials credentials = new BasicAWSCredentials(“アクセスキー”,”シークレットキーID”); AmazonEC2 ec2 = new AmazonEC2Client(credentials);” ec2.describeInstances();
AWS SDKを利用する場合、認証情報取得と有効期限切れ前の再取得を自動的に実施可能
aws-cliはIAM Roleに対応済み
• http://aws.amazon.com/jp/cli/
AmazonEC2 ec2 = new AmazonEC2Client();” ec2.describeInstances();
IAM Role利用後
IAM Role適用のインスタンス上では、認証情報の設定が不要
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
43
IAMロールのクロスアカウントアクセス
あるアカウントのIAMロールを、別のアカウントのIAMロールに紐づける機能
例えば開発アカウントを使って、本番環境のS3データを更新するようなケースで利用
http://docs.aws.amazon.com/IAM/latest/UserGuide/cross-acct-access.html
開発アカウント用
ロール
本番アカウント 開発アカウント
AssumeRole
認証情報
開発者アカウント用ロールの
権限でアクセス
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
44
アジェンダ
IAMの概要
IAMポリシー
IAMロール
AWS Security Token Service
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
45
AWS Security Token Service(STS)
一時的に利用するトークンを発行するサービス
動的にIAMユーザーを作成し、ポリシーを適用できる
• STSはユーザー数制限なし
IAM Role for EC2は、このSTSを利用
• Assume Role
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
46
Identity Federation
企業・組織の認証機能と、AWSの認証を紐づける機能
例えばLDAP認証したユーザーに対してS3のアクセス権をつける、といった連携が可能
認証したユーザーごとにTemporary Security Credentials(一時的なアクセスキー)を発行
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
47
Temporary Security Credentials
AWSに対する、一時的な認証情報を作成する仕組み • 期限付きの認証情報(認証チケット)
ユーザーに対して、以下の3つのキーを発行 アクセスキー(ASIAJTNDEWXXXXXXX) シークレットアクセスキー(HQUdrMFbMpOHJ3d+Y49SOXXXXXXX) セッショントークン
(AQoDYXdzEHQakAOAEHxwpf/ozF73gmp9vZDWDPkgFnzwSG/3ztBw9Z4IUslNNn503+3SeN0nwI3wcdLR8y8Ulv9cnksMrBGjRVrJl2xg+/CRnI9nJ1tteHp6yso3sP0BVvnxLpNwyIUpHrcTHt+8v2P6Y9/VX2zl8Hc/cy6La0r1/GuiHb9NEwqt6VIgjPWCZzHXzX8XsUObKhMnAUkY2IdTMrNKXcqVk8VbC6BNTqWsMIIfQPz9fDjKK1ifAFmHVSWvUxio94n+ebXXpy1NuHnt5JEGV34VPLMsrpZ86b+eulKNE1suoQ8TM5E1O66rYwizkq6w+cJovUnMxg6ESASBvolsrEioLiP+SE7cX1i8gRrSG9/KT59GYTlhTzStjjFroCAqZu4KYplGUMCDl1g0twrdXeymsu3GG70Qwu0wSi3WjkW8VPiajahJXCEgp6gIgXElwkrBO01H5Y9NNDEyQaq8ocOGBPVRu+DS9LMs9SHASXimnnVeIN+1FVkXXXXXXXXXXXXXXXXXXXXXXXX)
作成した認証情報の有効期限設定が可能 デフォルト12時間 最小1時間 最大36時間 発行したチケットは延長や期間短縮は出来ない 即座にアクセス制御したい場合は、発行に使用したIAMユーザーやIAMロールの権限を変更
する
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
48
IAMユーザー AWS Account’s Access Key ID
Temporary Security
Credentials
ホテルに例えると・・・
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
49
AWS アカウント
IAMユーザー
Temporary Security
Credentials
IAMの権限階層
Permissions Example
すべての操作が可能 Action: * Effect: Allow Resource: * (implicit)
ユーザーやグループに対して割り当てられた権限
Action: [‘s3:*’, ‘sts:Get*’] Effect: Allow Resource: *
トークン作成時に決定される
Action: [ ‘s3:Get*’ ] Effect: Allow Resource: ‘arn:aws:s3:::mybucket/*’
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
50
ユースケース
モバイルアプリケーション • システムログインしたモバイルアプリユーザーごとにテンポラリの認
証情報を作成
• モバイルから直接S3にアップロード可能
• 有効期限があるため、セキュア
• 数千数万のユーザーに対応
一時的なアクセス権限の譲渡 • 一時的にS3へアップロード出来るようなアプリケーションの作成
• 一時的にEC2を起動できるような仕組みの構築
組織ユーザー毎のアクセス制御 • ユーザーごとに利用できるS3バケットの作成
• ユーザーごとにIAMユーザーを作る必要がない
• 組織のグループに紐づけてアクセス制御を実施
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
51
動作イメージ(1)
Webアプリケーションで利用するケース
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
52
動作イメージ2
モバイルやクライアントアプリケーションで利用するケース
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
53
Federated Users Direct Access to the AWS Management Console
STSを使用して、マネジメントコンソールへのログインを実行できる機能
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
54
Federated Users Direct Access to the AWS Management Console
トークン暗号化サービスのURLへアクセス
• 指定のURLに、STSの認証情報をJSONで付与
• https://signin.aws.amazon.com/federation?Action=getSigninToken&SessionType=json&Session={“sessionId”:” STSのAccessId”, ”sessionKey”:” STSのSecretAccessId”, “sessionToken”:”STSのセッショントークン”}
• 暗号化されたトークンが取得可能
ログインURL • https://signin.aws.amazon.com/federation?Action=login&SigninT
oken=暗号化トークン&Destination=マネジメントコンソールURL
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
55
Assume Role with Web Identity
ソーシャルサービスの認証を元に、AWSへのアクセスキーを発行するサービス
ソーシャルサービス認証を確認するサーバが不要 • 例えばスマートフォンアプリとS3だけでシステムが作成可能
現在Google,Facebook,Amazon(Login with Amazon)に対応
IAM Roleを使用して実現
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
56
Assume Role with Web Identity
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
57
Facebookにアプリケーションを登録 • https://developers.facebook.com/docs/plugins/registration/
利用手順1(例:Facebook)
http://docs.aws.amazon.com/STS/latest/UsingSTS/CreatingWIF.html
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
58
IAMロールを作成
利用手順2(例:Facebook)
ロール名
Role for Web Identity Providor
FacebookのアプリケーションID
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
59
IAMロールに、ポリシーを適用
• ポリシー内で、変数を利用してユーザーごとのアクセスポリシーを作成
利用手順3(例:Facebook)
{ "Version":"2012-10-17",
"Statement":[
{ "Effect":"Allow",
"Action":["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
"Resource":[
"arn:aws:s3:::myBucket/myApp/${graph.facebook.com:id}",
"arn:aws:s3:::myBucket/myApp/${graph.facebook.com:id}/*“
]
} ]
} Facebookにログインした ユーザーのIDが入る
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
60
アプリケーションから直接STSにアクセス • ソーシャルサービスのログイントークン • アプリケーションID • IAMロールのARN(arn:aws:iam::AWSアカウントID:role/IAMロール名)
利用手順4(例:Facebook)
// SecurityTokenのクライアント Anonymousで作成
AWSSecurityTokenService sts
= new AWSSecurityTokenServiceClient(new AnonymousAWSCredentials());
AssumeRoleWithWebIdentityRequest request
= new AssumeRoleWithWebIdentityRequest();
request.setProviderId(フェースブックのアプリケーションID);
request.setWebIdentityToken(Facebookのログイントークン);
request.setRoleArn(IAMロールのARN);
request.setRoleSessionName(“FB”);//任意の文字列
AssumeRoleWithWebIdentityResult result =
sts.assumeRoleWithWebIdentity(request);
//resultから、STS発行のアクセスキー、シークレットアクセスキー、セッショントークが取れる
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
61
WebIdentityFederationSessionCredentialsProviderを使用すると、タイムアウト時の再取得など行える
Tips:簡易アクセス用クラス
WebIdentityFederationSessionCredentialsProvider provider = new WebIdentityFederationSessionCredentialsProvider( Facebookのログイントークン, フェースブックのアプリケーションID,IAMロールのARN); AmazonS3 s3 = new AmazonS3Client(provider);
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
62
STS対応サービス
Amazon CloudWatch Amazon DynamoDB Amazon Elastic Compute Cloud Amazon Glacier Amazon Relational Database Service Amazon Simple Storage Service Amazon Simple Notification Service Amazon Simple Queue Service Amazon Simple Workflow Service Amazon Virtual Private Cloud AWS Identity and Access Management AWS Security Token Service Auto Scaling Elastic Load Balancing
2013/07現在
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
63
アジェンダ
IAMの概要
IAMポリシー
IAMロール
AWS Security Token Service
まとめ
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
64
まとめ
IAMを利用することで、よりセキュアで安全にAWSサービス群を利用できます
• 制限をかけることで、セキュリティだけでなく、オペレーションミスも低減できます
STSをうまく利用すると、AWSサービスをアプリケーションやモバイルから直接扱えます
• サーバコストの削減が可能
IAM自体には利用料が必要ありません
• 積極的に活用を!
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
65
追加のリソース
IAMドキュメント群
• http://aws.amazon.com/jp/documentation/iam/
IAMベストプラクティス
• http://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPractices.html
AWS Security Blog
• http://blogs.aws.amazon.com/security/
© 2012 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified or distributed in whole or in part without the express consent of Amazon.com, Inc.
66
ご参加ありがとう ございました。