ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • AWS RDS mysql user role 부여
    카테고리 없음 2024. 4. 22. 14:12

    aws rds mysql user 에 role 부여 시 발생된 에러

     

    create database test;
    create user 'abcc1'@'%' identified by 'sdafcasd!!3';
    create role test_role_1;
    grant select, update,delete,insert,execute on test.* to 'test_role_1';
    grant test_role_1 to abcc1;

    위 과정으로 하면 오류 발생

    Error Code: 1227. Access denied; you need (at least one of) the WITH ADMIN, ROLE_ADMIN, SUPER privilege(s) for this operation

     

    해결 방법

    https://stackoverflow.com/questions/73362352/rds-unable-to-grant-role-to-a-user-using-root-user

     

    rds unable to grant role to a user using root user

    I have a mysql rds instance, when you make the instance you declare a root user and a password. I am then using terraform to create a new user and give the user a role. However i get the following ...

    stackoverflow.com

     

    aws rds 에서 생성되는 admin 계정은 슈퍼 유저 권한이 없다.

    aws 에서 슈퍼 유저 권한을 제공하지 않기 때문에 admin 계정에 슈퍼 유저 권한을 줘야한다.

     

    GRANT ROLE_ADMIN on *.* to root;

    슈퍼 유저 권한을 admin 계정에 주고 (여기선 root)

     

    grant test_role_1 to abcc1;

    다시 'test_dd' 계정에 role 을 주면 에러가 안 뜬다.

     

    이제 user 계정 로그인

     

    set role test_role_1;

     

    적용

     

    위 설정 후 로그아웃 - 로그인하면 권한이 비활성화 되어 있다. (권한은 있지만 적용이 되지 않은 상태)

     

    자신에게 할당 된 권한 확인

    SHOW GRANTS for abcc1;

     

     

     

    권한을 활성화하려면

    본인 계정에서 직접 활성화
    set role test_role_1;
    
    슈퍼 유저에서 활성화
    SET DEFAULT ROLE test_role_1 to 'abcc1'@'%';

     

    aws 에서 로그인 시 role 을 적용시키려면

     

    aws rds -

    rds 에 적용되어 있는 파라미터 그룹 - 검색 - activate_all_roles_on_login

     

    1로 변경 // dynamic 이기 때문에 바로 적용됨

     

    activate_all_roles_on_login : ON 설정 시 매번 set role 명령으로 역할을 활성화하지 않아도 로그인과 동시에 부여된 역할이 자동으로 활성화됨

     

     

Designed by Tistory.