Skip to content

Managed policy "AmazonS3FullAccess" is not valid

0

Hello, Using Java CDK, I'm trying to create an execution role having attached the "AmazonS3FullAccess" managed policy. The following statement:

    Role role = Role.Builder.create(this, "...").roleName("...")
      .assumedBy(ServicePrincipal.Builder.create("lambda.amazonaws.com").build())
      .managedPolicies(List.of(ManagedPolicy.fromAwsManagedPolicyName("AmazonS3FullAccess "))).build();

raises the exception below:

12:16:35 PM | CREATE_FAILED        | AWS::IAM::Role          | quarkusapigatewaylambdarole76F80EE0
Resource handler returned message: "ARN arn:aws:iam::aws:policy/service-role/AmazonS3FullAccess  is not valid. (Service: Iam, Status Code: 400, Request ID: f4c56992-942c-48cb-825c-c2a139514373)" (RequestToken: d7ff2022-a057-486e-8d94-8
74b67d0e753, HandlerErrorCode: InvalidRequest)

I've tried also to use "service-role/AmazonS3FullAccess" as the managed policy name but with the same result.

However, looking in the AWS Console, at IAM->Polices I can see that the mentioned policy exists. So, what might be the problem here ?

Many thanks in advance for your help.

Kind regards,

Nicolas

2 Answers
3
Accepted Answer

Hi,

It seems that you have a superfluous space in the string of the policy name "AmazonS3FullAccess " -> so, please try with "AmazonS3FullAccess"

Best,

Didier

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
  • Hi, this was it, many thanks. So for the records, the right statement is:

    ... ManagedPolicy.fromAwsManagedPolicyName("AmazonS3FullAccess") ...
    

    and not

    ... ManagedPolicy.fromAwsManagedPolicyName("serviceRole/AmazonS3FullAccess") ...
    

    as I've seen in different places.

  • Hi, glad that you fixed your issues! Thanks for accepting my answer. Didier

2

Hello.

Looking at the document below, I thought it was necessary to add it as follows.
https://docs.aws.amazon.com/cdk/api/v2/java/software/amazon/awscdk/services/iam/ManagedPolicy.html

role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName("AmazonSESFullAccess"));
EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.