설명
role은 ECS가 로드 밸런서를 관리할 때 사용하는 서비스 역할입니다. 명시적 역할은 로드 밸런서를 사용하고 태스크 모드가 awsvpc가 아닌 경우에만 지정할 수 있습니다.
잠재적 영향
서비스 역할의 권한이 넓으면 연동에 필요하지 않은 리소스도 변경할 수 있습니다. 애플리케이션의 태스크 역할과 이미지 가져오기·로그 전송용 실행 역할에는 각각 필요한 권한을 부여하세요.
해결 방법
서비스 역할의 관리형·인라인 정책과 신뢰 정책을 확인하고 필요한 작업과 리소스만 허용하세요. community.aws 11.1.0의 ecs_service는 기존 서비스의 역할을 갱신하지 않습니다. 기존 역할 정책을 수정하거나 지원되는 전환 방법을 사용한 뒤 역할과 대상 등록, 상태 확인 결과를 검증하세요.
예시
클러스터, 태스크 정의, 역할과 실제 target_group_arn을 준비하세요. 대상은 app의 8080 포트입니다. desired_count: 0이면 상태를 확인할 실행 중 태스크가 없습니다.
변경 전
yaml
- name: ECS Service
community.aws.ecs_service:
state: present
name: console-test-service
cluster: new_cluster
task_definition: "new_cluster-task:1"
desired_count: 0
load_balancers:
- targetGroupArn: "{{ target_group_arn }}"
containerName: app
containerPort: 8080
role: admin
변경 후
yaml
- name: ECS Service
community.aws.ecs_service:
state: present
name: console-test-service
cluster: new_cluster
task_definition: "new_cluster-task:1"
desired_count: 0
load_balancers:
- targetGroupArn: "{{ target_group_arn }}"
containerName: app
containerPort: 8080
새 서비스에서 role: admin을 생략하면 ECS는 해당 구성의 서비스 연결 역할을 사용합니다. 기존 서비스의 권한을 판단할 때는 실제 역할 정책을 확인하세요.