미운 오리 새끼의 우아한 개발자되기

[AWS] AWS API AccessDeniedException 본문

Cloud/AWS

[AWS] AWS API AccessDeniedException

Serina_Heo 2023. 2. 24. 16:56

내가 AWS 를 사용하다보면 가장 답답한 부분이 IAM 이다.

개인 프로젝트야 AdministratorAccess 를 줘버리면 쉬울 일이지만, 회사 일을 하다보면 수많은 AWS Account, User 들이 얽혀있고, 많은 리소스들이 상용환경에 있기 때문에 인프라 담당자가 쉽게 IAM 권한을 주지 않는다.

최근에 개발환경을 구축하면서 AWS API 를 자주 사용하고 있는데 AccessDeniedException 을 자주 마주치게 된다.

난 분명 필요한 권한을 준거 같은데 왜 안될까..

API 를 호출했을 때 error log 가 아래와 같이 나오면 

 An error occurred (AccessDeniedException) when calling the UpdateService operation: User: arn:aws:sts::xxx:assumed-role/AmazonSSMRoleForInstancesQuickSetup/i-Xxx is not authorized to perform: ecs:UpdateService on resource: arn:aws:ecs:ap-northeast-2:xxx:service/xxx-ecs-cluster/xxx-service because no identity-based policy allows the ecs:UpdateService action

 

해당 aws configure profile 이 그 API 를 실행하는데 필요한 권한을 가지고 있는지 IAM 시뮬레이터로 확인이 필요하다.

https://docs.aws.amazon.com/ko_kr/IAM/latest/UserGuide/access_policies_testing-policies.html#policies_policy-simulator-using

 

IAM 정책 시뮬레이터로 IAM 정책 테스트 - AWS Identity and Access Management

작업이 암묵적으로 거부됨(즉, 명시적으로 허용되지 않기 때문에 작업이 거부된 경우)인 경우 나열(List) 및 문 표시(Show statement) 옵션은 표시되지 않습니다.

docs.aws.amazon.com