Universal link をAWS CloudFrontでホスティングして構築する
iOS アプリのUniversal linksを、S3, CloudFront, ACM, Route53で構築
必要なもの
Apple Developer team identifier, bundle identifier
静的ホスティング
SSL設定済みのHosted zone
取得したドメインをRoute53+ACMでSSL証明書設定してホスティング
リダイレクトしない
index.html と json形式の apple-app-site-association ファイルを置く
Universal links
ドメイン
適当に取得したドメイン
CloudFrontのURIでも可能
やること
CloudFront + S3 + Route53 で独自ドメインを使ってホストする
S3 だけだとhttpsでホストできない
手順
1. 独自ドメインの設定
2. S3 でバケットを作る
3. index.html, apple-app-site-association ファイルを作成
Universal links参照
4. 作成したファイルを作成したバケットに配置
5. S3の Static Hosting を有効化
6. CloudFront Distribution 作成
Origin Settings
table:
Origin Domain Name 作成したS3のバケットを指定
Restrict Bucket Access yes
Origin Access Identity create new identity
Grant Read Permissions on Bucket yes
Default Cache Behavior Settings
table:
Viewer Protocol Policy Redirect HTTP to HTTPS
Distributtion Settings
table:
Altername Domain Names (CNAMEs) ドメイン
SSL Certificatescustom SSL certificate で証明書指定
Default Root Object index.html
Bucket for logs ログを保存するS3バケットを指定
logは指定しなくてもOK
create certificate at ACM
7. Route53で Hosted Zoneを開き、 Create Record Set → aliasから CloudFront のdistributionを指定
8. 待つ
注意
CloudFrontからは バージニアリージョンの証明書しか使えない
CloudFrontはdefaultでキャッシュの有効期限が24時間なので検証/変更時はinvalidationが必要
SSL設定ができてないとアクセスしてもセキュリティアラートが表示される
参考
https://qiita.com/THHacker/items/11eadffe6b3ce3491e3b
https://qiita.com/jasbulilit/items/73d70a01a5d3b520450f