DeleteGroup 사용하기
DeleteGroup 사용하기 (SDK/CLI)
DeleteGroup(IAM 그룹 삭제) API를 활용하는 방법을 코드 예시로 정리했어요. 각 예시는 어떤 동작을 하는지, 어떤 파라미터를 쓰는지 순서대로 살펴볼 수 있어요.
출처: 문서
본문
다음 코드 예시들은 DeleteGroup 를 어떻게 사용하는지 보여줘요.
AWS CLI
IAM 그룹 삭제하기
aws iam delete-group \
--group-name MyTestGroup
다음 delete-group 명령은 MyTestGroup이라는 IAM 그룹을 삭제해요.
JavaScript(SDK v3)
import { DeleteGroupCommand, IAMClient } from "@aws-sdk/client-iam";
const client = new IAMClient({});
/**
*
* @param {string} groupName
*/
export const deleteGroup = async (groupName) => {
const command = new DeleteGroupCommand({
GroupName: groupName,
});
const response = await client.send(command);
console.log(response);
return response;
};
GitHub에 더 많은 내용이 있어요. AWS Code Examples Repository에서 전체 예시를 찾아 실행 방법을 배울 수 있어요.
PowerShell Tools (V4)
예시 1: MyTestGroup이라는 IAM 그룹을 삭제해요. 첫 번째 명령은 그룹의 멤버인 IAM 사용자를 모두 제거하고, 두 번째 명령은 IAM 그룹을 삭제해요. 두 명령 모두 확인 프롬프트 없이 동작해요.
(Get-IAMGroup -GroupName MyTestGroup).Users | Remove-IAMUserFromGroup -GroupName MyTestGroup -Force
Remove-IAMGroup -GroupName MyTestGroup -Force
PowerShell Tools (V5)
예시 1: MyTestGroup이라는 IAM 그룹을 삭제해요. 첫 번째 명령은 그룹의 멤버인 IAM 사용자를 모두 제거하고, 두 번째 명령은 IAM 그룹을 삭제해요. 두 명령 모두 확인 프롬프트 없이 동작해요.
(Get-IAMGroup -GroupName MyTestGroup).Users | Remove-IAMUserFromGroup -GroupName MyTestGroup -Force
Remove-IAMGroup -GroupName MyTestGroup -Force