difficult points that make static website, using Route53, CloudFront, ACM and S3 via https

i think, there are some difficult points make https static website using Route53, CloudFront, ACM and S3.

so i searched and writing knowlege in this blog.

Route53

can’t select CloudFront distributions at CNAME Alias, after setting CloudFront.

please set Alias ” No “, and set CloudFront Domain Name in Value.


ACM

please set region US East (N. Virginia) when you get certificate.

if you other region you set, you can’t  select certificate in CloudFront AWS conslole.


CloudFront

can’t set certificate, after you get certificate at US East (N. Virginia) region.

answer 1:

please wait few days.

if you get certificate at Certification Manager, you can’t select in CloudFront immediately.

i waited few days and i could selected it.

 

ansewer 2:

you upload certificate by aws acli.

maybe you can select certificate at CloudFront AWS console immediately.

but i don’t try this method.

https://aws.amazon.com/premiumsupport/knowledge-center/custom-ssl-certificate-cloudfront/

displayed file list of XML, via CloudFront

please set ” Default Root Object ” at CloudFront AWS console.

example, ” index.html “.

Access Deny occur, when you access your domain.

please set ” Alternate Domain Names (CNAMEs) ” your domain at CloudFront AWS console.

Access Deny occur via CloudFront

please public access setting, at S3 object and bucket at S3 BucketPolicy.

i setting every thing, but i can’t access.

there is possibility used cache at CloudFront.

so remove cache at Invalidation tab of CloudFront console. and input ” /* “.


S3

you can access “static website hosting” url. but can’t via CloudFront.

there is possibility, you did’t setting public access policy at S3 object and S3 bucket.

so you setting public access setting at it.

if you have too many object.

using aws cli command is very useful.

aws s3 sync . s3://my-bucket/path –acl public-read

error occur when public access setting at S3 bucket.

please select ” false ” at Piblic access settings of Permissions.

this function is add AWS console, at November 18th, 2018.

Route53 + CloudFront + ACM + S3 で https する際にハマったこと

ネットの記事をみながら構成していくなかで、ハマったこと

Route53

CloudFront の設定が終わって、Route53 で、登録したドメインの CNAME に、CloudFront のドメイン名を登録するときAlias を選択しても、Target の候補に CroudFront が出てこない。

Alias No を選択して、Value CloudFront のドメイン名を入力しよう。


ACM

証明書をとるときは、リージョンを「バージニア北部」にしよう。

そうしないと、CloudFront の画面で取得した証明書を選択できない。


CloudFront

バージニア北部」で証明書を取得しても CloudFront の画面で設定できない。

解決方法1:

待つ。

ACM で証明書を取得しても、すぐには CloudFront の画面で選択ができない。

私は 1,2 日待ったら選択できるようになりました。

 

解決方法2:

手動でアップロードする。

私は試してないですが、手動でアップロードすることですぐに反映されるみたいです。

Amazon CloudFrontの独自ドメインSSL証明書をAWS CLIでアップロードする

CloudFront 経由で S3 にアクセスしたら、ファイル一覧の XML が表示される。

解決方法:

CloudFront の設定画面で、「Default Root Object」を設定しましょう。

例えば、index.html など。

取得したドメインで、CloudFront 経由でアクセスすると AccessDeny になる。

CloudFront Alternate Domain Names (CNAMEs)」に、

アクセスしたいドメインの値を設定しましょう。

CloudFront 経由で AccessDeny になる。

S3 バケットポリシーで、オブジェクトとバケット全体を、パブリック公開設定にしましょう。

もろもろ設定したけど、やっぱりダメだ。

CloudFront でキャッシュが残っている可能性があります。

CloudFront Invalidations “/*” を設定して、全てのキャッシュを削除してみましょう。


S3

static website hosting url にはアクセスできるが、CloudFront 経由でアクセスできない。

バケットと、オブジェクトがパブリック公開になっていない可能性があります。

バケットポリシーを公開設定にして、各オブジェクトを公開設定にしましょう。

オブジェクトが大量にある場合は、 aws cli を用いてコマンドでサイドアップロードするのが手っ取り早いです。

aws s3 sync . s3://my-bucket/path  –acl public-read

バケットポリシーを公開設定にしようとするが、エラーになる。

「アクセス権限」の「パブリックアクセス設定」を全て false にしましょう。

この機能は、201811/18から AWS に追加されました。