{"id":21235,"date":"2015-06-19T15:34:30","date_gmt":"2015-06-19T10:04:30","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=21235"},"modified":"2015-06-19T15:34:30","modified_gmt":"2015-06-19T10:04:30","slug":"enable-switch-role-feature-to-access-multiple-aws-accounts","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/enable-switch-role-feature-to-access-multiple-aws-accounts\/","title":{"rendered":"Enable Switch Role feature to access Multiple AWS Accounts"},"content":{"rendered":"<p>Today we&#8217;re going to demonstrate the use of switch role feature that AWS has introduced a few months back. This feature enables an IAM user to use switch role directly in AWS Management Console to access resources across multiple AWS accounts.<\/p>\n<p>E.g Lets say an IAM user X of Account 1 wants to access resources associated with Account 2. In this scenario we&#8217;ll create an IAM role in Account 2 and allow Access to user X from Account 1.<\/p>\n<p><strong>Walkthrough<\/strong><\/p>\n<p>Let&#8217;s consider a scenario to implement this feature. Consider a user &#8220;foo&#8221; of Account 1 wants to access S3 resources owned by another account Account 2.<\/p>\n<p><span style=\"font-weight: bold;text-align: justify;color: #ff9900\">Step 1. Configure Account 2  <\/span><\/p>\n<p><strong>a) Create a role<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image1.jpg\" alt=\"image1\" width=\"616\" height=\"195\" class=\"alignnone size-full wp-image-21263\" \/><\/p>\n<p><strong>b) Select Role for Cross-Account Access<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image2.jpg\" alt=\"image2\" width=\"1025\" height=\"323\" class=\"alignnone size-full wp-image-21264\" \/><\/p>\n<p><strong>c) Provide Account number of user &#8220;foo&#8221; present in Account 1<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image3.jpg\" alt=\"image3\" width=\"569\" height=\"175\" class=\"alignnone size-full wp-image-21279\" \/><\/p>\n<p><strong>d) Attach a Policy to the above role<\/strong><br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image4.jpg\" alt=\"image4\" width=\"799\" height=\"230\" class=\"alignnone size-full wp-image-21280\" \/><\/p>\n<p><span style=\"font-weight: bold;text-align: justify;color: #ff9900\">Step 2. Configure Account 1 <\/span><\/p>\n<p>a) Attach the below policy to the user IAM &#8220;foo&#8221; in Account 1.<\/p>\n<p>[js]<\/p>\n<p>{<br \/>\n\t&quot;Version&quot;: &quot;2012-10-17&quot;,<br \/>\n\t&quot;Statement&quot;: {<br \/>\n\t\t&quot;Effect&quot;: &quot;Allow&quot;,<br \/>\n\t\t&quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br \/>\n\t\t&quot;Resource&quot;: &quot;Copy the ARN from role that we have created in Account 2&quot; \/\/<br \/>\n\t}<br \/>\n}<\/p>\n<p>[\/js]<\/p>\n<p>b) Now log in to AWS Management Console for Account 1 using IAM user &#8220;foo&#8221; and Click on Switch Role.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image7.jpg\" alt=\"image7\" width=\"400\" height=\"348\" class=\"alignnone size-full wp-image-21321\" \/><\/p>\n<p>c) This will redirect you to a page to provide the credentials for the Account 2. You need to enter the Account Number of Account 2 and the role you created in Step 1.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image8.jpg\" alt=\"image8\" width=\"1062\" height=\"374\" class=\"alignnone size-full wp-image-21322\" \/><\/p>\n<p>c) If everything works well, you will be redirected to Account 2 AWS Management Console and access the granted resources.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/image9.jpg\" alt=\"image9\" width=\"562\" height=\"318\" class=\"alignnone size-full wp-image-21323\" \/><\/p>\n<p>Leave a comment if you have any questions regarding this article.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;re going to demonstrate the use of switch role feature that AWS has introduced a few months back. This feature enables an IAM user to use switch role directly in AWS Management Console to access resources across multiple AWS accounts. E.g Lets say an IAM user X of Account 1 wants to access resources [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[1174],"tags":[248,1887,1888],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/21235"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=21235"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/21235\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=21235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=21235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=21235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}