<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Vincent Tjianattan]]></title><description><![CDATA[Vincent Tjianattan]]></description><link>https://vincenttjia.com</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1697341694186/N6Xa21v9k.png</url><title>Vincent Tjianattan</title><link>https://vincenttjia.com</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 17:36:50 GMT</lastBuildDate><atom:link href="https://vincenttjia.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[AWS temporary credential best practice for developer access - console setup]]></title><description><![CDATA[Background
I've seen numerous posts on Reddit about people getting hacked or their access keys leaked. So I started this blog to address the gap in the issue. While AWS launched AWS SSO in 2017, not a lot of people are aware of it and most of the tim...]]></description><link>https://vincenttjia.com/aws-temporary-credential-best-practice-for-developer-access-console-setup</link><guid isPermaLink="true">https://vincenttjia.com/aws-temporary-credential-best-practice-for-developer-access-console-setup</guid><category><![CDATA[AWS SSO]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Vincent Tjianattan]]></dc:creator><pubDate>Sun, 15 Oct 2023 08:32:51 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-background">Background</h1>
<p>I've seen <a target="_blank" href="https://www.reddit.com/r/aws/search/?q=account%20hacked&amp;restrict_sr=1">numerous posts on Reddit</a> about people getting hacked or their access keys leaked. So I started this blog to address the gap in the issue. While AWS launched AWS SSO in 2017, not a lot of people are aware of it and most of the time people still resort to using IAM Users or worse the root account for day to day operations.</p>
<p>Do note that this just improves security, making it harder for attackers to get access and is <strong>not</strong> a foolproof method to make your account unhackable. You can still get hacked in numerous ways like exposing your access key(it will still be valid up to 1 hour after you first generated it, if you use the default value) or setting a weak root/sso user password with no MFA and many more like granting a random person IAM role access etc. The attack surface is limitless so please still be careful.</p>
<p>Let's start, I am unsure of the level of this blog. But personally, I would put it at level 200.</p>
<p>If you want a semi-automated setup with terraform script, please refer to <a target="_blank" href="https://vincenttjia.com/aws-temporary-credential-best-practice-for-developer-access">this blog post</a></p>
<h1 id="heading-prerequisite">Prerequisite</h1>
<ul>
<li>an AWS Account</li>
</ul>
<h1 id="heading-steps">Steps</h1>
<h3 id="heading-initial-setup">Initial setup</h3>
<p>Go to <a target="_blank" href="https://console.aws.amazon.com/singlesignon/home">https://console.aws.amazon.com/singlesignon/home</a> on your AWS console then make sure that you have chosen the AWS region that is closest to you, for this example, I will be using the ap-southeast-1 region.</p>
<p>Go ahead and click <code>Enable</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697297537622/d8f1af98-79f4-428c-9340-eacdfe994a8b.png" alt class="image--center mx-auto" /></p>
<p>Depending on whether you have enabled AWS Organization or not. You may or may not get this message. But if you do, click on <code>Create AWS organization</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697297667477/d2227579-e203-4513-bbc9-be32d07ea77d.png" alt class="image--center mx-auto" /></p>
<p>Before continuing to create users, groups and permission sets. You will need to define some setup through the console. Unfortunately at the time of writing this blog AWS did not provide any API to enable these settings, so these steps must be done manually, I will probably be updating this guide when it's available.</p>
<p>On your IAM Identity Center dashboard, click on <code>settings</code> on the left navigation bar</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301150561/24501502-958e-4123-a826-6f7caa2c7d4f.png" alt class="image--center mx-auto" /></p>
<p>Click on Authentication</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301229345/bed6c381-f166-47df-a4fa-6241b058bd16.png" alt class="image--center mx-auto" /></p>
<p>Click <code>Configure</code> on <strong>Standard authentication</strong> and then check the box on <code>Send email OTP</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301295944/3548564d-adb5-44fb-9e46-851b13e06c98.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301367342/4b133229-d68d-4acf-8889-5d0b9186ced4.png" alt class="image--center mx-auto" /></p>
<p>Next click <code>Configure</code> on <strong>Multi-factor Authentication</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301433766/c94c2f4e-ca4e-4fd5-a63d-3642f22e706f.png" alt class="image--center mx-auto" /></p>
<p>You can choose to be creative on this screen, but I would strongly advise that you copy the settings on the screen for maximum security. But you can be flexible between context-aware and always-on, as with anything on security, there's always a tradeoff between more secure and more comfortable, the more comfortable you are the less secure it is like not enforcing MFA.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301503530/59370495-ffcd-4f59-b7d4-a3cd7786caac.png" alt class="image--center mx-auto" /></p>
<p>Note: to improve security even further, you can even choose to disable Authenticator apps and only enable Security keys if you have hardware devices such as Yubikey. But I will take the most common use-case and allow virtual authenticator</p>
<h3 id="heading-creating-permission-sets-and-groups">Creating permission sets and groups</h3>
<p>Now comes the fun part setting up your users and permissions</p>
<p>Go to <a target="_blank" href="https://ap-southeast-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#!/accounts/permissionSets">https://ap-southeast-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#!/accounts/permissionSets</a></p>
<p>Click on <code>Create permission set</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697357522732/e66ce3d3-2889-4015-9647-1110d587ae97.png" alt class="image--center mx-auto" /></p>
<p>You can choose on one of the predefined permission set or create your own custom. But for this example I will be using the AdministratorAccess predefined permission set</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697357553812/115c083e-a5d5-443f-81f6-6f384204ab8c.png" alt class="image--center mx-auto" /></p>
<p>Click on next</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697357605096/558ce7a1-ade1-40a2-83f6-391b47728aa8.png" alt class="image--center mx-auto" /></p>
<p>Feel free to fill it in or just leave it as the default value, both work. Then hit <code>next</code> and then hit <code>create</code> after you review that the information is correct.</p>
<p>Next go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#/groups">https://us-east-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#/groups</a></p>
<p>Create a group with the name of your permission sets with the accountId/accountAlias</p>
<p>Example AdministratorAccess-123456789012</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697357971310/61666a9c-6550-4823-bff9-282e89ab52a1.png" alt class="image--center mx-auto" /></p>
<p>Go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/iamv2/home?region=ap-southeast-1#/organization/accounts">https://us-east-1.console.aws.amazon.com/iamv2/home?region=ap-southeast-1#/organization/accounts</a></p>
<p>Check the box for your AWS account and then click on <code>Assign users or groups</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697358097574/be8bd73c-02f9-440d-bc40-6dbb759f4955.png" alt class="image--center mx-auto" /></p>
<p>Check the box the group that we created earlier, then hit <code>Next</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697358147872/0f897cbc-c1c1-447d-b69d-e34c69280cdd.png" alt class="image--center mx-auto" /></p>
<p>Same goes for the permission sets and hit <code>Next</code> and <code>Submit</code> once you reviewed that the information is correct.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697358195585/6c9059a4-a9c6-4d3f-9bce-a6c521ca3fba.png" alt class="image--center mx-auto" /></p>
<p>Repeat the steps above for all the permission set you want to create</p>
<h3 id="heading-creating-the-users-and-assigning-them-permissions">Creating the users and assigning them permissions</h3>
<p>Next go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#/users">https://us-east-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#/users</a></p>
<p>Click on <code>Add users</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697357725071/2bfd53be-fb3d-415b-8b83-47f191e806e6.png" alt class="image--center mx-auto" /></p>
<p>Fill in the details of user that you want to create, then hit <code>Next</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697357826598/0b949de8-5753-49ca-9fec-0d5c81b7241c.png" alt class="image--center mx-auto" /></p>
<p>Assign the users to the groups that you have created, then hit <code>Next</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697358254107/b85d83d3-a9e9-46e8-bef8-707f79befcb3.png" alt class="image--center mx-auto" /></p>
<p>Review the info then click on <code>Add user</code></p>
<h3 id="heading-account-setup">Account Setup</h3>
<p>Check the email that you have provided on the users, you should see an email similar to this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697358469206/74ab55a8-0127-488e-a3ea-4522e825e8ee.png" alt class="image--center mx-auto" /></p>
<p>If for any reasons you did not receive the email, you can go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#/users">https://us-east-1.console.aws.amazon.com/singlesignon/home?region=ap-southeast-1#/users</a>, click on the user and on the top of the page click on <code>Send email verification link</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697358602434/e46c25c0-e007-4315-8965-a7d0f012a352.png" alt class="image--center mx-auto" /></p>
<p>Continue through the setup, by setting up your password and MFA.</p>
<p>Now, you should now be arriving at this page</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697305332371/2420d98d-7fb6-43a6-bb12-74acb5468a46.png" alt class="image--center mx-auto" /></p>
<p>Now that you have confirmed that you have access, we can start on setting up your temporary credential on the cli.</p>
<pre><code class="lang-bash">aws configure sso
</code></pre>
<pre><code class="lang-bash">SSO session name (Recommended): &lt;You can choose any&gt;
SSO start URL [None]: &lt;Use the url from earlier&gt;
SSO region [None]: &lt;The region that was used earlier&gt;
SSO registration scopes [sso:account:access]: &lt;Just leave blank and hit enter&gt;
</code></pre>
<p>Example</p>
<pre><code class="lang-bash">SSO session name (Recommended): personal
SSO start URL [None]: https://d-1234acd5.awsapps.com/start/
SSO region [None]: ap-southeast-1
SSO registration scopes [sso:account:access]:
</code></pre>
<p>Confirm and continue, then allow it</p>
<pre><code class="lang-plaintext">CLI default client Region [ap-southeast-1]: &lt;Use which ever region best for you&gt;
CLI default output format [None]: &lt;Use which ever format best for you&gt;
CLI profile name [SuperAdmin-198266650228]: default
</code></pre>
<p>Example</p>
<pre><code class="lang-bash">CLI default client Region [ap-southeast-1]: ap-southeast-1
CLI default output format [None]: json
CLI profile name [SuperAdmin-198266650228]: default
</code></pre>
<p>Note: only use the profile default if you only have 1 credential, if you have multiple like SuperAdmin, PowerUser etc. You can separate their naming and pass the <code>--profile</code> parameter every time you want to use them</p>
<p>Now you should be able to use temporary credentials on your terminal and periodically run <code>aws sso login</code> when your session runs out</p>
<pre><code class="lang-plaintext">aws sso login
</code></pre>
<h2 id="heading-cleanupimportant">Cleanup(important)</h2>
<h3 id="heading-cleanup-on-the-root-account">Cleanup on the root account</h3>
<p>Now that everything is done, there are a few cleanup that we need to do</p>
<p>Go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/iam/home#/security_credential">https://us-east-1.console.aws.amazon.com/iam/home#/security_credential</a></p>
<p>Delete any root access keys that you might have found here. But, before deleting other access keys be sure that you are not using them for anything else or stuff will break.</p>
<p>Secondly, generate a strong password using your password manager for your root account and don't forget to set up MFA to make sure that the root account is never compromised. I would suggest at least a 128-character password with a letter, number and symbol.</p>
<p>There are 2 approaches that you can use, you can store the password in your password manager if you ever need to use the root account in the future or you can choose not to store it and just request a password reset anytime you need to access the root account. This needs to be taken with a grain of salt as you will need to secure and maintain access to the email that is associated with the root account as well.</p>
<p>Ideally, it should look like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306143392/83055416-3ccd-4fc2-93d6-c98a3dedc0d0.png" alt class="image--center mx-auto" /></p>
<p>Lastly, as root, you would want to give access to Billing for yourself</p>
<p>Go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/billing/home#/account">https://us-east-1.console.aws.amazon.com/billing/home#/account</a></p>
<p>then scroll down until you find <strong>IAM user and role access to Billing information</strong> edit it and activate IAM access</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306541994/14aa593c-e1a8-4539-b4d7-25011827d87d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-cleanup-on-iam-users">Cleanup on IAM Users</h3>
<p>Delete all existing IAM users on your account, but before deleting please be sure that you have re-created the user in IAM Identity Center, assigned the correct permission and you have communicated it clearly to the affected user the new method to login and assume cli access.</p>
<h2 id="heading-nice-to-have">Nice to have</h2>
<h3 id="heading-custom-domain">Custom domain</h3>
<p>You can set a custom domain for your AWS SSO login portal</p>
<p>Go to the settings page we visited earlier from <a target="_blank" href="https://ap-southeast-1.console.aws.amazon.com/singlesignon/home">https://ap-southeast-1.console.aws.amazon.com/singlesignon/home</a> -&gt; Scroll down to Identity Source -&gt; Actions -&gt; Customize AWS access portal URL</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306748795/e4fba541-0836-4688-905b-647f50cd5f38.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-troubleshooting">Troubleshooting</h1>
<h3 id="heading-running-issue-into-assuming-different-profiles">Running issue into assuming different profiles</h3>
<p>If you only used the <code>default</code> profile you will not be running into this issue. But if you set up multiple profiles you might have issues such as running the terraform version before 0.12</p>
<p>I would suggest you install <a target="_blank" href="https://docs.commonfate.io/granted/getting-started/">Granted-cli</a> and then you can just do</p>
<pre><code class="lang-bash">assume profileName
</code></pre>
]]></content:encoded></item><item><title><![CDATA[AWS temporary credential best practice for developer access]]></title><description><![CDATA[Background
I've seen numerous posts on Reddit about people getting hacked or their access keys leaked. So I started this blog to address the gap in the issue. While AWS launched AWS SSO in 2017, not a lot of people are aware of it and most of the tim...]]></description><link>https://vincenttjia.com/aws-temporary-credential-best-practice-for-developer-access</link><guid isPermaLink="true">https://vincenttjia.com/aws-temporary-credential-best-practice-for-developer-access</guid><category><![CDATA[AWS]]></category><category><![CDATA[AWS SSO]]></category><category><![CDATA[Terraform]]></category><dc:creator><![CDATA[Vincent Tjianattan]]></dc:creator><pubDate>Sun, 15 Oct 2023 03:25:11 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-background">Background</h1>
<p>I've seen <a target="_blank" href="https://www.reddit.com/r/aws/search/?q=account%20hacked&amp;restrict_sr=1">numerous posts on Reddit</a> about people getting hacked or their access keys leaked. So I started this blog to address the gap in the issue. While AWS launched AWS SSO in 2017, not a lot of people are aware of it and most of the time people still resort to using IAM Users or worse the root account for day to day operations.</p>
<p>Do note that this just improves security, making it harder for attackers to get access and is <strong>not</strong> a foolproof method to make your account unhackable. You can still get hacked in numerous ways like exposing your access key(it will still be valid up to 1 hour after you first generated it, if you use the default value) or setting a weak root/sso user password with no MFA and many more like granting a random person IAM role access etc. The attack surface is limitless so please still be careful.</p>
<p>Let's start, I am unsure of the level of this blog. But personally, I would put it at level 200.</p>
<p>If you want to setup without the need to install terraform, please refer to <a target="_blank" href="https://vincenttjia.com/aws-temporary-credential-best-practice-for-developer-access-console-setup">this blog post</a></p>
<h1 id="heading-prerequisite">Prerequisite</h1>
<ul>
<li><p>an AWS Account</p>
</li>
<li><p>Terraform installed -&gt; If not yet you can use <a target="_blank" href="https://github.com/tfutils/tfenv">tfenv</a> to install terraform on mac/linux, if you are on windows please follow <a target="_blank" href="https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli">the official guide</a></p>
</li>
<li><p>Git</p>
</li>
</ul>
<h1 id="heading-steps">Steps</h1>
<h3 id="heading-initial-setup">Initial setup</h3>
<p>Go to <a target="_blank" href="https://console.aws.amazon.com/singlesignon/home">https://console.aws.amazon.com/singlesignon/home</a> on your AWS console then make sure that you have chosen the AWS region that is closest to you, for this example, I will be using the ap-southeast-1 region.</p>
<p>Go ahead and click <code>Enable</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697297537622/d8f1af98-79f4-428c-9340-eacdfe994a8b.png" alt class="image--center mx-auto" /></p>
<p>Depending on whether you have enabled AWS Organization or not. You may or may not get this message. But if you do, click on <code>Create AWS organization</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697297667477/d2227579-e203-4513-bbc9-be32d07ea77d.png" alt class="image--center mx-auto" /></p>
<p>Before continuing to create users, groups and permission sets. You will need to define some setup through the console. Unfortunately at the time of writing this blog AWS did not provide any API to enable these settings, so these steps must be done manually, I will probably be updating this guide when it's available.</p>
<p>On your IAM Identity Center dashboard, click on <code>settings</code> on the left navigation bar</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301150561/24501502-958e-4123-a826-6f7caa2c7d4f.png" alt class="image--center mx-auto" /></p>
<p>Click on Authentication</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301229345/bed6c381-f166-47df-a4fa-6241b058bd16.png" alt class="image--center mx-auto" /></p>
<p>Click <code>Configure</code> on <strong>Standard authentication</strong> and then check the box on <code>Send email OTP</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301295944/3548564d-adb5-44fb-9e46-851b13e06c98.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301367342/4b133229-d68d-4acf-8889-5d0b9186ced4.png" alt class="image--center mx-auto" /></p>
<p>Next click <code>Configure</code> on <strong>Multi-factor Authentication</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301433766/c94c2f4e-ca4e-4fd5-a63d-3642f22e706f.png" alt class="image--center mx-auto" /></p>
<p>You can choose to be creative on this screen, but I would strongly advise that you copy the settings on the screen for maximum security. But you can be flexible between context-aware and always-on, as with anything on security, there's always a tradeoff between more secure and more comfortable, the more comfortable you are the less secure it is like not enforcing MFA.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697301503530/59370495-ffcd-4f59-b7d4-a3cd7786caac.png" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Note: to improve security even further, you can even choose to disable Authenticator apps and only enable Security keys if you have hardware devices such as Yubikey. But I will take the most common use-case and allow virtual authenticator</div>
</div>

<h3 id="heading-setup-using-terraform">Setup using terraform</h3>
<p>Firstly you would need to get an AWS Access key,</p>
<p>Go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/iam/home#/security_credential">https://us-east-1.console.aws.amazon.com/iam/home#/security_credential</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306193278/5e3db29f-cc49-4137-981b-bd7c65d93bc1.png" alt class="image--center mx-auto" /></p>
<p>Check the <code>I understand creating a root access key is not a best practice, but I still want to create one.</code> then click on <code>Create access keys</code>. Don't worry this will only be temporary and we will be cleaning up the access keys at the end of this guide. Do note please never share this access key with anyone</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697302953441/f0cfa749-207f-4dad-89c8-f1a5216582b4.png" alt class="image--center mx-auto" /></p>
<p>Copy the <strong>Access key</strong> and enter the command below if you are on Mac/Linux</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> AWS_ACCESS_KEY_ID=AKIAXXXXXXXXXXXXXXXX
</code></pre>
<p>Then copy the <strong>Secret access key</strong> and enter the command below if you are on Mac/Linux</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX
</code></pre>
<details><summary>If you are on Windows</summary><div data-type="detailsContent">If you are on windows, change <code>export</code> to <code>setx</code> and remove the <code>=</code> (equal sign). Example <strong>setx AWS_ACCESS_KEY_ID </strong><code>AKIAIOSFODNN7EXAMPLE</code></div></details>

<p>Next you can open your favorite text editor and paste the text below into a file</p>
<p><strong>main.tf</strong></p>
<pre><code class="lang-bash">module <span class="hljs-string">"this"</span> {
  <span class="hljs-built_in">source</span> = <span class="hljs-string">"github.com/vincenttjia/terraform-aws-basic-aws-iam-identity-center-setup.git?ref=v1.0.0"</span>

  users = [
    {
      email       = <span class="hljs-string">"example@example.com"</span>
      given_name  = <span class="hljs-string">"John"</span>
      family_name = <span class="hljs-string">"Doe"</span>
    }
  ]
}

output <span class="hljs-string">"identity_center_url"</span> {
  value = module.setup.identity_center_url
}

provider <span class="hljs-string">"aws"</span> {
  region = <span class="hljs-string">"ap-southeast-1"</span>
}
</code></pre>
<p>You can look at the example here <a target="_blank" href="https://github.com/vincenttjia/terraform-aws-basic-aws-iam-identity-center-setup/tree/master/example">https://github.com/vincenttjia/terraform-aws-basic-aws-iam-identity-center-setup/tree/master/example</a></p>
<p>You might also need to change the aws region, depending on what you choose earlier</p>
<p>Then open your terminal, and run the command</p>
<pre><code class="lang-bash">terraform init
terraform apply
</code></pre>
<p>Note: If you run into <code>validating provider credentials error</code>. you might need to redo the <code>export</code> command above if you run a new terminal session.</p>
<p>Then type <code>yes</code> on your terminal. You can confirm the changes on the AWS Console</p>
<p>Now that we have created the users, you need to assign them permission. In total we have 3 permission sets and you can choose between the 3. But if you want almost the same access as the root account. Please choose SuperAdmin and you will need at least 1 person acting as the SuperAdmin</p>
<p>You can add people using their email using the following configuration</p>
<pre><code class="lang-bash">module <span class="hljs-string">"this"</span> {
  <span class="hljs-built_in">source</span> = <span class="hljs-string">"github.com/vincenttjia/terraform-aws-basic-aws-iam-identity-center-setup.git?ref=v1.0.0"</span>

  users = [
    {
      email       = <span class="hljs-string">"example@example.com"</span>
      given_name  = <span class="hljs-string">"John"</span>
      family_name = <span class="hljs-string">"Doe"</span>
    }
    <span class="hljs-comment"># ... more users</span>
  ]

  super_admins   = [<span class="hljs-string">"example@example.com"</span>]
  power_users    = [<span class="hljs-string">"example@example.com"</span>, <span class="hljs-string">"example1@example.com"</span>]
  readonly_users = [<span class="hljs-string">"example@example.com"</span>, <span class="hljs-string">"example1@example.com"</span>]
}

<span class="hljs-comment"># ... other configurations</span>
</code></pre>
<p>Then run</p>
<pre><code class="lang-bash">terraform apply
</code></pre>
<p>Now that everything is set up, you can click on the URL on your terminal and then skip to the <strong>account setup</strong> section.</p>
<h3 id="heading-account-setup">Account Setup</h3>
<p>Enter your email address and then click <code>Next</code>. You should receive an OTP on your email, which you can enter and finish your account setup.</p>
<p>Continue through the setup, by setting up your password and MFA.</p>
<p>You should now be arriving at this page</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697305332371/2420d98d-7fb6-43a6-bb12-74acb5468a46.png" alt class="image--center mx-auto" /></p>
<p>Now that you have confirmed that you have access, we can start on setting up your temporary credential on the cli.</p>
<pre><code class="lang-bash">aws configure sso
</code></pre>
<pre><code class="lang-bash">SSO session name (Recommended): &lt;You can choose any&gt;
SSO start URL [None]: &lt;Use the url from earlier&gt;
SSO region [None]: &lt;The region that was used earlier&gt;
SSO registration scopes [sso:account:access]: &lt;Just leave blank and hit enter&gt;
</code></pre>
<p>Example</p>
<pre><code class="lang-bash">SSO session name (Recommended): personal
SSO start URL [None]: https://d-1234acd5.awsapps.com/start/
SSO region [None]: ap-southeast-1
SSO registration scopes [sso:account:access]:
</code></pre>
<p>Confirm and continue, then allow it</p>
<pre><code class="lang-plaintext">CLI default client Region [ap-southeast-1]: &lt;Use which ever region best for you&gt;
CLI default output format [None]: &lt;Use which ever format best for you&gt;
CLI profile name [SuperAdmin-198266650228]: default
</code></pre>
<p>Example</p>
<pre><code class="lang-bash">CLI default client Region [ap-southeast-1]: ap-southeast-1
CLI default output format [None]: json
CLI profile name [SuperAdmin-198266650228]: default
</code></pre>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Note: only use the profile default if you only have 1 credential, if you have multiple like SuperAdmin, PowerUser etc. You can separate their naming and pass the <code>--profile</code> parameter every time you want to use them</div>
</div>

<p>Now you should be able to use temporary credentials on your terminal and periodically run <code>aws sso login</code> when your session runs out</p>
<pre><code class="lang-plaintext">aws sso login
</code></pre>
<h2 id="heading-cleanupimportant">Cleanup(important)</h2>
<h3 id="heading-cleanup-on-the-root-account">Cleanup on the root account</h3>
<p>Now that everything is done, there are a few cleanup that we need to do</p>
<p>Go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/iam/home#/security_credential">https://us-east-1.console.aws.amazon.com/iam/home#/security_credential</a></p>
<p>And delete the access keys that we generated earlier or any root access keys you might have generated(before deleting other access keys be sure that you are not using them for anything else or stuff will break).</p>
<p>Secondly, generate a strong password using your password manager for your root account and don't forget to set up MFA to make sure that the root account is never compromised. I would suggest at least a 128-character password with a letter, number and symbol.</p>
<p>There are 2 approaches that you can use, you can store the password in your password manager if you ever need to use the root account in the future or you can choose not to store it and just request a password reset anytime you need to access the root account. This needs to be taken with a grain of salt as you will need to secure and maintain access to the email that is associated with the root account as well.</p>
<p>Ideally, it should look like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306143392/83055416-3ccd-4fc2-93d6-c98a3dedc0d0.png" alt class="image--center mx-auto" /></p>
<p>Lastly, as root, you would want to give access to Billing for yourself</p>
<p>Go to <a target="_blank" href="https://us-east-1.console.aws.amazon.com/billing/home#/account">https://us-east-1.console.aws.amazon.com/billing/home#/account</a></p>
<p>then scroll down until you find <strong>IAM user and role access to Billing information</strong> edit it and activate IAM access</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306541994/14aa593c-e1a8-4539-b4d7-25011827d87d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-cleanup-on-iam-users">Cleanup on IAM Users</h3>
<p>Delete all existing IAM users on your account, but before deleting please be sure that you have re-created the user in IAM Identity Center, assigned the correct permission and you have communicated it clearly to the affected user the new method to login and assume cli access.</p>
<h2 id="heading-nice-to-have">Nice to have</h2>
<h3 id="heading-custom-domain">Custom domain</h3>
<p>You can set a custom domain for your AWS SSO login portal</p>
<p>Go to the settings page we visited earlier from <a target="_blank" href="https://ap-southeast-1.console.aws.amazon.com/singlesignon/home">https://ap-southeast-1.console.aws.amazon.com/singlesignon/home</a> -&gt; Scroll down to Identity Source -&gt; Actions -&gt; Customize AWS access portal URL</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1697306748795/e4fba541-0836-4688-905b-647f50cd5f38.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-troubleshooting">Troubleshooting</h1>
<h3 id="heading-running-issue-into-assuming-different-profiles">Running issue into assuming different profiles</h3>
<p>If you only used the <code>default</code> profile you will not be running into this issue. But if you set up multiple profiles you might have issues such as running the terraform version before 0.12</p>
<p>I would suggest you install <a target="_blank" href="https://docs.commonfate.io/granted/getting-started/">Granted-cli</a> and then you can just do</p>
<pre><code class="lang-bash">assume profileName
</code></pre>
]]></content:encoded></item></channel></rss>