Contents

Cloudformation Script for cross account role

Contents

A Seamless Guide to Cross-Account Role Access with AWS CloudFormation

Introduction:

In the world of AWS, managing multiple accounts efficiently is crucial for streamlined operations. Cross-account role access simplifies this by allowing seamless transitions between accounts. Here’s a step-by-step guide to setting up cross-account access using AWS CloudFormation.

Requirements:

  • CloudFormation Script: The heart of our setup, this script automates the creation of necessary resources.

  • Source Account Number: The AWS account from which you’ll initiate the cross-account access.

  • Role Name: The name of the IAM role to be created in the destination account.

Steps:

Step 1: Create Custom Policy in Source Account

  • Create a custom policy in the source account with STS full permissions.

  • Attach this policy to the IAM user(s) who will initiate the switch role process.

Step 2: Run CloudFormation Script

  • In the destination account, execute the CloudFormation script provided.

Step 3: Use Switch Role

  • Once the CloudFormation script successfully runs, switch to the destination account.

  • Open the AWS console, click on your username at the upper right-hand side, then select “Switch Role”.

https://github.com/yahyagulshan/linuxnotes/assets/59036269/63b55761-57af-4ec3-8253-e78f6df70f28

  • Enter the required details and click “Switch Role”.

https://github.com/yahyagulshan/linuxnotes/assets/59036269/309f2711-bf8b-4a3b-8e7b-217fc979d311

Step 4: Navigate to Destination Account

  • You are now in the destination account, ready to utilize its resources.

https://github.com/yahyagulshan/linuxnotes/assets/59036269/4dd88400-af7b-4612-be5d-eda4ed5385ae

Step 5: Switch Back to Source Account

  • To return to the source account, simply click on “Switch back”.

https://github.com/yahyagulshan/linuxnotes/assets/59036269/b5f4b491-1558-4b49-a385-3590cbec09cb

Access Resources:

  • For the CloudFormation template and the STS full permission policy, visit the GitHub repository below:

Access the GitHub repo here

  • With this setup, you can seamlessly navigate between accounts, leveraging resources where needed without compromise.

Conclusion:

AWS CloudFormation simplifies the setup of cross-account role access, offering a secure and efficient way to manage multiple AWS accounts. With this guide, you’re equipped to streamline your AWS operations, maximizing efficiency and security.