Cloud Security
Published in

Cloud Security

Create an IAM User with CloudFormation

ACM.15 Creating Batch job administrators to kick of AWS Batch jobs

  • I’ll use a separate user for this purpose from my administrative user account which has too many permissions.
  • I cannot use an IAM role to kick off the jobs because I want to use MFA and you cannot use MFA with an AWS IAM Role alone. An MFA serial number is associated with a user.
  • I don’t want to use AWS SSO (now AWS Identity Center) because I don’t like the configuration that includes the URL to my login portal or the browser interaction. I’m not even sure that will work with what I am hoping to implement.
  • I’m going to use STS and pass in credentials and an MFA token.
  • I don’t want to use a Yubikey because I’d have to install the Yubico CLI on my laptop, so I’ll use virtual MFA for this user.
  • This user does not need access to the AWS Console. This user is needed solely to obtain an MFA code to kick off a job and to assume a role.
  • I’ll be leveraging an AWS Access Key and Secret Key associated with the IAM user but I don’t have anywhere secure to put those just yet so I’ll create them later.
  • This user will not be allowed to modify it’s own password or MFA. An administrator will have to do that.
  • I’m going to run my batch jobs in a separate, locked down account in my AWS organization. I’ll create the user in that account.
  • The only required permissions from my batch job administrator seems to be STS to assume the roles I create for my batch jobs in that account.
  • I may want to assign the permissions to kick off batch jobs to other users in the future, so I’ll assign the permissions to a group, not a user. That is an AWS security best practice.
  • I will create a separate role for each batch jobs with permissions limited to exactly what that batch job needs to do.
  • We will limit access to resources to this role only unless MFA is present for the reasons discussed in the last post.
  • We’ll add permissions to this role later when we set up the resources it needs to use and access.
  • I expect that I’ll need to deploy and re-deploy batch job administrators at different times than the batch jobs themselves so I’ll put that code in a separate directory called batch_job_admins in my GitHub repo.
  • I’ll add a deploy.sh in the directory containing the scripts to deploy my batch job admins.
  • I generally put each resource in it’s own file so it’s easy to find the code when I want to edit it. I can also redeploy individual resources separately.
/batch_job_admins
/cfn
policy_batch_job_admins.yaml
group_batch_job_admins.yaml
user_batch_job_admins.yaml
deploy.sh
Resource: !Sub 'arn:aws:iam::${AWS::AccountId}:role/batch_*'
git clone https://github.com/tradichel/SecurityMetricsAutomation.git
NOTE: All the following code moved into the iam directory in a subsequent post and refactoring of code.
#group_batch_job_admins.yaml
https://github.com/tradichel/SecurityMetricsAutomation/blob/main/iam/batch_job_admins/cfn/group_batch_job_admins.yaml
#policy_batch_job_admins.yaml
https://github.com/tradichel/SecurityMetricsAutomation/blob/main/iam/batch_job_admins/cfn/policy_batch_job_admins.yaml
#user_batch_job_admin.yaml
https://github.com/tradichel/SecurityMetricsAutomation/blob/main/iam/batch_job_admins/cfn/user_batch_job_admin.yaml
#deploy.sh
https://github.com/tradichel/SecurityMetricsAutomation/blob/main/iam/batch_job_admins/deploy.sh
./deploy.sh
Medium: Teri Radichel or Email List: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests services via LinkedIn: Teri Radichel or IANS Research

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Teri Radichel

Cloud Security Training and Penetration Testing | GSE, GSEC, GCIH, GCIA, GCPM, GCCC, GREM, GPEN, GXPN | AWS Hero | Infragard | IANS Faculty | 2ndSightLab.com