

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

# 使用範本巨集在 CloudFormation 範本上執行自訂處理
<a name="template-macros"></a>

透過巨集，讓可您在範本上執行自訂處理，例如尋找和取代操作這種簡單動作，乃至於全部範本的大規模轉換。

若要了解可能性的廣度，請考慮使用 `AWS::Include` 和 `AWS::Serverless` 轉換 (由 CloudFormation 託管的巨集)：
+ [AWS::Include 轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/transform-aws-include.html)可讓您將樣板式範本程式碼片段插入範本中。
+ [AWS::Serverless 轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/transform-aws-serverless.html)採用以無 AWS 伺服器應用程式模型 (AWS SAM) 語法編寫的整個範本，並將其轉換並擴展為合規的 CloudFormation 範本。如需無伺服器應用程式的詳細資訊 AWS SAM，請參閱 [AWS Serverless Application Model 開發人員指南](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html)。

**Topics**
+ [帳單](#template-macros-billing)
+ [巨集範例](#template-macros-examples-list)
+ [相關資源](#template-macros-related-resources)
+ [CloudFormation 巨集概觀](template-macros-overview.md)
+ [建立 CloudFormation 巨集定義](template-macros-author.md)
+ [簡單字串取代巨集範](macros-example.md)
+ [疑難排解處理過的範本](template-macros-troubleshoot-processed-template.md)

## 帳單
<a name="template-macros-billing"></a>

當巨集執行時，Lambda 函數的擁有者需要支付執行該函數的任何相關費用。

`AWS::Include` 和 `AWS::Serverless` 轉換是由 CloudFormation 託管的巨集。可免費使用它們。

## 巨集範例
<a name="template-macros-examples-list"></a>

除了本區段中的此範例外，您還可以在我們的 [GitHub 程式碼庫](https://github.com/aws-cloudformation/aws-cloudformation-templates/tree/main/CloudFormation/MacrosExamples)中找到包含原始程式碼和範本的巨集範例。這些範例「按現狀」提供作為教學用途。

## 相關資源
<a name="template-macros-related-resources"></a>
+ [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-cloudformation-macro.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-cloudformation-macro.html)
+ [CloudFormation 範本 Transform 區段](transform-section-structure.md)
+ [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-transform.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-transform.html)
+ [AWS::Serverless 轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/transform-aws-serverless.html)
+ [AWS::Include 轉換](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/transform-aws-include.html)