Skip to content

Commit 7360add

Browse files
authored
[Post] The Stack Part 3 (#18)
* Add draft post * Add ui-app and ui-internal writeup * Cover deployments in part 3 * Add missing import * Fix response page path * Add rewrite handler * Fix edge-function * Fix incorrect file ending
1 parent 639f1be commit 7360add

11 files changed

Lines changed: 1772 additions & 3 deletions

posts/2023-10-07-the-stack-part-1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Now that we are ready, a high-level overview of the steps we will be taking are:
9292
The first screen you'll meet wants you to review various infomration and pricing as well as choose a few defaults. We are going to change some of the values:
9393

9494
- **Region deny setting**: Choose `Enabled` for this. We want to make sure that Control Tower is governing our accounts and resources.
95+
- We will need `us-east-1` for certain "global" resources, so we'll add that to the list of allowed regions along with your desired region.
9596

9697
#### Step 2
9798

posts/2023-10-07-the-stack-part-2.md

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Otherwise, let's jump in!
2828
- [Trigger the Workflows](#trigger-the-workflows)
2929
- [Manual alternative: Bootstrapping our Accounts](#manual-alternative-bootstrapping-our-accounts)
3030
- [Manual alternative: Deployments](#manual-alternative-deployments)
31+
- [Bonus: Just](#bonus-just)
3132
- [Next Steps](#next-steps)
3233

3334

@@ -314,7 +315,7 @@ Our deployment flow gets a bit more complicated. We're building for the future h
314315
We will be building up the following flow, illustrated in the diagram below:
315316
316317
<div style="text-align:center;">
317-
<a href="/resources/images/the-stack-part-2-deployment-flow.png" target="_blank" rel="noopener noreferrer"><img src="/resources/images/the-stack-part-2-deployment-flow.png" loading="lazy" alt="Deployment flow" title="Deployment flow" width="100%%" /></a>
318+
<a href="/resources/images/the-stack-part-2-deployment-flow.png" target="_blank" rel="noopener noreferrer"><img src="/resources/images/the-stack-part-2-deployment-flow.png" loading="lazy" alt="Deployment flow" title="Deployment flow" width="100%" /></a>
318319
</div>
319320
320321
This is what is called a "staggered deployment", but across our environments:
@@ -436,7 +437,7 @@ We could have been using using build `matrix`'s again, but that would mean that
436437
Voila 🎉 We've now set the skeleton for the deployment flow we pictured earlier:
437438

438439
<div style="text-align:center;">
439-
<a href="/resources/images/the-stack-part-2-deployment-flow.png" target="_blank" rel="noopener noreferrer"><img src="/resources/images/the-stack-part-2-deployment-flow.png" loading="lazy" alt="Deployment flow" title="Deployment flow" width="100%%" /></a>
440+
<a href="/resources/images/the-stack-part-2-deployment-flow.png" target="_blank" rel="noopener noreferrer"><img src="/resources/images/the-stack-part-2-deployment-flow.png" loading="lazy" alt="Deployment flow" title="Deployment flow" width="100%" /></a>
440441
</div>
441442

442443
**Part 2: Reuseable workflow**
@@ -532,7 +533,7 @@ Push your project to GitHub. You now have access to the workflows and can trigge
532533
If you haven't done it already, let's run the `Deployment: Bootstrap` workflow first, to set up CDK on all accounts. Alternatively, jump to the section [Manual alternative: Bootstrapping our Accounts](#manual-alternative-bootstrapping-our-accounts) for how to do this manually.
533534

534535
<div style="text-align:center;">
535-
<a href="/resources/images/the-stack-part-2-trigger-bootstrap-workflow.png" target="_blank" rel="noopener noreferrer"><img src="/resources/images/the-stack-part-2-trigger-bootstrap-workflow.thumbnail.png" loading="lazy" alt="Manually trigger the bootstrap workflow" title="Manually trigger the bootstrap workflow" width="80%%" /></a>
536+
<a href="/resources/images/the-stack-part-2-trigger-bootstrap-workflow.png" target="_blank" rel="noopener noreferrer"><img src="/resources/images/the-stack-part-2-trigger-bootstrap-workflow.thumbnail.png" loading="lazy" alt="Manually trigger the bootstrap workflow" title="Manually trigger the bootstrap workflow" width="80%" /></a>
536537
</div>
537538

538539
Next up, before we initiate the deployment it's recommended to be logged into your Domain Registrar that controls the DNS of your domain, so that you can quickly update your name servers to point to the Hosted Zone that we will be creating. This is necessary to DNS validate our ACM certificates.
@@ -611,6 +612,81 @@ $ DOMAIN="app.example.com" bun run cdk deploy --concurrency 4 'Cloud' 'Cloud/**'
611612
The `DOMAIN` environment variable is required here, since we need to know what domain we should use for the Hosted Zone.
612613

613614

615+
## Bonus: Just
616+
617+
It might seem overkill right now, but we will eventually have many different commands across many folder locations in our mono-repo setup. To make this a bit easier to work with, we can use the tool [Just](https://github.com/casey/just) to help us out.
618+
619+
From `just`'s README:
620+
621+
> `just` is a handy way to save and run project-specific commands
622+
623+
From [the installation instructions](https://github.com/casey/just#packages) we can install it via:
624+
625+
```bash
626+
# macOS:
627+
$ brew install just
628+
# Linux with prebuilt-mpr (https://docs.makedeb.org/prebuilt-mpr/getting-started/#setting-up-the-repository):
629+
$ sudo apt install just
630+
# Prebuilt binaries (assuming $HOME/.local/bin is in your $PATH):
631+
$ curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to $HOME/.local/bin
632+
```
633+
634+
This allows us to set up a `justfile` in the root of our project, which we can then use to define shortcuts to our commands. For example, we can define a shortcut to run our CDK commands:
635+
636+
```makefile
637+
# Display help information.
638+
help:
639+
@ just --list
640+
641+
# Setup dependencies and tooling for <project>, e.g. `just setup deployment`.
642+
setup project:
643+
just _setup-{{project}}
644+
645+
_setup-deployment:
646+
#!/usr/bin/env bash
647+
set -euxo pipefail
648+
cd deployment
649+
bun install
650+
651+
# Deploy the specified <stack>, e.g. `just deploy Cloud`, defaulting to --all.
652+
deploy stack='--all':
653+
#!/usr/bin/env bash
654+
set -euxo pipefail
655+
cd deployment
656+
bun run cdk deploy --concurrency 4 --require-approval never {{ if stack == "--all" { "--all" } else { stack } }}
657+
658+
# Run tests for <project>, e.g. `just test deployment`.
659+
test project:
660+
just _test-{{project}}
661+
662+
_test-deployment:
663+
#!/usr/bin/env bash
664+
set -euxo pipefail
665+
cd deployment
666+
bun test
667+
668+
_test-synth:
669+
#!/usr/bin/env bash
670+
set -euxo pipefail
671+
cd deployment
672+
bun run cdk synth --all
673+
```
674+
675+
We can now run our commands via `just`:
676+
677+
```bash
678+
# Setup our dependencies:
679+
$ just setup deployment
680+
# Run tests:
681+
$ just test deployment
682+
# Synthesize our CDK stack:
683+
$ just test synth
684+
# Deploy our CDK stack:
685+
$ just deploy # or just deploy Cloud
686+
```
687+
688+
689+
614690
## Next Steps
615691

616692
Next up is to add our first Frontend! Follow along in Part 3 of the series (will be posted soon).

0 commit comments

Comments
 (0)