本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
「自動化」是「系 Systems Manager」的一項功能,會將 AWS 資源填入 AWS Management Console 符合您為輸入參數定義的資源類型。符合資源類型之 AWS 帳戶 中的資源會顯示在下拉式清單中供您選擇。您可以為 Amazon 彈性運算雲端 (Amazon EC2) 執行個體、Amazon 簡單儲存服務 (Amazon S3) 儲存貯體和 AWS Identity and Access Management (IAM) 角色定義輸入參數類型。支援的類型定義和用來尋找相符資源的規則運算式如下:
-
AWS::EC2::Instance::Id
-
^m?i-([a-z0-9]{8}|[a-z0-9]{17})$
-
List<AWS::EC2::Instance::Id>
-
^m?i-([a-z0-9]{8}|[a-z0-9]{17})$
-
AWS::S3::Bucket::Name
-
^[0-9a-z][a-z0-9\\-\\.]{3,63}$
-
List<AWS::S3::Bucket::Name>
-
^[0-9a-z][a-z0-9\\-\\.]{3,63}$
-
AWS::IAM::Role::Arn
-
^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):iam::[0-9]{12}:role/.*$
-
List<AWS::IAM::Role::Arn>
-
^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):iam::[0-9]{12}:role/.*$
以下為 Runbook 內容中定義之輸入參數類型的範例。
- YAML
-
description: Enables encryption on an Amazon S3 bucket
schemaVersion: '0.3'
assumeRole: '{{ AutomationAssumeRole }}'
parameters:
BucketName:
type: 'AWS::S3::Bucket::Name'
description: (Required) The name of the Amazon S3 bucket you want to encrypt.
SSEAlgorithm:
type: String
description: (Optional) The server-side encryption algorithm to use for the default encryption.
default: AES256
AutomationAssumeRole:
type: 'AWS::IAM::Role::Arn'
description: (Optional) The Amazon Resource Name (ARN) of the role that allows Automation to perform the actions on your behalf.
default: ''
mainSteps:
- name: enableBucketEncryption
action: 'aws:executeAwsApi'
inputs:
Service: s3
Api: PutBucketEncryption
Bucket: '{{BucketName}}'
ServerSideEncryptionConfiguration:
Rules:
- ApplyServerSideEncryptionByDefault:
SSEAlgorithm: '{{SSEAlgorithm}}'
isEnd: true
- JSON
-
{
"description": "Enables encryption on an Amazon S3 bucket",
"schemaVersion": "0.3",
"assumeRole": "{{ AutomationAssumeRole }}",
"parameters": {
"BucketName": {
"type": "AWS::S3::Bucket::Name",
"description": "(Required) The name of the Amazon S3 bucket you want to encrypt."
},
"SSEAlgorithm": {
"type": "String",
"description": "(Optional) The server-side encryption algorithm to use for the default encryption.",
"default": "AES256"
},
"AutomationAssumeRole": {
"type": "AWS::IAM::Role::Arn",
"description": "(Optional) The Amazon Resource Name (ARN) of the role that allows Automation to perform the actions on your behalf.",
"default": ""
}
},
"mainSteps": [
{
"name": "enableBucketEncryption",
"action": "aws:executeAwsApi",
"inputs": {
"Service": "s3",
"Api": "PutBucketEncryption",
"Bucket": "{{BucketName}}",
"ServerSideEncryptionConfiguration": {
"Rules": [
{
"ApplyServerSideEncryptionByDefault": {
"SSEAlgorithm": "{{SSEAlgorithm}}"
}
}
]
}
},
"isEnd": true
}
]
}