

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# `AWS-AttachIAMToInstance`
<a name="automation-aws-attachiamtoinstance"></a>

 **설명** 

관리형 인스턴스에 AWS Identity and Access Management (IAM) 역할을 연결합니다.

 [이 자동화 실행(콘솔)](https://console.aws.amazon.com/systems-manager/automation/execute/AWS-AttachIAMToInstance) 

**문서 유형**

자동화

**소유자**

Amazon

**플랫폼**

Linux, macOS, Windows 

**파라미터**
+ AutomationAssumeRole

  유형: 문자열

  설명: (선택 사항) 사용자를 대신하여 Systems Manager Automation을 통해 작업을 수행할 수 있도록 허용하는 AWS Identity and Access Management (IAM) 역할의 Amazon 리소스 이름(ARN)입니다. 역할을 지정하지 않은 경우, Systems Manager Automation에서는 이 실행서를 시작하는 사용자의 권한을 사용합니다.
+ ForceReplace

  유형: Boolean

  설명: (선택 사항) 플래그를 사용하여 기존 IAM 프로파일을 대체할지 여부를 지정합니다.

  기본값: true
+ InstanceId

  유형: 문자열

  설명: (필수) IAM 역할을 할당하려는 인스턴스의 ID입니다.
+ RoleName

  유형: 문자열

  설명: (필수) 관리형 인스턴스에 추가할 IAM 역할 이름입니다.

 **문서 단계** 

1.  `aws:executeAwsApi` - DescribeInstanceProfile - EC2 인스턴스에 연결된 IAM 인스턴스 프로파일을 찾습니다.

1.  `aws:branch` - CheckInstanceProfileAssociations - EC2 인스턴스에 연결된 IAM 인스턴스 프로파일을 확인합니다.

   1.  IAM 인스턴스 프로파일이 연결되어 있고 `ForceReplace`가 `true`로 설정된 경우: 

      1.  `aws:executeAwsApi` - DisassociateIamInstanceProfile - EC2 인스턴스에서 IAM 인스턴스 프로파일의 연결을 해제합니다.

   1.  `aws:executeAwsApi` - ListInstanceProfilesForRole - 제공된 IAM 역할을 위한 인스턴스 프로파일을 표시합니다.

   1.  `aws:branch` - CheckInstanceProfileCreated - 제공된 IAM 역할에 연결된 인스턴스 프로파일이 있는지 확인합니다.

      1. IAM 역할에 연결된 인스턴스 프로파일이 있는 경우:

         1.  `aws:executeAwsApi` - AttachIAMProfileToInstance - IAM 인스턴스 프로파일 역할을 EC2 인스턴스에 연결합니다.

      1. IAM 역할에 연결된 인스턴스 프로파일이 없는 경우:

         1.  `aws:executeAwsApi` - CreateInstanceProfileForRole - 지정된 IAM 역할을 위한 인스턴스 프로파일 역할을 생성합니다.

         1.  `aws:executeAwsApi` - AddRoleToInstanceProfile - 인스턴스 프로파일 역할을 지정된 IAM 역할에 연결합니다.

         1.  `aws:executeAwsApi` - GetInstanceProfile - 지정된 IAM 역할을 위한 인스턴스 프로파일 데이터를 가져옵니다.

         1.  `aws:executeAwsApi` - AttachIAMProfileToInstanceWithRetry - IAM 인스턴스 프로파일 역할을 EC2 인스턴스에 연결합니다.

 **출력** 

AttachIAMProfileToInstanceWithRetry.AssociationId

GetInstanceProfile.InstanceProfileName

GetInstanceProfile.InstanceProfileArn

AttachIAMProfileToInstance.AssociationId

ListInstanceProfilesForRole.InstanceProfileName

ListInstanceProfilesForRole.InstanceProfileArn