|
| 1 | +# AWS quickstart |
| 2 | + |
| 3 | +This is the shortest supported path for creating, checking, updating, and |
| 4 | +removing a HayaSend AWS deployment. Use an exact released HayaSend version in |
| 5 | +every infrastructure command. |
| 6 | + |
| 7 | +## 1. Sign in and set the target once |
| 8 | + |
| 9 | +Install Node.js 24 or newer, npm 12 or newer, the current AWS CLI v2, and the |
| 10 | +current AWS SAM CLI. Sign in with your normal AWS SSO profile: |
| 11 | + |
| 12 | +```bash |
| 13 | +export AWS_PROFILE=your-sso-profile |
| 14 | +export AWS_REGION=ap-northeast-1 |
| 15 | +aws sso login --profile "$AWS_PROFILE" |
| 16 | + |
| 17 | +export HAYASEND_AWS_ACCOUNT_ID="$( |
| 18 | + aws sts get-caller-identity --query Account --output text |
| 19 | +)" |
| 20 | +export HAYASEND_VERSION=X.Y.Z |
| 21 | +``` |
| 22 | + |
| 23 | +`HAYASEND_AWS_ACCOUNT_ID` and `AWS_REGION` are non-secret configuration. Every |
| 24 | +HayaSend AWS command calls STS and refuses to continue when the authenticated |
| 25 | +account differs. Pass `--account`, `--region`, `--stack`, or `--profile` only |
| 26 | +when overriding these defaults. The default stack name is `hayasend`. |
| 27 | + |
| 28 | +## 2. Create the stack |
| 29 | + |
| 30 | +Generate a read-only plan: |
| 31 | + |
| 32 | +```bash |
| 33 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" deploy aws |
| 34 | +``` |
| 35 | + |
| 36 | +Review the account, Region, SES state, parameters, tags, and exact apply |
| 37 | +command in the JSON result. Then apply: |
| 38 | + |
| 39 | +```bash |
| 40 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" deploy aws --apply |
| 41 | +``` |
| 42 | + |
| 43 | +Apply builds the packaged SAM application, creates an unexecuted |
| 44 | +CloudFormation change set, prints every resource action, and executes it only |
| 45 | +when no unacknowledged removal or possible replacement exists. HayaSend never |
| 46 | +changes DNS. |
| 47 | + |
| 48 | +## 3. Check whether it is ready |
| 49 | + |
| 50 | +```bash |
| 51 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" status aws |
| 52 | +``` |
| 53 | + |
| 54 | +The result keeps two decisions separate: |
| 55 | + |
| 56 | +- `operational` requires a stable stack, no drift reported, no problematic |
| 57 | + stack resources, all discovered HayaSend alarms in `OK`, and a successful |
| 58 | + public `/healthz` request; |
| 59 | +- `send_ready` additionally requires SES production access and account |
| 60 | + sending to be enabled. |
| 61 | + |
| 62 | +The result includes SES quota, only problematic resource and alarm details, |
| 63 | +the CloudWatch dashboard URL, and exact update, cleanup, and deep-diagnostics |
| 64 | +commands. It does not read the bootstrap secret or API keys. |
| 65 | + |
| 66 | +For authenticated application and queue diagnostics, set a scoped key locally |
| 67 | +and run: |
| 68 | + |
| 69 | +```bash |
| 70 | +export HAYASEND_BASE_URL=https://your-api.example |
| 71 | +export HAYASEND_API_KEY=your-scoped-diagnostics-key |
| 72 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" doctor |
| 73 | +``` |
| 74 | + |
| 75 | +Keep the key in an approved secret manager and out of command arguments, |
| 76 | +transcripts, and issue reports. |
| 77 | + |
| 78 | +## 4. Update safely |
| 79 | + |
| 80 | +Plan an update to the existing stack: |
| 81 | + |
| 82 | +```bash |
| 83 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" upgrade aws |
| 84 | +``` |
| 85 | + |
| 86 | +After reviewing the plan: |
| 87 | + |
| 88 | +```bash |
| 89 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" upgrade aws --apply |
| 90 | +``` |
| 91 | + |
| 92 | +`upgrade aws` refuses a missing or non-terminal stack and uses the same exact |
| 93 | +change-set inspection as initial deployment. If CloudFormation proposes any |
| 94 | +removal, indeterminate action, or possible replacement, it stops before |
| 95 | +execution. Use `--allow-destructive-changes` only after reviewing every |
| 96 | +printed destructive action. |
| 97 | + |
| 98 | +Run `status aws` again after every update. |
| 99 | + |
| 100 | +## 5. Remove the running stack |
| 101 | + |
| 102 | +First print the deletion plan: |
| 103 | + |
| 104 | +```bash |
| 105 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" cleanup aws |
| 106 | +``` |
| 107 | + |
| 108 | +Cleanup refuses an unmanaged stack, a non-terminal stack, or a stack with |
| 109 | +termination protection enabled. To delete the stack, repeat the exact name: |
| 110 | + |
| 111 | +```bash |
| 112 | +npx --yes "@haya-inc/hayasend@${HAYASEND_VERSION}" cleanup aws \ |
| 113 | + --apply \ |
| 114 | + --confirm-stack hayasend |
| 115 | +``` |
| 116 | + |
| 117 | +The CLI waits for `stack-delete-complete` and verifies that the stack no longer |
| 118 | +exists. It does not purge retained customer data. The DynamoDB table, payload |
| 119 | +bucket, and enabled inbound bucket and KMS key have `DeletionPolicy: Retain`; |
| 120 | +their physical IDs are printed before and after deletion. Decide their |
| 121 | +retention, export, and eventual destruction separately under the applicable |
| 122 | +backup, audit, and privacy policy. |
| 123 | + |
| 124 | +## Routine operating loop |
| 125 | + |
| 126 | +Run `status aws` after deployment, after updates, after AWS incidents, and |
| 127 | +before production canaries. Subscribe a real on-call destination to the |
| 128 | +`AlarmTopicArn`, confirm that subscription, configure an AWS Budget, and use |
| 129 | +the generated dashboard as the first operational view. The complete response |
| 130 | +procedures are in the [operations runbook](operations.md). |
0 commit comments