lambda function cannot invoke step function using LabRole on AWS academy

0

I'm using AWS academy which I am not allowed to create IAM role, what I can use is only the LabRole.

I am trying to use lambda function to invoke my step function using StartExecution, but it didn't work. I got the error below from CloudWatch. However, it should work on LabRole.

[ERROR] ClientError: An error occurred (AccessDeniedException) when calling the StartExecution operation: User: arn:aws:sts::051823271855:assumed-role/LabRole/my-s3-function is not authorized to access this resource Traceback (most recent call last):   File "/var/task/lambda_function.py", line 20, in lambda_handler     input = json.dumps(input))   File "/var/runtime/botocore/client.py", line 391, in _api_call     return self._make_api_call(operation_name, kwargs)   File "/var/runtime/botocore/client.py", line 719, in _make_api_call     raise error_class(parsed_response, operation_name)

Wendy
질문됨 일 년 전312회 조회
1개 답변
0

Hi Wendy,

Are you able to attach a custom policy to the Lab role as described here? https://docs.aws.amazon.com/IAM/latest/UserGuide/roles-managingrole-editing-console.html (Modifying a role permissions policy (console)).

Then you can select step function start execution and associate it with a resource arn.

Hope it helps ;)

profile picture
전문가
답변함 일 년 전
  • I tried this before, but I can't attach role policy. The error was: Errors attaching policies to the role. Policy AWSStepFunctionsConsoleFullAccess not added. User: arn:aws:sts::051823271855:assumed-role/voclabs/user**** is not authorized to perform: iam:AttachRolePolicy on resource: role LabRole because no identity-based policy allows the iam:AttachRolePolicy action

    Thank you so much for your help!

  • Strange. I d try to add iam:AttachRolePolicy to your user. Most likely will fail because the lab is maybe too restrictive. Do you have an option to restart the lab (destroy and redo)?

  • I can restart the lab but it didn't help. I found the LabRole of my TA is the same as mine. Do you have any suggestions about connect S3 with step function? I tried EventBridge before, but it also didn't work because of the LabRole.

  • But did you manage to execute the step function from lambda?

    Is the s3 question related to this problem or is another one. You would need to elaborate it a bit either here or in a new question depending on it

  • Yes, I used stepFunction.start_execution( stateMachineArn='arn:aws:states:XXXXXXXXXXXXXXXX:stateMachine:my-state-machine',...) from my lambda.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠