

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# CloudFormation
<a name="automation-ref-cfn"></a>

 AWS Systems Manager 自動化為 提供預先定義的 Runbook AWS CloudFormation。如需有關執行手冊的詳細資訊，請參閱 [Working with runbooks](https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-documents.html)。如需如何檢視 Runbook 內容的詳細資訊，請參閱 [檢視 Runbook 內容](automation-runbook-reference.md#view-automation-json)。

**Topics**
+ [`AWS-DeleteCloudFormationStack`](automation-aws-deletecloudformationstack.md)
+ [`AWS-EnableCloudFormationSNSNotification`](AWS-EnableCloudFormationStackSNSNotification.md)
+ [`AWS-RunCfnLint`](automation-aws-runcfnlint.md)
+ [`AWSSupport-TroubleshootCFNCustomResource`](automation-awssupport-TroubleshootCFNCustomResource.md)
+ [`AWS-UpdateCloudFormationStack`](automation-aws-updatecloudformationstack.md)

# `AWS-DeleteCloudFormationStack`
<a name="automation-aws-deletecloudformationstack"></a>

 **Description** 

刪除 CloudFormation 堆疊。

 [執行此自動化 （主控台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWS-DeleteCloudFormationStack) 

**文件類型**

 自動化

**擁有者**

Amazon

**平台**

Linux、macOS、 Windows

**參數**
+ AutomationAssumeRole

  類型：字串

  描述：（選用） 允許 Systems Manager Automation 代表您執行動作的 (IAM) 角色的 AWS Identity and Access Management Amazon Resource Name (ARN)。如果未指定角色，Systems Manager Automation 會使用啟動此 Runbook 之使用者的許可。
+ StackNameOrId

  類型：字串

  描述：（必要） 要刪除之 CloudFormation 堆疊的名稱或唯一 ID

# `AWS-EnableCloudFormationSNSNotification`
<a name="AWS-EnableCloudFormationStackSNSNotification"></a>

 **Description** 

 `AWS-EnableCloudFormationSNSNotification` Runbook 會為您指定的 () 堆疊啟用 Amazon Simple Notification Service AWS CloudFormation (Amazon SNS CloudFormation) 通知。

 [執行此自動化 （主控台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWS-EnableCloudFormationStackSNSNotification) 

**文件類型**

 自動化

**擁有者**

Amazon

**平台**

Linux、macOS、 Windows

**參數**
+ AutomationAssumeRole

  類型：字串

  描述：（選用） 允許 Systems Manager Automation 代表您執行動作的 (IAM) 角色的 AWS Identity and Access Management Amazon Resource Name (ARN)。如果未指定角色，Systems Manager Automation 會使用啟動此 Runbook 的使用者許可。
+ StackArn

  類型：字串

  描述：（必要） 您要為其啟用 Amazon SNS 通知的 CloudFormation 堆疊 ARN 或名稱。
+ NotificationArn

  類型：字串

  描述：（必要） 您要與 CloudFormation 堆疊建立關聯的 Amazon SNS 主題 ARN。

**必要的 IAM 許可**

`AutomationAssumeRole` 參數需要下列動作才能成功使用 Runbook。
+ ssm:GetAutomationExecution
+ ssm:StartAutomationExecution
+ cloudformation:DescribeStacks
+ cloudformation:UpdateStack
+ kms:解密
+ kms:產生資料金鑰
+ sns:Publish
+ sqs:GetQueueAttributes

 **文件步驟** 
+ CheckCfnSnsLimits (`aws:executeScript`) - 驗證尚未與您指定的 CloudFormation 堆疊建立關聯的 Amazon SNS 主題數量上限。
+ EnableCfnSnsNotification (`aws:executeAwsApi`) - 啟用 CloudFormation 堆疊的 Amazon SNS 通知。
+ VerificationCfnSnsNotification (`aws:executeScript`) - 驗證堆疊是否已啟用 Amazon SNS 通知 CloudFormation 。

 **輸出** 

CheckCfnSnsLimits.NotificationArnList - 接收 CloudFormation 堆疊 Amazon SNS 通知的 ARNs 清單。

VerificationCfnSnsNotification.VerifySnsTopicsResponse - API 操作的回應，確認 CloudFormation 堆疊已啟用 Amazon SNS 通知。

# `AWS-RunCfnLint`
<a name="automation-aws-runcfnlint"></a>

 **Description** 

 此 Runbook 使用 [AWS CloudFormation Linter](https://github.com/aws-cloudformation/cfn-python-lint) `cfn-python-lint` () 來驗證 YAML 和 JSON 範本是否符合 CloudFormation 資源規格。`AWS-RunCfnLint` Runbook 會執行其他檢查，例如確保已輸入資源屬性的有效值。如果驗證不成功，則 `RunCfnLintAgainstTemplate` 步驟會失敗，且會在錯誤訊息中提供 Linter 工具的輸出。此 Runbook 使用 using cfn-lint v0.24.4。

 [執行此自動化 （主控台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWS-RunCfnLint) 

**文件類型**

 自動化

**擁有者**

Amazon

**平台**

Linux、macOS、 Windows

**參數**
+ AutomationAssumeRole

  類型：字串

  描述：（選用） 允許 Systems Manager Automation 代表您執行動作的 (IAM) 角色的 AWS Identity and Access Management Amazon Resource Name (ARN)。如果未指定角色，Systems Manager Automation 會使用啟動此 Runbook 的使用者許可。
+ ConfigureRuleFlag

  類型：字串

   描述：(選用) 規則要傳遞至 `--configure-rule` 參數的組態選項。

  範例：E2001:strict=false,E3012:strict=false。
+ FormatFlag

  類型：字串

   描述：(選用) 要傳遞給 `--format` 參數以指定輸出格式的值。

  有效值：預設 \$1 安靜 \$1 可剖析 \$1 json

  預設：Default
+ IgnoreChecksFlag

  類型：字串

  描述：(選用) 要傳遞至 --ignore-checks 參數的規則 ID。不會檢查這些規則。

  範例：E1001,E1003,W7001
+ IncludeChecksFlag

  類型：字串

   描述：(選用) 要傳遞至 `--include-checks` 參數的規則 ID。將會檢查這些規則。

  範例：E1001,E1003,W7001
+ InfoFlag

  類型：字串

   描述：(選用) `--info` 參數的選項。包含啟用範本處理的其他記錄資訊的選項。

  預設：false
+ TemplateFileName

  類型：字串

  描述：S3 儲存貯體中範本檔案的名稱或鍵。
+ TemplateS3BucketName

  類型：字串

  描述：包含套件程式範本的 S3 儲存貯體名稱。
+ RegionsFlag

  類型：字串

   描述：（選用） 要傳遞到 的值，讓 `--regions` 參數根據指定的 測試範本 AWS 區域。

  範例：us-east-1、us-west-1

 **文件步驟** 

 RunCfnLintAgainstTemplate – 根據指定的 CloudFormation 範本執行`cfn-python-lint`工具。

 **輸出** 

 RunCfnLintAgainstTemplate.output – `cfn-python-lint`工具中的 stdout。

# `AWSSupport-TroubleshootCFNCustomResource`
<a name="automation-awssupport-TroubleshootCFNCustomResource"></a>

 **Description** 

 `AWSSupport-TroubleshootCFNCustomResource` Runbook 可協助診斷 AWS CloudFormation 堆疊在建立、更新或刪除自訂資源時失敗的原因。Runbook 會檢查用於自訂資源的服務權杖，以及傳回的錯誤訊息。檢閱自訂資源的詳細資訊後，執行手冊輸出會提供自訂資源堆疊行為和疑難排解步驟的說明。

 [執行此自動化 （主控台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWSSupport-TroubleshootCFNCustomResource) 

**文件類型**

 自動化

**擁有者**

Amazon

**平台**

Linux、macOS、 Windows

**參數**
+ AutomationAssumeRole

  類型：字串

  描述：（選用） 允許 Systems Manager Automation 代表您執行動作的 (IAM) 角色的 AWS Identity and Access Management Amazon Resource Name (ARN)。如果未指定角色，Systems Manager Automation 會使用啟動此 Runbook 的使用者許可。
+ StackName

  類型：字串

  描述：（必要） 自訂資源失敗的 CloudFormation 堆疊名稱。

**必要的 IAM 許可**

`AutomationAssumeRole` 參數需要下列動作才能成功使用 Runbook。
+  `cloudformation:DescribeStacks` 
+  `cloudformation:DescribeStackEvents` 
+  `cloudformation:ListStackResources` 
+  `ec2:DescribeRouteTables` 
+  `ec2:DescribeNatGateways` 
+  `ec2:DescribeSecurityGroups` 
+  `ec2:DescribeVpcs` 
+  `ec2:DescribeVpcEndpoints` 
+  `ec2:DescribeSubnets` 
+  `logs:FilterLogEvents` 

 **文件步驟** 
+  `validateCloudFormationStack` - 驗證 CloudFormation 堆疊是否存在於相同的 AWS 帳戶 和 中 AWS 區域。
+  `checkCustomResource` - 分析 CloudFormation 堆疊、檢查失敗的自訂資源，並輸出有關如何對失敗的自訂資源進行故障診斷的資訊。

# `AWS-UpdateCloudFormationStack`
<a name="automation-aws-updatecloudformationstack"></a>

 **Description** 

使用存放在 Amazon S3 儲存貯體中的 CloudFormation 範本來更新 AWS CloudFormation 堆疊。

 [執行此自動化 （主控台）](https://console.aws.amazon.com/systems-manager/automation/execute/AWS-UpdateCloudFormationStack) 

**文件類型**

 自動化

**擁有者**

Amazon

**平台**

Linux、macOS、 Windows

**參數**
+ AutomationAssumeRole

  類型：字串

  描述：（選用） 允許 Systems Manager Automation 代表您執行動作的 (IAM) 角色的 AWS Identity and Access Management Amazon Resource Name (ARN)。如果未指定角色，Systems Manager Automation 會使用啟動此 Runbook 之使用者的許可。
+ LambdaAssumeRole

  類型：字串

  描述：（必要） Lambda 所擔任角色的 ARN
+ StackNameOrId

  類型：字串

  描述：（必要） 要更新的 CloudFormation 堆疊名稱或唯一 ID
+ TemplateUrl

  類型：字串

   描述：（必要） 包含更新 CloudFormation 範本的 S3 儲存貯體位置 （例如 `https://s3.amazonaws.com/amzn-s3-demo-bucket2/updated.template)` 