AWS Builder Center
Two IAM Permissions, Not Twelve: Least Privilege on a Hackathon Project

Two IAM Permissions, Not Twelve: Least Privilege on a Hackathon Project

Most hackathon projects attach broad AWS permissions just to make things work. We took the opposite approach. By granting only two Amazon Polly permissions, we reduced risk, simplified debugging, and learned an important lesson about the difference between IAM permissions and account-level access controls.

Software Developer

Two IAM Permissions, Not Twelve: Least Privilege on a Hackathon Project

Most hackathon projects start the same way.
A service throws an access error.
Someone searches Stack Overflow.
Someone else finds a managed policy called:
AdministratorAccess
or
AmazonSomethingFullAccess
The policy gets attached.
The error disappears.
Everyone moves on.
We've all done it.
But this time we decided not to.
What started as a simple Amazon Polly integration turned into one of the best lessons we learned about AWS security, debugging, and the difference between permissions and actual access.



The Default Developer Instinct

When you're building fast, security usually feels like something you'll fix later.
The logic is understandable:
"It's just a hackathon project."
"We'll tighten permissions after launch."
"We just need it working."
The problem is that temporary permissions often become permanent permissions.
A policy attached during a weekend project can survive for months or even years.
That's how overly privileged AWS accounts are born.
Instead of granting broad access, we asked a simple question:
What does our application actually need?
The answer was surprisingly small.



What Our Application Actually Needed

Our application used Amazon Polly for text-to-speech.
It performed only two operations:
  1. Convert text into audio
  1. List available voices
That's it.
No S3.
No Lambda.
No EC2.
No DynamoDB.
No CloudFormation.
No Bedrock.
No administrative actions.
Only two API calls.



The Entire Policy

Our final IAM policy looked like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"polly:SynthesizeSpeech",
"polly:DescribeVoices"
],
"Resource": "*"
}
]
}
That was enough for the entire feature.
No additional permissions.
No managed FullAccess policies.
No wildcard actions.
Just the exact permissions our code required.



Why Least Privilege Matters

Least privilege is one of the most important security principles in AWS.
The idea is simple:
Give an identity only the permissions it needs to perform its job.
Nothing more.
This reduces:
  • Accidental changes
  • Security risks
  • Blast radius during compromise
  • Audit complexity
  • Future maintenance costs
Even in a small project, it's worth doing.
And in our case, it actually made debugging easier.



AWS Error Messages Are Underrated

Many platforms return vague errors like:
Access denied.
or
Unauthorized.
AWS usually gives you much more information.
One of the most useful things about IAM is that the error message often tells you exactly what is wrong.
A typical message looks like:
User:
arn:aws:iam::123456789012:user/polly-user

is not authorized to perform:

polly:SynthesizeSpeech

because no identity-based policy allows the action.
That single message tells you:
  • Which user made the request
  • Which action failed
  • Why it failed
In many cases, the error itself contains the solution.
Instead of spending hours debugging code, you can often fix the issue in minutes.
For us, IAM errors were effectively acting as a debugging tool.



Permissions Were Correct. Access Still Failed.

This was the lesson that surprised us the most.
At one point, we were working with Amazon Bedrock.
The IAM user already had:
AmazonBedrockFullAccess
attached.
So naturally we assumed access should work.
It didn't.
Every request failed.
At first we thought:
  • Wrong credentials
  • Wrong region
  • Missing permission
  • SDK issue
None of those were true.
The IAM permissions were correct.
The policy was attached.
The actions were allowed.
Yet access was still denied.



The Important AWS Lesson

Permissions being correct does not automatically mean access is granted.
AWS has multiple layers of control.
An IAM policy might allow an action, but access can still be blocked by:
  • Service control policies (SCPs)
  • Account restrictions
  • Region restrictions
  • Service access controls
  • Organization-level policies
  • Explicit denies
In our case, the limitation existed outside the IAM policy itself.
The user technically had permission.
The account still could not use the service.
That distinction is incredibly important.
When troubleshooting AWS:
  1. Check IAM permissions.
  1. Check account-level controls.
  1. Check organization policies.
  1. Check service availability.
  1. Check regional restrictions.
Don't assume permissions are the entire story.



Key Management Matters Too

Permissions are only part of security.
Credentials matter just as much.
During development we stored AWS credentials in environment variables.
Example:
AWS_ACCESS_KEY_ID=xxxxx
AWS_SECRET_ACCESS_KEY=xxxxx
AWS_REGION=ap-south-1
Then loaded them into our application.
const client = new PollyClient({
region: process.env.AWS_REGION,
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
}
});



What We Never Did

We never:
  • Committed credentials to Git
  • Stored secrets in source code
  • Shared credentials in chat messages
  • Added secrets to public repositories
Even for a hackathon project, that risk isn't worth taking.
Git history lasts forever.
Once credentials are pushed publicly, you should assume they're compromised.



What We'd Use in Production

Environment variables are acceptable for small projects and prototypes.
For production systems, we'd move toward temporary credentials.
Options include:

IAM Roles

For AWS-hosted workloads:
  • EC2 Instance Roles
  • ECS Task Roles
  • Lambda Execution Roles
Applications receive credentials automatically.
No hardcoded secrets required.



AWS STS

AWS Security Token Service (STS) provides temporary credentials.
Benefits:
  • Short-lived access
  • Automatic expiration
  • Reduced exposure
  • Better security posture
Instead of long-term keys, applications receive credentials that expire automatically.
Even if leaked, the damage window is limited.



The Smallest Policy Is Often the Best Policy

The interesting thing about this project is that we never needed more permissions.
The final production feature ran successfully with:
polly:SynthesizeSpeech
polly:DescribeVoices
That's all.
Not ten permissions.
Not twenty permissions.
Not FullAccess.
Just two actions.
And because the policy was so small:
  • Auditing became easier
  • Debugging became easier
  • Security improved
  • Future maintenance improved



Final Thoughts

AWS security doesn't have to be complicated.
Start with the question:
What does my application actually need?
Then grant exactly that.
In our case, the answer was two permissions.
The project worked perfectly.
We learned how useful IAM error messages can be.
We learned that permissions and access are not always the same thing.
And we learned that least privilege isn't just an enterprise security concept.
It's something worth practicing from the very first prototype.
Because good security habits are easier to build early than retrofit later.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article