@@ -309,6 +309,57 @@ module "static_site" {
309309
310310これにより、必要に応じてルートとサブフォルダで異なるデフォルトファイルを使用できます。
311311
312+ ### カスタムエラーページ使用時(SPAサポート)
313+
314+ シングルページアプリケーション(SPA)のクライアントサイドルーティングに不可欠な、CloudFront のカスタムエラーレスポンスを設定できます:
315+
316+ ``` hcl
317+ module "static_site" {
318+ source = "path/to/terraform-aws-static-site"
319+
320+ s3_bucket_name = "my-spa-bucket"
321+ cloudfront_distribution_name = "my-spa-site"
322+
323+ # SPA クライアントサイドルーティング用のエラーレスポンス設定
324+ custom_error_responses = [
325+ {
326+ error_code = 403
327+ response_code = 200
328+ response_page_path = "/index.html"
329+ },
330+ {
331+ error_code = 404
332+ response_code = 200
333+ response_page_path = "/index.html"
334+ }
335+ ]
336+
337+ providers = {
338+ aws = aws
339+ aws.us_east_1 = aws.us_east_1
340+ }
341+ }
342+ ```
343+
344+ より良いユーザーエクスペリエンスのためにカスタムエラーページを設定することもできます:
345+
346+ ``` hcl
347+ custom_error_responses = [
348+ {
349+ error_code = 404
350+ response_code = 404
351+ response_page_path = "/errors/404.html"
352+ error_caching_min_ttl = 300 # 5分間キャッシュ
353+ },
354+ {
355+ error_code = 500
356+ response_code = 500
357+ response_page_path = "/errors/500.html"
358+ error_caching_min_ttl = 60 # 1分間キャッシュ
359+ }
360+ ]
361+ ```
362+
312363### 自動キャッシュ無効化使用時
313364
314365キャッシュ無効化機能はメインモジュールに直接組み込まれています - サブモジュールは不要です。有効にすると、Lambda 関数、SQS キュー、IAM ロールを含む必要なすべての AWS リソースが自動的に作成されます。
@@ -422,6 +473,8 @@ module "static_site" {
422473| cloudfront_function_associations | デフォルトキャッシュ動作用 CloudFront 関数アソシエーションのリスト | ` list(object) ` | ` [] ` | いいえ |
423474| default_root_object | ルート URL へのリクエスト時に CloudFront が返すオブジェクト | ` string ` | ` "index.html" ` | いいえ |
424475| subfolder_root_object | 設定時、サブフォルダリクエストのデフォルトオブジェクトとしてこのファイルを提供する CloudFront 関数を作成 | ` string ` | ` "" ` | いいえ |
476+ | custom_error_responses | CloudFront のカスタムエラーレスポンス設定のリスト(SPA ルーティング用の例を参照) | ` list(object) ` | ` [] ` | いいえ |
477+ | skip_certificate_validation | ACM 証明書の DNS 検証レコードをスキップ(テスト用に便利) | ` bool ` | ` false ` | いいえ |
425478| tags | すべてのリソースに適用するタグ | ` map(string) ` | ` {} ` | いいえ |
426479
427480## 出力変数
@@ -662,7 +715,16 @@ module "static_site" {
662715
663716## 例
664717
665- 完全な例については、[ examples] ( ./examples/ ) ディレクトリを参照してください。
718+ 完全な例については、[ examples] ( ./examples/ ) ディレクトリを参照してください:
719+
720+ - [ 基本的な使用法] ( ./examples/basic/ ) - シンプルな静的ウェブサイトホスティング
721+ - [ カスタムドメイン使用例] ( ./examples/with-custom-domain/ ) - ACM 証明書付きカスタムドメインの使用
722+ - [ SPAエラーハンドリング例] ( ./examples/spa-with-error-handling/ ) - クライアントサイドルーティング付きシングルページアプリケーション
723+ - [ キャッシュ無効化使用例] ( ./examples/with-cache-invalidation/ ) - 自動 CloudFront キャッシュ無効化
724+ - [ CloudWatch ログ使用例] ( ./examples/with-logging/ ) - クロスアカウントログ配信
725+ - [ サブフォルダルートオブジェクト使用例] ( ./examples/with-subfolder-root-object/ ) - サブディレクトリからインデックスファイルを提供
726+ - [ PR プレビュー環境] ( ./examples/with-pr-preview/ ) - PR プレビュー用ワイルドカードドメイン
727+ - [ SPAサポート付きPRプレビュー] ( ./examples/with-pr-spa-preview/ ) - フル SPA ルーティングサポート付き PR プレビュー
666728
667729## ライセンス
668730
0 commit comments