Small language models are fast, cheap, and run almost anywhere. But even the smallest model needs data. If that data is in Amazon S3, you don’t want to give it full control over the bucket. The safest way is to give the model a read-only IAM role that can only access what it needs. Nothing more.
To set this up, start with the principle of least privilege. Create an IAM policy that grants only s3:GetObject and s3:ListBucket for the exact bucket and prefixes the model will read from. Avoid wildcards in resource paths unless they are strictly necessary. Test the policy with the IAM Policy Simulator before attaching it to any role.
Next, create an IAM role with a trust policy that allows only the specific compute environment running the model to assume it. For example, if your small language model runs on Amazon SageMaker or an EC2 instance, make sure the trust policy targets that service. Attach the read-only S3 policy to this role.
When deploying, reference the role directly in your service configuration so that no human credentials are embedded in the model runtime. Rotate any temporary credentials automatically using AWS’s built-in refresh mechanisms.