Creating and Deploying a Gatsby Site with AWS CDK

  • initialize a gatsby blog starter

  • make the first gatsby default commit

  • install aws cdk

  • cdk init an app, choose javascript

  • update the gitignore

  • make the first commit

  • configure AWS sso

  • cdk bootstrap account and regions

  • cdk sync test and deploy shell to aws

  • configure cdk stack environment with account

Site Deployment Resources

  • set variables (domain) as props
  • set tags
  • create s3 bucket
  • create sample static deployment
  • import hosted zone
  • create cert
  • set OAI
  • create distribution
  • Create r53 record for apex
  • create r53 record for www

CI/CD Pipeline

  • create codestar connection (pending)
  • authenticate github connection in codestar
  • create aws resources

Blog Post(s) & Theme

  • Find and implement a dark theme for site
  • Write 3 blog posts
    • Project motivations & Document repo (possibly a markdown slide deck in MDX as a gatsby post?)
    • Review of CDK Implementation
    • Review of Gatsby && Build implementation

Gatsby Starter Blog

npm i -g aws-cdk
cdk --version # 2.45.0 (build af1fb7c)
cdk init app --language javascript

Configure AWS CLI for SSO

Make sure you select the region your SSO lives in, not the region you want to interact with! You will get an error otherwise about an Invalid Grant.

More info about using named profiles with IAM Identity Center (formerly AWS SSO)

Bootstrapping basics

Bootstrapping multiple regions

cdk bootstrap \
aws://310141637485/us-east-1 \
aws://310141637485/us-east-2 \
aws://310141637485/us-west-1 \
aws://310141637485/us-west-2 \
--profile cstgsso

CDK Docs

CDK API Reference Docs

Static Site Construct

CDK Pipelines

Note about github codestar connections No L2 constructs in v2 yet?

Locally test Codebuild Buildspecs

./ -i 3c8ea9e9584d -a local-build -m