Automation 시스템 변수 - AWS Systems Manager

Automation 시스템 변수

AWS Systems Manager Automation 실행서는 다음 변수를 사용합니다. 이러한 변수를 사용하는 방법의 예는 AWS-UpdateWindowsAmi 실행서의 JSON 원본을 참조하세요.

AWS-UpdateWindowsAmi 실행서의 JSON 소스를 보려면
  1. AWS Systems Manager 콘솔(https://console.aws.amazon.com/systems-manager/)을 엽니다.

  2. 탐색 창에서 Documents를 선택합니다.

  3. 문서 목록에서 검색 창을 사용하거나 검색 창 오른쪽의 숫자를 사용하여 실행서 AWS-UpdateWindowsAmi를 선택합니다.

  4. 콘텐츠 탭을 선택합니다.

시스템 변수

Automation 실행서는 다음 시스템 변수를 지원합니다.

변수 Details

global:ACCOUNT_ID

Automation이 실행되는 사용자 또는 역할의 AWS 계정 ID입니다.

global:DATE

yyyy-MM-dd 형식의 날짜(런타임 시).

global:DATE_TIME

yyyy-MM-dd_HH.mm.ss 형식의 날짜와 시간(런타임 시).

global:AWS_PARTITION

리소스가 있는 파티션. 표준 AWS 리전에서 파티션은 aws입니다. 다른 파티션에 있는 리소스의 경우 파티션은 aws-partitionname입니다. 예를 들어 AWS GovCloud(미국 서부) 리전의 리소스 파티션은 aws-us-gov입니다.

global:REGION

실행서가 실행되는 리전입니다. 예: us-east-2.

Automation 변수

Automation 실행서는 다음 자동화 변수를 지원합니다.

변수 Details

automation:EXECUTION_ID

현재 자동화에 할당된 고유 식별자입니다. 예를 들면 1a2b3c-1a2b3c-1a2b3c-1a2b3c1a2b3c1a2b3c입니다.

용어

다음 용어는 변수 및 파라미터 확인 방식을 설명합니다.

용어 정의

Constant ARN

변수가 없는 유효한 Amazon 리소스 이름(ARN)입니다.

arn:aws:iam::123456789012:role/roleName

실행서 파라미터

실행서 수준에서 정의된 파라미터(예:instanceId)입니다. 파라미터는 기본 문자열 대체 항목으로 사용됩니다. 값은 실행 시작 시점에 제공됩니다.

{ "description": "Create Image Demo", "version": "0.3", "assumeRole": "Your_Automation_Assume_Role_ARN", "parameters":{ "instanceId": { "type": "String", "description": "Instance to create image from" } }

시스템 변수

실행서의 일부를 평가할 때 실행서에 대체 항목으로 제공되는 일반 변수입니다.

"activities": [ { "id": "copyImage", "activityType": "AWS-CopyImage", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "ImageName": "{{imageName}}", "SourceImageId": "{{sourceImageId}}", "SourceRegion": "{{sourceRegion}}", "Encrypted": true, "ImageDescription": "Test CopyImage Description created on {{global:DATE}}" } } ]

자동화 변수

실행서의 일부를 평가할 때 실행서에 대체 항목으로 제공되는 자동화 관련 변수입니다.

{ "name": "runFixedCmds", "action": "aws:runCommand", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "DocumentName": "AWS-RunPowerShellScript", "InstanceIds": [ "{{LaunchInstance.InstanceIds}}" ], "Parameters": { "commands": [ "dir", "date", "“{{outputFormat}}” -f “left”,”right”,”{{global:DATE}}”,”{{automation:EXECUTION_ID}}” ] } } }

Systems Manager 파라미터

AWS Systems Manager Parameter Store에서 정의된 변수입니다. 단계 입력에서는 직접 참조할 수 없습니다. 파라미터에 액세스하려면 권한이 필요할 수 있습니다.

description: Launch new Windows test instance schemaVersion: '0.3' assumeRole: '{{AutomationAssumeRole}}' parameters: AutomationAssumeRole: type: String default: '' description: >- (Required) The ARN of the role that allows Automation to perform the actions on your behalf. If no role is specified, Systems Manager Automation uses your IAM permissions to run this runbook. LatestAmi: type: String default: >- {{ssm:/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base}} description: The latest Windows Server 2016 AMI queried from the public parameter. mainSteps: - name: launchInstance action: 'aws:runInstances' maxAttempts: 3 timeoutSeconds: 1200 onFailure: Abort inputs: ImageId: '{{LatestAmi}}' ...

지원되는 시나리오

시나리오 설명

생성 시 상수 ARN assumeRole.

호출 사용자가 지정된 assumeRole을 전달하도록 허용되는지 확인하는 권한 부여 확인이 수행됩니다.

{ "description": "Test all Automation resolvable parameters", "schemaVersion": "0.3", "assumeRole": "arn:aws:iam::123456789012:role/roleName", "parameters": { ...

자동화가 시작될 때 AssumeRole에 제공되는 실행서 파라미터입니다.

실행서의 파라미터 목록에서 정의되어야 합니다.

{ "description": "Test all Automation resolvable parameters", "schemaVersion": "0.3", "assumeRole": "{{dynamicARN}}", "parameters": { ...

시작 시 실행서 파라미터에 제공된 값입니다.

고객이 파라미터에 사용할 값을 제공합니다. 시작 시 제공된 입력이 실행서의 파라미터 목록에 정의되어야 합니다.

... "parameters": { "amiId": { "type": "String", "default": "ami-12345678", "description": "list of commands to run as part of first step" }, ...

자동화 실행 시작에 입력되는 항목: {"amiId" : ["ami-12345678"] }

실행서 내용 내에서 참조되는 Systems Manager 파라미터입니다.

변수는 고객의 계정 내에 존재하거나 공개적으로 액세스 가능한 파라미터이며 실행서의 AssumeRole은 변수에 액세스할 수 있습니다. 생성 시 AssumeRole에 액세스 권한이 있는지 확인이 이루어집니다. 이 파라미터는 단계 입력에서 직접 참조할 수 없습니다.

... parameters: LatestAmi: type: String default: >- {{ssm:/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base}} description: The latest Windows Server 2016 AMI queried from the public parameter. mainSteps: - name: launchInstance action: 'aws:runInstances' maxAttempts: 3 timeoutSeconds: 1200 onFailure: Abort inputs: ImageId: '{{LatestAmi}}' ...

단계 정의 내에서 참조되는 시스템 변수

자동화가 시작될 때 시스템 변수가 실행서로 대체됩니다. 실행서에 입력된 값은 대체가 이루어진 시점과 관련이 있습니다. 즉, 그 사이의 단계를 실행하는 데 걸리는 시간 때문에 1단계에 입력된 시간 변수의 값은 3단계에 입력된 값과 다릅니다. 시스템 변수를 실행서의 파라미터 목록에 설정할 필요가 없습니다.

... "mainSteps": [ { "name": "RunSomeCommands", "action": "aws:runCommand", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "DocumentName": "AWS:RunPowerShell", "InstanceIds": ["{{LaunchInstance.InstanceIds}}"], "Parameters": { "commands" : [ "echo {The time is now {{global:DATE_TIME}}}" ] } } }, ...

단계 정의 내에서 참조되는 자동화 변수.

자동화 변수를 실행서의 파라미터 목록에 설정할 필요가 없습니다. 지원되는 유일한 자동화 변수는 automation:EXECUTION_ID입니다.

... "mainSteps": [ { "name": "invokeLambdaFunction", "action": "aws:invokeLambdaFunction", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "FunctionName": "Hello-World-LambdaFunction", "Payload" : "{ "executionId" : "{{automation:EXECUTION_ID}}" }" } } ...

다음 단계 정의에 포함된 이전 단계의 출력을 참조하십시오.

이는 파라미터 리디렉션입니다. 이전 단계의 출력은 구문 {{stepName.OutputName}}을 이용해 참조됩니다. 고객은 이 구문을 실행서 파라미터에 사용할 수 없습니다. 이것은 참조 단계가 실행될 때 해결됩니다. 파라미터가 실행서의 파라미터에 열거되지 않습니다.

... "mainSteps": [ { "name": "LaunchInstance", "action": "aws:runInstances", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "ImageId": "{{amiId}}", "MinInstanceCount": 1, "MaxInstanceCount": 2 } }, { "name":"changeState", "action": "aws:changeInstanceState", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "InstanceIds": ["{{LaunchInstance.InstanceIds}}"], "DesiredState": "terminated" } } ...

지원되지 않는 시나리오

시나리오 설명

생성 시 assumeRole에 제공되는 Systems Manager 파라미터입니다.

지원하지 않음.

... { "description": "Test all Automation resolvable parameters", "schemaVersion": "0.3", "assumeRole": "{{ssm:administratorRoleARN}}", "parameters": { ...

Systems Manager 파라미터는 단계 입력에서 직접 참조할 수 있습니다.

생성 시 InvalidDocumentContent 예외를 반환합니다.

... mainSteps: - name: launchInstance action: 'aws:runInstances' maxAttempts: 3 timeoutSeconds: 1200 onFailure: Abort inputs: ImageId: '{{ssm:/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base}}' ...

변수 단계 정의

실행서에서 단계의 정의는 변수에 의해 구성됩니다.

... "mainSteps": [ { "name": "LaunchInstance", "action": "aws:runInstances", "{{attemptModel}}": 1, "onFailure": "Continue", "inputs": { "ImageId": "ami-12345678", "MinInstanceCount": 1, "MaxInstanceCount": 2 } ... User supplies input : { "attemptModel" : "minAttempts" }

실행서 파라미터 상호 참조

시작 시 사용자가 실행서 내 다른 파라미터에 대한 참조인 입력 파라미터를 제공합니다.

... "parameters": { "amiId": { "type": "String", "default": "ami-7f2e6015", "description": "list of commands to run as part of first step" }, "alternateAmiId": { "type": "String", "description": "The alternate AMI to try if this first fails". "default" : "{{amiId}}" }, ...

다중 확장

실행서가 변수의 이름으로 평가되는 변수를 정의합니다. 이는 변수 구분 기호(즉 {{ }}) 내에 포함되고 해당 변수/파라미터의 값으로 확장됩니다.

... "parameters": { "firstParameter": { "type": "String", "default": "param2", "description": "The parameter to reference" }, "secondParameter": { "type": "String", "default" : "echo {Hello world}", "description": "What to run" } }, "mainSteps": [{ "name": "runFixedCmds", "action": "aws:runCommand", "maxAttempts": 1, "onFailure": "Continue", "inputs": { "DocumentName": "AWS-RunPowerShellScript", "InstanceIds" : "{{LaunchInstance.InstanceIds}}", "Parameters": { "commands": [ "{{ {{firstParameter}} }}"] } ... Note: The customer intention here would be to run a command of "echo {Hello world}"

변수 유형이 다른 실행서 단계의 출력을 참조

사용자가 이후 단계에서 이전 실행서 단계의 출력을 참조합니다. 출력이 이후 단계 작업의 요구 사항을 충족하지 않는 변수 유형입니다.

... mainSteps: - name: getImageId action: aws:executeAwsApi inputs: Service: ec2 Api: DescribeImages Filters: - Name: "name" Values: - "{{ImageName}}" outputs: - Name: ImageIdList Selector: "$.Images" Type: "StringList" - name: copyMyImages action: aws:copyImage maxAttempts: 3 onFailure: Abort inputs: SourceImageId: {{getImageId.ImageIdList}} SourceRegion: ap-northeast-2 ImageName: Encrypted Copies of LAMP base AMI in ap-northeast-2 Encrypted: true ... Note: You must provide the type required by the Automation action. In this case, aws:copyImage requires a "String" type variable but the preceding step outputs a "StringList" type variable.