

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

# 參考 Infrastructure Composer 中的外部檔案
<a name="using-composer-external-files"></a>

您可以使用外部檔案搭配您的 AWS Serverless Application Model (AWS SAM) 範本，重複使用重複的程式碼並整理您的專案。例如，您可能有規格所述的多個 Amazon API Gateway REST API 資源OpenAPI。您可以建立一個外部檔案，並參考每個資源，而不是複寫範本中的OpenAPI規格程式碼。

AWS Infrastructure Composer 支援下列外部檔案使用案例：
+ 外部OpenAPI規格檔案定義的 API Gateway REST API 資源。
+ AWS Step Functions 外部狀態機器定義檔案定義的狀態機器資源。

若要進一步了解如何為支援的資源設定外部檔案，請參閱下列內容：
+ `[ DefinitionBody](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-api.html#sam-api-definitionbody)` 適用於 `AWS::Serverless::Api`。
+ `[ DefinitionUri](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html#sam-statemachine-definitionuri)` 適用於 `AWS::Serverless::StateMachine`。

**注意**  
若要從 Infrastructure Composer 主控台參考具有 Infrastructure Composer 的外部檔案，您必須在**本機同步**模式下使用 Infrastructure Composer。如需詳細資訊，請參閱[在 Infrastructure Composer 主控台中本機同步和儲存您的專案](using-composer-project-local-sync.md)。

**Topics**
+ [Infrastructure Composer 外部參考檔案的最佳實務](using-composer-external-files-best-practices.md)
+ [在 Infrastructure Composer 中建立外部檔案參考](using-composer-external-files-new.md)
+ [在 Infrastructure Composer 中使用外部檔案參考載入專案](using-composer-external-files-load.md)
+ [在 Infrastructure Composer 中建立參考外部檔案的應用程式](using-composer-external-files-examples-example3.md)
+ [使用 Infrastructure Composer 參考OpenAPI規格外部檔案](using-composer-external-files-examples-example1.md)