I was trying to assume an IAM role with the AWS CLI, but I missed setting it up right in the prerequisites. Make sure to check that first, then move forward.
-
AWS CLI Setup: Ensure the AWS CLI is installed and configured with your credentials.
-
IAM Role Configuration: The role must exist with a trust policy allowing your user to assume it and appropriate permissions attached to it.
-
Permission Checks: Your IAM user or group must have sts: AssumeRole permission, and the role must have the necessary policies for the actions you need to perform.
Follow these steps to Assume an IAM Role:
-
To create your IAM policy, run the command and Make sure to replace policy.json with the path to your policy document. ![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXffHt6YCjSZg1dD_wlRrwQU3mM5kjki_gaz_pTDhX44ZnslceSVdb3E9A9T69I907d0S-K8NhMRUUO6EjsAr-YfbpnnOLbsvPa-S6-qzdpWPf2sl5iC7TywRMDWaRPVbOTVF2KpntOXAh0dw6aJrAz_OgA?key=yoX2iRIeULeNwFB7S9Y6IF9I)
-
Find the ARN of the IAM role you want to use. It looks like this:
![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcgRvnbS73pQFjGTygYpc4qwfIDcTzxF8IPfhaD8wMPXDCYysXjNOjDc2PFZ4ucxHnMApfrnCmDpWjvLIpBc_BmON21csgngLvtwnW2McWFXT5yiHL3EiqFTCBOcFlhwgIY1j0DZEkTYNtGQl0KNhe_KJy1?key=yoX2iRIeULeNwFB7S9Y6IF9I)
![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXdej846nl6oxXOgNWwqzD2s0d_sKrPjPkePil4PHjtVsV3nRwoMhwCDLxCHWWhhR5pHL-UhJFR_8EHGFbvz53PZBt7oRh8TPDBCcFlXvhJ4E9sMJr-YGGeCTiBnois9_s5x4a5lAGgsDyWo0qW-ji8WX3A?key=yoX2iRIeULeNwFB7S9Y6IF9I)
![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeXn2WV3IioJX-s9-OiCde9WH089D0Faez42dqaYtp1cJF_hxq9dM6VHZ2fQUv_xWXPZz_g-Wm4YZpmzWAlj_9k3a91EChArOr03U72BZiPCtqn-_zRJZXnuRPwStkHhcFxodpTocNTs8IUfXh-SNew0EeX?key=yoX2iRIeULeNwFB7S9Y6IF9I)
Replace <account-id> and <role-name> with your role's details and <session-name> with a name for your session (this can be any identifier).
![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXfPFBCh6kib-JOaGh6LHKXqnI6LrlBl6AhgXbYKQ5GYafHavTBoMAKq-98IuUOnVtbuuoG89lhQqx1-EXqMJKWLivVZlsT3oCHnjrAjmX5egIGr4NGEbNmh8sOcRC0wB8MJLBMYGugqir8W7eiVYyxjfNdz?key=yoX2iRIeULeNwFB7S9Y6IF9I)
![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXe3GVQvSiy55sR2Z94HRASEqmh9hBnLNN3lFQTGGZe4hVX03LrV8KhKj1w-sgKlpXTkX-A6ApsJzbtLO_yarzCr69wbbRubPWPXorhPtEAP1bGYOGJIMfBO6_6cljKxcxBXq8GGDTWah745gVvj6gy9UGQ-?key=yoX2iRIeULeNwFB7S9Y6IF9I)
![image](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcplJ_IWFeOnwuXQfXgRPgQD_qttY6ipvRPvrkwdakwjIs6BPAr0kufobHMGE7TOa6LDbgP-Lbk2ujEJX4eJCPWSEYq4hHhSlcD8bWvobgBOtebjSRkPi0f6tNr8vH0M9ZNJU9aF5UZAp_xtYTakjCGDpIj?key=yoX2iRIeULeNwFB7S9Y6IF9I)