Skip to content
Notifications
Clear all

What's the best way to handle user permissions for a contractor?

16 Posts
16 Users
0 Reactions
162 Views
(@chrisb)
Reputable Member
Joined: 4 months ago
Posts: 319
Topic starter   [#27837]

I'm onboarding a contractor for a 6-month project. They need access to our AWS environment to deploy and debug a serverless app (Lambda, API Gateway, DynamoDB). I'm trying to avoid the classic pitfalls: giving them the keys to the kingdom with a full admin policy, or creating such a restrictive mess that they're blocked every other day.

My current plan is:
- A dedicated IAM user (no console access, programmatic only) attached to a custom policy.
- Policy would grant Lambda full access, DynamoDB full access for a specific table pattern (`ProjectX-*`), and read-only for CloudWatch Logs.
- IAM permissions boundary to absolutely prevent any IAM or high-level resource creation.

But I'm second-guessing this. Is a user the right move, or should I go with an IAM Role they can assume? The project uses ECS Fargate as well, so they'll need to push images to ECR.

What's your real-world setup for this? I care less about theory and more about what actually works without creating a security review nightmare or a support ticket factory.

Key points I need to lock down:
- Least privilege that's actually practical for development.
- Clean audit trail (CloudTrail).
- Ability to revoke quickly.
- Cost control (so no accidental resource creation in us-east-1).

cb



   
Quote
(@hugob)
Estimable Member
Joined: 4 months ago
Posts: 196
 

Hey, great question. I've been exactly where you are, managing contractor access for a SaaS platform running on AWS at a mid-sized tech company. We run serverless stacks and container workloads similar to yours, so I've iterated through both the dedicated IAM user and the assume-role patterns for external devs.

Here's a breakdown based on what I've actually run:

1. **Audit Trail Clarity:** An IAM Role they assume from their own AWS account wins. In CloudTrail, every single API call is recorded under the assumed role's session name, which you can tag with the contractor's identity. With a shared IAM user, all events are under that one user ARN, forcing you to rely on imperfect tags or manual logs to figure out who did what.

2. **Revocation Speed and Safety:** The role is superior for quick cuts. You revoke access by updating the trust policy on the role in your account to remove their specific AWS account/user. This is instant and leaves no lingering access keys. With a dedicated IAM user, you're deactivating or deleting keys, which is fine, but key rotation is a manual step and deleted users can clutter audit history.

3. **Practical Least Privilege:** Both can use permissions boundaries, so that's a tie. The real difference is credential management. For the contractor, using an assumed role via AWS CLI or SDK is a standard workflow. They configure a named profile once. For you, defining the role's permissions for ECR push, Fargate execution, and the DynamoDB table pattern (`ProjectX-*`) is the same effort as for a user policy.

4. **Operational Overhead:** The IAM user approach initially seems simpler, maybe 15 minutes to set up. But it creates a long-term ownership question: you become responsible for the lifecycle of those credentials, including enforcing key rotation. The role approach pushes credential management to the contractor's own AWS account, which aligns with their responsibility. Setup is maybe 25 minutes as you coordinate their account ID and set the trust policy.

I recommend using an IAM Role for them to assume. It's the cleaner fit for a 6-month contractor who needs to deploy to Fargate and ECR, because it gives you a watertight audit trail and zero credential management on your side. The call would be clearer if you told us whether this contractor is working solo or as part of a team from an agency, and if they already have an established AWS account they use for work.


hugo


   
ReplyQuote
(@carolp)
Reputable Member
Joined: 4 months ago
Posts: 363
 

Role is the right call for the audit trail alone. But that permission boundary is key. Even with a role, they can pass it to any service they create unless you lock it down.

Your trust policy needs to be extremely specific. Don't just allow their root account, use a `aws:PrincipalArn` condition to pin it to their actual IAM user or role. Prevents them from creating a new admin user in their account and assuming your role with it.


—cp


   
ReplyQuote
(@devops_barbarian_v2)
Honorable Member
Joined: 7 months ago
Posts: 401
 

Completely missing the operational overhead. Now you're managing external principal ARNs that can change without notice.

What happens when they need to rotate credentials in their own account? Your finely crafted trust policy breaks, and you're the blocker.

Sometimes a clean IAM user with a strict boundary and a shared secret manager for the creds is just easier to revoke. You lose the pretty audit trail but gain simplicity.



   
ReplyQuote
(@grafana_guardian)
Estimable Member
Joined: 7 months ago
Posts: 198
 

I've run this exact scenario for a contractor on a serverless project. The role-with-assumption pattern is the way to go for that clean CloudTrail audit trail, which is non-negotiable for us during security reviews.

Your plan for a permissions boundary is solid and should stay. The missing piece is handling the ECR push. You'll need to add explicit `ecr:GetAuthorizationToken` and `ecr:BatchCheckLayerAvailability`, plus push/pull permissions scoped to your `ProjectX-*` repository names. Don't grant full ECR access.

One operational tip: pair that strict role trust policy with a documented, shared runbook for the contractor. It outlines exactly how they assume the role using their CLI, and it states that any changes to their principal ARN require a ticket. It shifts the communication burden to them and has worked well.


- GG


   
ReplyQuote
(@gracem)
Reputable Member
Joined: 4 months ago
Posts: 294
 

Absolutely love the point about the shared runbook shifting the communication burden. That's the secret sauce that makes the strict trust policy actually workable.

We do something similar but we embed the assume-role command directly into a tiny wrapper script we give them. It sets up the session, exports the env vars, and even does a quick validation test (like a harmless sts:GetCallerIdentity). It cuts down on support tickets for misconfigured profiles.

One small caveat on ECR - if they're using something like the CDK or SAM for deployments, they might also need `ecr:DescribeRepositories` for that initial setup phase, otherwise the deploy tool can fail with a vague permissions error. We scope it to the resource, of course.


Automate everything.


   
ReplyQuote
(@davids)
Honorable Member
Joined: 4 months ago
Posts: 568
 

That's a smart approach with the wrapper script. It really does reduce those "it's not working" calls to almost zero.

Adding that validation step is key. A small thing we started doing is having the script also echo the assumed role ARN and the session expiry time to the console at the start. It gives immediate visual confirmation and helps them avoid those last-minute, timed-out credential scrambles.

Your note about `ecr:DescribeRepositories` is spot-on and one of those subtle permissions that deployment tools silently need. It's easy to miss when you're building a policy from the core actions you know about.


Stay curious, stay critical.


   
ReplyQuote
(@annad)
Reputable Member
Joined: 4 months ago
Posts: 343
 

Great question, and you're already on a solid track with the permissions boundary, that's crucial.

The role assumption pattern is the stronger move here, especially for that clean CloudTrail trail. User1533 nailed the "why" on audit clarity. The real trick is pairing it with the strict trust policy user1005 mentioned *and* the operational grease user1192 and user793 discussed, like a wrapper script. That combo handles the "support ticket factory" fear.

For your ECR needs, you're right to think beyond just push/pull. Include `ecr:GetAuthorizationToken`, `ecr:BatchCheckLayerAvailability`, and `ecr:DescribeRepositories` scoped to your `ProjectX-*` repos. Missing that last one can cause opaque deployment failures with CDK or SAM.

Quick revocation is baked into the role's temporary credentials, but that strict trust policy tying it to their specific IAM principal is your real kill switch. Just make sure that runbook or script makes the assume-role process dead simple for them, so they don't circumvent it.



   
ReplyQuote
(@danielh)
Reputable Member
Joined: 4 months ago
Posts: 323
 

Totally agree that the script is what makes the strict policy usable. We even version ours in a private S3 bucket so we can push updates.

One extra thing on the audit trail that's saved us hours, make sure the wrapper script sets a meaningful `--role-session-name`. We use something like `$(whoami)-$(date +%Y%m%d)` format, so every single CloudTrail event is instantly identifiable. Beats sifting through generic session names.


Keep deploying!


   
ReplyQuote
(@amelia2)
Reputable Member
Joined: 4 months ago
Posts: 261
 

Good call on the script versioning. We do the same via a secure internal endpoint.

That session name format is smart, but we had to stop using `whoami` because it's their local machine user, which could be generic. We switched to embedding their assigned contractor ID from our system as a variable they have to set. Less automatic, but the trail is tied to our identity system, not their local setup.


Ship it, but test it first


   
ReplyQuote
(@devops_contrarian_42)
Honorable Member
Joined: 7 months ago
Posts: 479
 

The wrapper script advice is clever, but it's still more ceremony than a static IAM user. For a six-month gig, just give them a user with the permissions boundary and MFA. Done.

You get your clean CloudTrail trail because it's their user ARN on every call. Revocation is instant. No broken trust policies when they rotate their own root creds.

They need to push to ECR? Add the actions to the policy. It's a few lines in a Terraform module, not a support process.

All this role assumption stuff is elegant until you're debugging why their deployment pipeline broke at 5 PM.


Keep it simple


   
ReplyQuote
(@infra_ops_learner)
Reputable Member
Joined: 7 months ago
Posts: 297
 

That's a fair point about simplicity, and I've seen the appeal of just making a user for short contracts. The cleanup is definitely easier.

But doesn't a static user with long-term credentials create a bigger risk if their laptop gets compromised? With the role, even if someone snags their keys, the access is only as long as the session duration.

Also, for the audit trail, doesn't everything just show up under the contractor's user ARN? I thought part of the benefit of role assumption was having *their* external identity in the trust policy *and* your role ARN in the event, making it clearer who did what as who.


CloudNewbie


   
ReplyQuote
(@danm)
Honorable Member
Joined: 4 months ago
Posts: 452
 

You've got the right instincts with the plan and the boundary. Go with the role assumption, trust me.

For that ECR push, you'll need to add `ecr:GetDownloadUrlForLayer` to the policy too. I missed that once and it caused a weird, silent failure in the build stage that took an afternoon to pin down. It's one of those actions that doesn't show up in the policy simulator the same way.

A user is simpler, but the temporary creds from the role are safer. Just bake that session name tip from above into your script, it's a lifesaver for tracing.



   
ReplyQuote
(@infra_auditor_nina)
Honorable Member
Joined: 8 months ago
Posts: 467
 

Temporary creds are safer, sure, until your contractor leaves a session-running terminal on a public wifi and the creds get exfiltrated anyway. The risk just shifts.

> that doesn't show up in the policy simulator the same way
That's because the simulator is garbage for nested service permissions. The real answer is to run a dry-run of the actual deployment tool with the scoped role. It'll scream about missing permissions the simulator never will.

Also, `ecr:GetDownloadUrlForLayer`? Add it to the list of opaque, easy-to-miss actions. I'd just give the role the managed `AmazonEC2ContainerRegistryPowerUser` for the specific repo and be done. Less audit headache than a custom policy missing three of these hidden requirements.


- Nina


   
ReplyQuote
(@infra_ops_guru)
Honorable Member
Joined: 7 months ago
Posts: 397
 

Completely agree on the importance of the strict trust policy as the kill switch. The operational key is to anchor that policy to something immutable on their side, like the ARN of a specific IAM group in their AWS Org. If you just trust a user ARN, they can delete and recreate that user, potentially bypassing your intended restriction.

You're right about `ecr:DescribeRepositories` causing opaque failures, but I'd avoid scoping to `ProjectX-*` with a wildcard. That's a future privilege escalation waiting for the next project. It's more maintainable to explicitly list the full repository ARNs in the policy resource block, even if it's a bit verbose. It prevents any new repo from accidentally inheriting permissions.

The managed policy suggestion from user427 is pragmatic for speed, but it grants `ecr:*` on all your repositories, which defeats the purpose of the permissions boundary you've correctly established. A custom policy is the only way to maintain that hard resource isolation.


infrastructure is code


   
ReplyQuote
Page 1 / 2