태스크를 위한 Windows IAM 역할에 대한 추가 구성 - Amazon Elastic Container Service

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

태스크를 위한 Windows IAM 역할에 대한 추가 구성

중요

작업 역할을 사용하는 Fargate의 Windows 컨테이너의 경우 추가 조치가 필요하지 않습니다. 작업 역할을 사용하는 EC2의 Windows 컨테이너의 경우 다음 단계를 수행합니다.

Windows 기능이 있는 작업을 위한 IAM 역할에는 EC2의 추가 구성이 필요하지만 이러한 구성의 상당 부분은 Linux 컨테이너 인스턴스에서의 작업을 위한 IAM 역할 구성과 유사합니다. Windows 컨테이너용 태스크에 대한 IAM 역할을 구성하려면 다음 요구 사항을 충족해야 합니다.

  • 컨테이너 인스턴스를 시작할 때 컨테이너 인스턴스 사용자 데이터 스크립트에 -EnableTaskIAMRole 옵션을 설정해야 합니다. EnableTaskIAMRole은 태스크에 대한 태스크 IAM 역할 기능을 켭니다. 예:

    <powershell> Import-Module ECSTools Initialize-ECSAgent -Cluster 'windows' -EnableTaskIAMRole </powershell>
  • 작업 컨테이너 부트스트랩 스크립트를 위한 IAM 역할에서 제공되는 네트워킹 명령을 사용하여 컨테이너를 부트스트랩해야 합니다.

  • 태스크를 위한 IAM 역할과 정책을 생성해야 합니다. 자세한 정보는 작업에 대한 IAM 역할 및 정책 생성을 참조하세요.

  • 태스크 정의를 등록할 때 또는 태스크를 실행할 때 재정의로 태스크를 위해 생성한 IAM 역할을 지정해야 합니다. 자세한 정보는 작업에 대한 IAM 역할 지정 섹션을 참조하세요.

  • 작업 자격 증명 공급자를 위한 IAM 역할은 컨테이너 인스턴스에서 포트 80을 사용합니다. 따라서 컨테이너 인스턴스에서 태스크에 대한 IAM 역할을 구성하면 컨테이너는 어떤 포트 매핑에서도 호스트 포트로 포트 80을 사용할 수 없습니다. 포트 80에서 컨테이너를 노출하려면 로드 밸런싱을 사용하는 컨테이너를 위한 서비스를 구성하는 것이 좋습니다. 로드 밸런서에서 포트 80을 사용할 수 있습니다. 이렇게 하면 트래픽을 컨테이너 인스턴스 상의 다른 호스트 포트로 라우팅할 수 있습니다. 자세한 정보는 서비스 로드 밸런싱 섹션을 참조하세요.

  • Windows 인스턴스가 다시 시작되면 프록시 인터페이스를 삭제하고 Amazon ECS 컨테이너 에이전트를 다시 초기화하여 자격 증명 프록시를 다시 불러와야 합니다.

작업 컨테이너 부트스트랩 스크립트를 위한 IAM 역할

컨테이너가 컨테이너 인스턴스에서 자격 증명 프록시에 액세스하여 자격 증명을 얻으려면 먼저 필요한 네트워킹 명령을 사용하여 컨테이너를 부트스트랩해야 합니다. 다음 코드 예제 스크립트는 시작할 때 컨테이너에서 실행되어야 합니다.

참고

Windows에서 awsvpc 네트워크 모드를 사용할 때 이 스크립트를 실행할 필요가 없습니다.

Powershell이 포함된 Windows 컨테이너를 실행하는 경우 다음 스크립트를 사용하세요.

# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You may # not use this file except in compliance with the License. A copy of the # License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is distributed # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language governing # permissions and limitations under the License. $gateway = (Get-NetRoute | Where { $_.DestinationPrefix -eq '0.0.0.0/0' } | Sort-Object RouteMetric | Select NextHop).NextHop $ifIndex = (Get-NetAdapter -InterfaceDescription "Hyper-V Virtual Ethernet*" | Sort-Object | Select ifIndex).ifIndex New-NetRoute -DestinationPrefix 169.254.170.2/32 -InterfaceIndex $ifIndex -NextHop $gateway -PolicyStore ActiveStore # credentials API New-NetRoute -DestinationPrefix 169.254.169.254/32 -InterfaceIndex $ifIndex -NextHop $gateway -PolicyStore ActiveStore # metadata API

Command 셸만 있는 Windows 컨테이너를 실행하는 경우 다음 스크립트를 사용합니다.

# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You may # not use this file except in compliance with the License. A copy of the # License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is distributed # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either # express or implied. See the License for the specific language governing # permissions and limitations under the License. for /f "tokens=1" %i in ('netsh interface ipv4 show interfaces ^| findstr /x /r ".*vEthernet.*"') do set interface=%i for /f "tokens=3" %i in ('netsh interface ipv4 show addresses %interface% ^| findstr /x /r ".*Default.Gateway.*"') do set gateway=%i netsh interface ipv4 add route prefix=169.254.170.2/32 interface="%interface%" nexthop="%gateway%" store=active # credentials API netsh interface ipv4 add route prefix=169.254.169.254/32 interface="%interface%" nexthop="%gateway%" store=active # metadata API