

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

# CloudFormation 範本 Transform 區段
<a name="transform-section-structure"></a>

選用的 `Transform` 區段指定 CloudFormation 用來以某種方式處理您範本的一或多個巨集。

巨集可執行簡單任務，如文字查詢與替換，也可對整個範本進行更全面的轉換。CloudFormation 會按照巨集的指定順序執行。當您建立變更集時，CloudFormation 產生的變更集會包含處理過的範本內容。然後，您可以檢閱變更並執行變更集。如需有關巨集運作方式的詳細資訊，請參閱 [使用範本巨集在 CloudFormation 範本上執行自訂處理](template-macros.md)。

CloudFormation 亦支援*轉換*，這些是由 CloudFormation 託管的巨集。在執行順序和範圍方面，CloudFormation 對待這些轉換的方式與您建立的任何巨集相同。如需詳細資訊，請參閱[轉換參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/transform-reference.html)。

若要宣告多個巨集，請使用清單格式，並指定一或多個巨集。

例如，在以下範例中，CloudFormation 會評估範本 `MyMacro`，再評估 `AWS::Serverless`，這兩者都可以處理整個範本，因為其都納入 `Transform` 區段中。

```
# Start of processable content for MyMacro and AWS::Serverless
Transform:
  - MyMacro
  - 'AWS::Serverless'
Resources:
  WaitCondition:
    Type: AWS::CloudFormation::WaitCondition
  MyBucket:
    Type: AWS::S3::Bucket
    Properties: 
      BucketName: amzn-s3-demo-bucket
      Tags: [{"key":"value"}]
      CorsConfiguration: []
  MyEc2Instance:
    Type: AWS::EC2::Instance 
    Properties:
      ImageId: ami-1234567890abcdef0
# End of processable content for MyMacro and AWS::Serverless
```