Reputation: 666
import json
import boto3
client = boto3.client('lambda')
response = client.add_layer_version_permission(
LayerName='arn:aws:lambda:us-east-1:xxxx:layer:AWSLambda-Python38-SciPy1x',
VersionNumber=29,
StatementId='xaccount',
Action='lambda:GetLayerVersion',
Principal='*',
)
print(response)
setp1) setup aws credentials
step2) Created new IAM admin user and assigned policies to that user AdministratorAccess,AWSLambda_FullAccess, AWSLambdaExecute
step3) after running the python script I am getting error
botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the AddLayerVersionPermission operation: User: arn:aws:iam::xxxx:root is not authorized to perform: lambda:AddLayerVersionPermission on resource: arn:aws:lambda:us-east-1:xxxx:layer:AWSLambda-Python38-SciPy1x:29
Upvotes: 0
Views: 761
Reputation: 238249
The layer you are trying to modify:
arn:aws:lambda:us-east-1:xxxx:layer:AWSLambda-Python38-SciPy1
is AWS managed public layer. It does not belong to you, thus you can't modify its permissions, explaining why you are denied doing this.
Upvotes: 2