Overview# I used AWS CDK to create a static site with CloudFront + S3. Additionally, I used CloudFront Functions to add Basic authentication and processing to append index.html to requests that do not include a filename or extension in the URL. I also added a custom domain, so this is a memo of the process.
While somewhat incomplete, the source code is available in the following repository.
https://github.com/nakamura196/staticBasic
The intended use is to prepare an .env file like the following and run cdk deploy.
C R B R A D E E U E C O R C C G C M T O K I O A _ R E O U I A D T N N N R _ _ = T _ N N N u = N = A A s y A a M M - y M r E E e y E n = = a y = : a a s b a a a t b w a a - b s . . 1 . : b b c a b b o c b b m m . . : c c x o o x m m x x
The explanation for each item is as follows.
Item Description Example CERT_ARN Certificate ARN arn:aws:acm:xxxx RECORD_NAME Domain name to configure aaa.bbb.com BUCKET_NAME S3 bucket name for file storage aaa.bbb.com REGION Region name us-east-1 ACCOUNT AWS account number (12-digit number) 123456789012 DOMAIN_NAME Hosted zone name bbb.com
Stack# The following Stack was created.
i } i i i i i i i i d e } m m m m m m m m m o x p S S R a a a f p p p p p p p p t p c } o t t e w w w r o o o o o o o o e o o r a a m s s s o r r r r r r r r n r n s c c c c c } c } c ) c } w c } c ) c } n } t c c o _ _ _ m t t t t t t t t v t s u o o o o o ) o ) o ; o ) e o ) o ; o ) e ) k k v c c i . t p n n n n n d ; n r a b ; n t " { } n a e p ] r ; b n c } ; n t " c n d c c d d } p ; w r z t ) ; { , P a l l a " { { c c r e s s s s ホ s o S s e u u C s h O S s c f r , e s C s o ) 証 s h C e C s o e o e e , r R e a , r l o o m a o l u r t t t t ス t m 3 t m t c l t i r c 3 t t f i n ) s i l t d f , 明 t i e r l t m r m f f a c c v o } f ] i o r c n r n o P u u , w C a a a a a C a n a c ( ト a バ o o k o s i o バ i e n e , o t o e i 書 s r t o a t m a a l a a i r ) u , c u o ド o ホ e エ g e p o d d s o s s s s s e s f s t s r d b c ゾ h i ケ w v D e u o , g m ケ w o c c w o u e u c : l を c , t u d i i e u u l c c e a i o , n { } e t u メ r ス : イ e w s l f f - n r i s o c e o u e ー o n ッ e a e t d r i m ッ e n t i r r B d f e 取 e i d i n f n l l o h h w w g r c , C e t イ d ト リ t , i r r c s s i c r t t d g r o c m c r ン s N ト b l l N F i n e ト b s : p a i c u F F a P 得 r f F s N i t t t w e e e s i i t f e l 5 e ン N ゾ h ア : t c o o d t 3 a l o a i o ( S ( p o a k t I t a を s P e a r g A n ポ S : a w g e c r u w a t i r t a c : R B e d P r _ n g i u v a 3 5 指 a ー o ス a y n n k r m o u r f t ) t s e r i e D e m 作 i o t m o i c t リ i i l s i s k o n s t i c o r m a o e d M o P c : i o n e s レ 3 定 m ン s タ r r , t t - u f u t g i e ; a c , d n t = を d e 成 t l e e n n c : シ t [ a s _ n : e n c _ h f a n i e t ` o h M e l r l n n c n s コ . e I t ー o g , _ l c r f d e e c n t o N N N 取 Z , e i O , t A e ー e " m : i A t t t c : i t t b s e $ t a e t i o o n A A t t : ー A , D e ゲ u e o i t o r f 5 t a v i p i a a a p 得 o B c b 用 c s ` を B s . a c [ . i l c e の u : , { O v t h c t u e c s i T ド R 指 d ッ t t r b m o r 3 s t c e d m m m r n u y j の c s $ 設 u 3 E [ m c ` a F o o " a " 設 t b b i h o y o d w c s o y a 設 e 定 Z ト e s i " } m o e f B : , e e e o e c : e O e I { 定 c : f . e $ d u n u a t , 定 i [ u j o o d : c f e o n p w 定 c o 設 5 . g ; " n f f r a c I k c r s d b k G f C s { d n d s e o r c e r d s o r a s c : e s o n 定 3 C i f a " t r r } o s C p = = = e d e R t i s e u e e e a s w T c = f s n e k c : s : a l o w s i : _ r e . l n r w a o o m i o r s t e s g I n c t t c n I e o t r e = c e t : w P n s I a c c d I R o s o s w f m m f c n o p p p s = m : i d t k P O t o d b R i n o t = o t : { a s o t _ d t f a l ( d e u , m - s r r " S s p r r r . = o n e i e o b . n e s e o e n s C r N a w _ l . c e i F w o t , c d c - o " " o d t t s o o o e r v t n t t l j A i n i s n w t e n d a " w s c i V l n o u s u h o F " d c m a a m o a r ) c c c n o n a r A t y N i e L c t t o の . r r e N m i s _ l c i o t n n _ d i r r c k d w w t c u ; e e e v u e l u c i " a c c L a i e u 設 a F e t w a e n _ c o y e u i s c c f s d o o - k " s s " e k c s s s . t w P e c t , m y t O l t B r 定 w u d i m } d c l u : w d t : t l r , T n n l - a - - a n t s s s C e o , e y e S " W U y u c s n i f a e - e l o d e f y i o o a t s i l w c c w v e , . . . E 5 s l s } t ] , s . c e _ c r i w c x o u f r r , [ o u n " r T t b i s d d s " x e e e R 3 3 i s = - a , e c k P c t e c s ] l . u d r P o n d t R g a r / b - k k - ; t i n n n T . . c i t r l e o l i c a _ , o h d f o r n , f . o e r u a / c - - c e d v v v _ H B y I n d e P o t l o o t t c u t f r n o t r P u t g c w a d l l d n : . . . A o u . d e e m r u . i u n . e l d m r o t t _ o r t . e t s w k i i k d R D B R s c D e w n e i d b c d C j . o f l o n . o o n i e f t s - s - b b - s s E O U N t k E n t n n F u y f o s f u r " n t C c r t c 5 r ( " s - l / / l t C M C e e S t c i t c r c ( r d " r d o , t . a o i . e 3 o d ; 3 i i a a i S r O A K d t T i l t i o k w o e , o f n . C c l g F C R m i " a b w w b t i R I E Z ( R t o y = p n e e n . m r t A a h P i u l e A s ; m / s s / a n D N T o t O y u ` a t t b t f C o ` l c e o n n a c l t " a - - a c g _ _ _ " n h Y を d , n l O A S . r e n , l h P l s c s o i r ; w r r w k , N N N " e i , 作 f e ( r r i F o r t o e o i . t s r a i s o o s A A A ; . s 成 r w i n t u m t . w d l c S i . d s b - u u - { p M M M f , o g } e n F i D e M i y 3 o P S ( u c t t c r E E E r n i i / B c i f i d e c . O n R e t l e e e o o " t a n * u t l i s M t y R r E I t i o 5 5 r p m W . m A ` c i e c t e h . E i v C " o u 3 3 t s L e O . c ] k o ( a r t o C D g e E , n d " - i ? o b r P c , e n { t i h d A I i n _ ) f ; t f : " " " o s i o e t ( e b o s C R n t C { r a i " " " k i g l s P t A u d . H E ( T L o r c S ; ; ; u t i i s o h r t s C I C w y A n g a t p e n c I l i n i . A N T e p S t e t a ( B A y d i s ( o A C G _ b e S " t e c t u c S e c , n L H _ T s . _ ; s m k h c c t n y ( L E O O i V A " a P i k e a t S " t O _ P _ t I L ; n r s e s t i t C h W G T H e E L a o , t s e t a l i _ E I T B W , g p " I m y t o s G T M T u E e s " , d e S e u , E _ I P c R r ) H e n 3 m d T H Z S k _ " o { n t C e F " _ E E , e R ; { s t ( a n r d H A D t E t i { n t o i E D , , Q e t o ) n s A , U d y n ; t t D { E Z ( i F r , S o c u i T n a n b , e l c u I U t t d s i i " e o o , r n n I " " { d , , { { Summary# There may be some areas where consideration was insufficient, but I was able to experience the convenience of AWS CDK. We hope some parts of this serve as a reference for others.