대규모로 자동화 실행 - AWS Systems Manager

대규모로 자동화 실행

AWS Systems Manager Automation을 사용하면 대상을 사용하여 AWS 리소스 플릿에서 자동화를 실행할 수 있습니다. 또한 동시성 값과 오류 임계값을 지정하여 플릿 전체의 자동화 배포를 제어할 수도 있습니다. 동시성 및 오류 임계값 기능을 통칭하여 속도 제어라고 합니다. 동시성 값은 자동화를 동시에 실행하도록 허용된 리소스의 수를 결정합니다. 또한 Automation은 사용자가 선택할 수 있는 적응형 동시성 모드를 제공합니다. 적응형 동시성은 동시에 실행되는 자동화 100개에서 최대 500개로 자동화 할당량을 자동으로 조정합니다. 오류 임계값은 Systems Manager가 자동화를 다른 리소스로 보내는 것을 중지할 때까지 허용되는 자동화 실패 횟수를 결정합니다.

동시성 및 오류 임계값에 대한 자세한 내용은 대규모 자동화 제어 섹션을 참조하세요. 대상에 대한 자세한 내용은 자동화를 위한 대상 매핑 섹션을 참조하세요.

다음 절차에서는 적응형 동시성을 설정하는 방법과 Systems Manager 콘솔 및 AWS Command Line Interface(AWS CLI)에서 대상 및 속도 제어 기능을 사용하는 자동화를 실행하는 방법을 설명합니다.

대상 및 속도 제어를 사용하여 자동화 실행(콘솔)

다음 절차에서는 Systems Manager 콘솔에서 대상 및 속도 제어를 사용하여 자동화를 실행하는 방법을 설명합니다.

대상 및 속도 제어를 사용하여 자동화를 실행하려면
  1. AWS Systems Manager 콘솔https://console.aws.amazon.com/systems-manager/을 엽니다.

  2. 탐색 창에서 Automation(자동화)을 선택한 후 Execute automation(자동화 실행)을 선택합니다.

  3. [Automation 문서(Automation document)] 목록에서 실행서를 선택합니다. 문서 카테고리 창에서 옵션을 1개 이상 선택하여 SSM 문서를 목적에 따라 필터링합니다. 자신이 소유한 실행서를 보려면 [내 소유(Owned by me)] 탭을 선택합니다. 자신의 계정과 공유하고 있는 실행서를 보려면 [나와 공유됨(Shared with me)] 탭을 선택합니다. 모든 실행서를 보려면 [모든 문서(All documents)] 탭을 선택합니다.

    참고

    실행서 이름을 선택하여 실행서에 대한 정보를 볼 수 있습니다.

  4. 문서 세부 정보 섹션에서 문서 버전이 실행할 버전으로 설정되었는지 확인합니다. 이 시스템에는 다음 버전 옵션이 포함되어 있습니다.

    • 런타임 시 기본 버전 - Automation 런북이 정기적으로 업데이트되며 새 기본 버전이 할당된 경우 이 옵션을 선택합니다.

    • 런타임 시 최신 버전 - Automation 런북이 정기적으로 업데이트되며 최근에 업데이트된 버전을 실행하려는 경우 이 옵션을 선택합니다.

    • 1(기본값) - 문서의 최초 버전을 실행하려면 이 옵션을 선택합니다(기본값).

  5. 다음을 선택합니다.

  6. 실행 모드 섹션에서 Rate Control(속도 제어)을 선택합니다. 대상 및 속도 제어를 사용하려면 이 모드 또는 다중 계정 및 리전을 사용해야 합니다.

  7. [대상(Targets)] 섹션에서 Automation을 실행할 AWS 리소스를 대상으로 지정할 방식을 선택합니다. 다음 옵션이 필요합니다.

    1. 파라미터를 선택하려면 파라미터 목록을 사용합니다. [파라미터(Parameter)] 목록의 항목은 이 절차의 시작 부분에서 선택한 Automation 실행서의 파라미터로 결정됩니다. 파라미터를 선택하여 자동화 워크플로에서 실행되는 리소스 유형을 정의할 수 있습니다.

    2. 리소스를 대상으로 지정하는 방식을 선택하려면 대상 목록을 사용합니다.

      1. 파라미터 값을 사용하여 리소스를 대상으로 지정하기로 선택한 경우 입력 파라미터 섹션에서 선택한 파라미터에 대한 값을 입력합니다.

      2. AWS Resource Groups을 사용하여 리소스를 대상으로 지정하기로 한 경우 리소스 그룹 목록에서 그룹의 이름을 선택합니다.

      3. 태그를 사용하여 리소스를 대상으로 지정하기로 한 경우 태그 키와 (선택 사항) 태그 값을 제공된 필드에 입력합니다. 추가를 선택합니다.

      4. 현재 AWS 계정 및 AWS 리전의 전체 인스턴스에서 Automation 실행서를 실행하려면 [전체 인스턴스(All instances)]를 선택합니다.

  8. 입력 파라미터 섹션에서 필수 입력을 지정합니다. 필요에 따라 [AutomationAssumeRole] 목록에서 IAM 서비스 역할을 선택합니다.

    참고

    입력 파라미터 섹션에서 일부 옵션은 선택할 필요가 없습니다. 그 이유는 태그 또는 리소스 그룹을 사용하여 리소스를 대상으로 지정했기 때문입니다. 예를 들어 AWS-RestartEC2Instance 실행서를 선택한 경우 [입력 파라미터(Input parameters)] 섹션에서 인스턴스 ID를 지정하거나 선택할 필요가 없습니다. Automation 실행 시, 지정된 태그 또는 리소스 그룹을 사용하여 다시 시작할 인스턴스를 찾을 수 있습니다.

  9. 각 계정-리소스 페어 내에서 Automation을 실행할 수 있는 AWS 리소스 수를 제한하려면 속도 제어 섹션의 옵션을 사용합니다.

    동시성 섹션에서 옵션을 선택합니다.

    • 대상을 선택하여 자동화 워크플로를 동시에 실행할 수 있는 대상 수(절대 개수)를 입력합니다.

    • 백분율을 선택하여 자동화 워크플로를 동시에 실행할 수 있는 대상의 백분율을 입력합니다.

  10. 오류 임계값 섹션에서 옵션을 선택합니다.

    • 오류를 선택하여 자동화를 통한 다른 리소스로의 워크플로 전송이 중지될 때까지 허용되는 오류 수(절대 개수)를 입력합니다.

    • 백분율을 선택하여 자동화를 통한 다른 리소스로의 워크플로 전송이 중지될 때까지 허용되는 백분율을 입력합니다.

  11. (선택 사항) 모니터링을 위해 자동화에 적용할 CloudWatch 경보를 선택합니다. CloudWatch 경보를 자동화에 연결하려면 자동화를 시작하는 IAM 보안 주체에 iam:createServiceLinkedRole 작업에 대한 권한이 있어야 합니다. CloudWatch 경보에 대한 자세한 내용은 Amazon CloudWatch 경보 사용을 참조하세요. 경보가 활성화되면 자동화가 중지됩니다. AWS CloudTrail을 사용하면 추적에 API 호출이 표시됩니다.

  12. 실행을 선택합니다.

속도 제어 자동화로 시작된 자동화를 보려면 탐색 창에서 Automation을 선택한 다음 [하위 자동화 표시(Show child automations)]를 선택합니다.

대상 및 속도 제어를 사용하여 자동화 실행(명령줄)

다음 절차에서는 AWS CLI(Linux 또는 Windows) 또는 AWS Tools for PowerShell에서 대상 및 속도 제어를 사용하여 자동화를 실행하는 방법을 설명합니다.

대상 및 속도 제어를 사용하여 자동화를 실행하려면
  1. 아직 하지 않은 경우 AWS CLI 또는 AWS Tools for PowerShell을 설치하고 구성합니다.

    자세한 내용은 최신 버전의 AWS CLI 설치 또는 업데이트AWS Tools for PowerShell 설치를 참조하세요.

  2. 다음 명령을 실행하여 문서 목록을 확인합니다.

    Linux & macOS
    aws ssm list-documents
    Windows
    aws ssm list-documents
    PowerShell
    Get-SSMDocumentList

    사용할 실행서의 이름을 기록해 둡니다.

  3. 다음 명령을 실행하여 런북에 대한 세부 정보를 봅니다. 실행서 이름을 세부 정보를 보려는 실행서 이름으로 바꿉니다. 또한 --target-parameter-name 옵션에 사용할 파라미터 이름(예: InstanceId)에 유의하세요. 이 파라미터는 자동화가 실행되는 리소스 유형을 결정합니다.

    Linux & macOS
    aws ssm describe-document \ --name runbook name
    Windows
    aws ssm describe-document ^ --name runbook name
    PowerShell
    Get-SSMDocumentDescription ` -Name runbook name
  4. 실행할 대상 및 속도 제어 옵션을 사용하는 명령을 생성합니다. 각 example resource placeholder를 사용자의 정보로 바꿉니다.

    태그를 사용하여 대상 지정

    Linux & macOS
    aws ssm start-automation-execution \ --document-name runbook name \ --targets Key=tag:key name,Values=value \ --target-parameter-name parameter name \ --parameters "input parameter name=input parameter value,input parameter 2 name=input parameter 2 value" \ --max-concurrency 10 \ --max-errors 25%
    Windows
    aws ssm start-automation-execution ^ --document-name runbook name ^ --targets Key=tag:key name,Values=value ^ --target-parameter-name parameter name ^ --parameters "input parameter name=input parameter value,input parameter 2 name=input parameter 2 value" ^ --max-concurrency 10 ^ --max-errors 25%
    PowerShell
    $Targets = New-Object Amazon.SimpleSystemsManagement.Model.Target $Targets.Key = "tag:key name" $Targets.Values = "value" Start-SSMAutomationExecution ` DocumentName "runbook name" ` -Targets $Targets ` -TargetParameterName "parameter name" ` -Parameter @{"input parameter name"="input parameter value";"input parameter 2 name"="input parameter 2 value"} ` -MaxConcurrency "10" ` -MaxError "25%"

    파라미터 값을 사용하여 대상 지정

    Linux & macOS
    aws ssm start-automation-execution \ --document-name runbook name \ --targets Key=ParameterValues,Values=value,value 2,value 3 \ --target-parameter-name parameter name \ --parameters "input parameter name=input parameter value" \ --max-concurrency 10 \ --max-errors 25%
    Windows
    aws ssm start-automation-execution ^ --document-name runbook name ^ --targets Key=ParameterValues,Values=value,value 2,value 3 ^ --target-parameter-name parameter name ^ --parameters "input parameter name=input parameter value" ^ --max-concurrency 10 ^ --max-errors 25%
    PowerShell
    $Targets = New-Object Amazon.SimpleSystemsManagement.Model.Target $Targets.Key = "ParameterValues" $Targets.Values = "value","value 2","value 3" Start-SSMAutomationExecution ` -DocumentName "runbook name" ` -Targets $Targets ` -TargetParameterName "parameter name" ` -Parameter @{"input parameter name"="input parameter value"} ` -MaxConcurrency "10" ` -MaxError "25%"

    AWS Resource Groups을 사용하여 대상 지정

    Linux & macOS
    aws ssm start-automation-execution \ --document-name runbook name \ --targets Key=ResourceGroup,Values=Resource group nname \ --target-parameter-name parameter name \ --parameters "input parameter name=input parameter value" \ --max-concurrency 10 \ --max-errors 25%
    Windows
    aws ssm start-automation-execution ^ --document-name runbook name ^ --targets Key=ResourceGroup,Values=Resource group name ^ --target-parameter-name parameter name ^ --parameters "input parameter name=input parameter value" ^ --max-concurrency 10 ^ --max-errors 25%
    PowerShell
    $Targets = New-Object Amazon.SimpleSystemsManagement.Model.Target $Targets.Key = "ResourceGroup" $Targets.Values = "Resource group name" Start-SSMAutomationExecution ` -DocumentName "runbook name" ` -Targets $Targets ` -TargetParameterName "parameter name" ` -Parameter @{"input parameter name"="input parameter value"} ` -MaxConcurrency "10" ` -MaxError "25%"

    현재 AWS 계정 및 AWS 리전의 모든 Amazon EC2 인스턴스를 대상으로 지정

    Linux & macOS
    aws ssm start-automation-execution \ --document-name runbook name \ --targets "Key=AWS::EC2::Instance,Values=*" \ --target-parameter-name instanceId \ --parameters "input parameter name=input parameter value" \ --max-concurrency 10 \ --max-errors 25%
    Windows
    aws ssm start-automation-execution ^ --document-name runbook name ^ --targets Key=AWS::EC2::Instance,Values=* ^ --target-parameter-name instanceId ^ --parameters "input parameter name=input parameter value" ^ --max-concurrency 10 ^ --max-errors 25%
    PowerShell
    $Targets = New-Object Amazon.SimpleSystemsManagement.Model.Target $Targets.Key = "AWS::EC2::Instance" $Targets.Values = "*" Start-SSMAutomationExecution ` -DocumentName "runbook name" ` -Targets $Targets ` -TargetParameterName "instanceId" ` -Parameter @{"input parameter name"="input parameter value"} ` -MaxConcurrency "10" ` -MaxError "25%"

    이 명령으로 실행 ID가 반환됩니다. 클립보드에 이 ID를 복사합니다. 이 ID를 사용하여 자동화 상태를 확인할 수 있습니다.

    Linux & macOS
    {
        "AutomationExecutionId": "a4a3c0e9-7efd-462a-8594-01234EXAMPLE"
    }
    Windows
    {
        "AutomationExecutionId": "a4a3c0e9-7efd-462a-8594-01234EXAMPLE"
    }
    PowerShell
    a4a3c0e9-7efd-462a-8594-01234EXAMPLE
  5. 다음 명령을 실행하여 자동화를 봅니다. 각 자동화 실행 ID를 자신의 정보를 바꿉니다.

    Linux & macOS
    aws ssm describe-automation-executions \ --filter Key=ExecutionId,Values=automation execution ID
    Windows
    aws ssm describe-automation-executions ^ --filter Key=ExecutionId,Values=automation execution ID
    PowerShell
    Get-SSMAutomationExecutionList | ` Where {$_.AutomationExecutionId -eq "automation execution ID"}
  6. 자동화 진행 상황에 대한 세부 정보를 보려면 다음 명령을 실행합니다. 각 자동화 실행 ID를 자신의 정보를 바꿉니다.

    Linux & macOS
    aws ssm get-automation-execution \ --automation-execution-id automation execution ID
    Windows
    aws ssm get-automation-execution ^ --automation-execution-id automation execution ID
    PowerShell
    Get-SSMAutomationExecution ` -AutomationExecutionId automation execution ID

    시스템은 다음과 같은 정보를 반환합니다.

    Linux & macOS
    {
        "AutomationExecution": {
            "StepExecutionsTruncated": false,
            "AutomationExecutionStatus": "Success",
            "MaxConcurrency": "1",
            "Parameters": {},
            "MaxErrors": "1",
            "Outputs": {},
            "DocumentName": "AWS-StopEC2Instance",
            "AutomationExecutionId": "a4a3c0e9-7efd-462a-8594-01234EXAMPLE",
            "ResolvedTargets": {
                "ParameterValues": [
                    "i-02573cafcfEXAMPLE"
                ],
                "Truncated": false
            },
            "ExecutionEndTime": 1564681619.915,
            "Targets": [
                {
                    "Values": [
                        "DEV"
                    ],
                    "Key": "tag:ENV"
                }
            ],
            "DocumentVersion": "1",
            "ExecutionStartTime": 1564681576.09,
            "ExecutedBy": "arn:aws:sts::123456789012:assumed-role/Administrator/Admin",
            "StepExecutions": [
                {
                    "Inputs": {
                        "InstanceId": "i-02573cafcfEXAMPLE"
                    },
                    "Outputs": {},
                    "StepName": "i-02573cafcfEXAMPLE",
                    "ExecutionEndTime": 1564681619.093,
                    "StepExecutionId": "86c7b811-3896-4b78-b897-01234EXAMPLE",
                    "ExecutionStartTime": 1564681576.836,
                    "Action": "aws:executeAutomation",
                    "StepStatus": "Success"
                }
            ],
            "TargetParameterName": "InstanceId",
            "Mode": "Auto"
        }
    }
    Windows
    {
        "AutomationExecution": {
            "StepExecutionsTruncated": false,
            "AutomationExecutionStatus": "Success",
            "MaxConcurrency": "1",
            "Parameters": {},
            "MaxErrors": "1",
            "Outputs": {},
            "DocumentName": "AWS-StopEC2Instance",
            "AutomationExecutionId": "a4a3c0e9-7efd-462a-8594-01234EXAMPLE",
            "ResolvedTargets": {
                "ParameterValues": [
                    "i-02573cafcfEXAMPLE"
                ],
                "Truncated": false
            },
            "ExecutionEndTime": 1564681619.915,
            "Targets": [
                {
                    "Values": [
                        "DEV"
                    ],
                    "Key": "tag:ENV"
                }
            ],
            "DocumentVersion": "1",
            "ExecutionStartTime": 1564681576.09,
            "ExecutedBy": "arn:aws:sts::123456789012:assumed-role/Administrator/Admin",
            "StepExecutions": [
                {
                    "Inputs": {
                        "InstanceId": "i-02573cafcfEXAMPLE"
                    },
                    "Outputs": {},
                    "StepName": "i-02573cafcfEXAMPLE",
                    "ExecutionEndTime": 1564681619.093,
                    "StepExecutionId": "86c7b811-3896-4b78-b897-01234EXAMPLE",
                    "ExecutionStartTime": 1564681576.836,
                    "Action": "aws:executeAutomation",
                    "StepStatus": "Success"
                }
            ],
            "TargetParameterName": "InstanceId",
            "Mode": "Auto"
        }
    }
    PowerShell
    AutomationExecutionId       : a4a3c0e9-7efd-462a-8594-01234EXAMPLE
    AutomationExecutionStatus   : Success
    CurrentAction               : 
    CurrentStepName             : 
    DocumentName                : AWS-StopEC2Instance
    DocumentVersion             : 1
    ExecutedBy                  : arn:aws:sts::123456789012:assumed-role/Administrator/Admin
    ExecutionEndTime            : 8/1/2019 5:46:59 PM
    ExecutionStartTime          : 8/1/2019 5:46:16 PM
    FailureMessage              : 
    MaxConcurrency              : 1
    MaxErrors                   : 1
    Mode                        : Auto
    Outputs                     : {}
    Parameters                  : {}
    ParentAutomationExecutionId : 
    ProgressCounters            : 
    ResolvedTargets             : Amazon.SimpleSystemsManagement.Model.ResolvedTargets
    StepExecutions              : {i-02573cafcfEXAMPLE}
    StepExecutionsTruncated     : False
    Target                      : 
    TargetLocations             : {}
    TargetMaps                  : {}
    TargetParameterName         : InstanceId
    Targets                     : {tag:Name}
    참고

    콘솔에서 자동화 상태를 모니터링할 수도 있습니다. 자동화 실행 목록에서 방금 실행한 자동화를 선택한 후 실행 단계 탭을 선택합니다. 이 탭은 자동화 작업의 상태를 보여줍니다.