Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Trust Policy Has prohibited field Principal

I'm trying to create an IAM role and assign it to an EC2 instance according to Attach an AWS IAM Role to an Existing Amazon EC2 Instance by Using the AWS CLI.

The policy looks like below:

{  "Version": "2012-10-17",  "Statement": [  {     "Effect": "Allow",     "Principal": {     "Service": "ec2.amazonaws.com"     },     "Action": "sts:AssumeRole"   }  ] 

}

But it gives this error:

This policy contains the following error: Has prohibited field Principal 

There is a similar question here but it couldn't fix this issue.

Any help would be appreciated.

like image 562
Matrix Avatar asked Aug 03 '17 08:08

Matrix


People also ask

Has prohibited field principal for more information about the IAM policy?

In order to solve the "Policy has Prohibited field Principal" error, we have to add the Principal field to the role's trust policy, and not its permissions policy. The Principal field defines the IAM user or role, which is allowed access and it belongs in the trust policy.

What are principals in AWS policy?

A principal is a person or application that can make a request for an action or operation on an AWS resource. The principal is authenticated as the AWS account root user or an IAM entity to make requests to AWS. As a best practice, do not use your root user credentials for your daily work.

Why am I getting the error invalid principal in policy when I try to update my Amazon s3 bucket policy?

If your bucket policy uses IAM users or roles as Principals, then confirm that those IAM identities weren't deleted. When you edit and then try to save a bucket policy with a deleted IAM ARN, you get the "Invalid principal in policy" error.

How do I change my AWS trust policy?

In the navigation pane of the IAM console, choose Roles. The console displays the roles for your account. Choose the name of the role that you want to modify, and select the Trust relationships tab on the details page. Choose Edit trust relationship.


1 Answers

Faced the same issue when trying to update the "Trust Relationship" Or same known as "Trust Policy". "Principal" comes to play only in "Trust Policy". May be by mistake you are updating normal policy falling under the permissions tab. Try updating the policy under "Trust Relationships" tab as below:

    {       "Version": "2012-10-17",       "Statement": [       {          "Effect": "Allow",          "Principal": {            "Service": [            "ec2.amazonaws.com",            "lambda.amazonaws.com"            ]           },          "Action": "sts:AssumeRole"        }      ]     } 
like image 152
Abhishek Sinha Avatar answered Sep 28 '22 21:09

Abhishek Sinha