|
| 1 | +# Infrastructure |
| 2 | + |
| 3 | +Manage the static site infrastructure with Pulumi. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Pulumi CLI |
| 8 | +- AWS credentials with permissions to manage S3, CloudFront, ACM, Route53, and IAM |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +1. Install dependencies: |
| 13 | + ```bash |
| 14 | + cd infra |
| 15 | + npm install |
| 16 | + ``` |
| 17 | +2. Log into the shared S3 backend (only needs to be done once per environment): |
| 18 | + ```bash |
| 19 | + AWS_PROFILE=projectm pulumi login s3://pulumi-state-projectm |
| 20 | + ``` |
| 21 | +3. Create a stack (example `dev`) if it does not exist: |
| 22 | + ```bash |
| 23 | + pulumi stack init dev |
| 24 | + ``` |
| 25 | +4. Configure required values: |
| 26 | + ```bash |
| 27 | + pulumi config set bucketName prjm |
| 28 | + pulumi config set githubOwner projectM-visualizer |
| 29 | + pulumi config set githubRepo projectm-visualizer.org |
| 30 | + pulumi config set githubRefs '["refs/heads/master"]' |
| 31 | + pulumi config set aws:region your-app-region |
| 32 | + ``` |
| 33 | +5. Optional configuration: |
| 34 | + - `cloudfrontPriceClass` (`PriceClass_100`, `PriceClass_200`, `PriceClass_All`) |
| 35 | + - `primaryDomain` and `alternateDomains` to enable custom domains |
| 36 | + - `hostedZoneId` to request an ACM certificate via DNS validation |
| 37 | + - `certificateArn` to reuse an existing certificate instead of provisioning one |
| 38 | + - `oidcProviderArn` to reference an existing GitHub OIDC provider |
| 39 | + - `githubRoleName` to override the IAM role name |
| 40 | + |
| 41 | +6. Deploy: |
| 42 | + ```bash |
| 43 | + AWS_PROFILE=projectm PULUMI_CONFIG_PASSPHRASE=projectm pulumi up |
| 44 | + ``` |
| 45 | + |
| 46 | +Outputs include the CloudFront distribution details and the IAM role ARN. |
| 47 | + |
| 48 | +### State |
| 49 | + |
| 50 | +State lives in `s3://pulumi-state-projectm` (versioned). Set `AWS_PROFILE=projectm` and `PULUMI_CONFIG_PASSPHRASE=projectm` when running Pulumi commands so AWS calls and encrypted config values work consistently. |
| 51 | + |
| 52 | +## GitHub Actions |
| 53 | + |
| 54 | +Set these repository secrets and variables before running the deployment workflow: |
| 55 | + |
| 56 | +- `AWS_ROLE_ARN` (secret): ARN of the IAM role exported by Pulumi. |
| 57 | +- `GH_TOKEN` (secret): GitHub token with `repo` scope for `generate-reports`. |
| 58 | +- `NUXT_PUBLIC_ASSET_KEY` (secret): Encryption key used by `generate-reports`. |
| 59 | +- `vars.AWS_REGION`: AWS region for S3 operations (for example, `us-west-2`). |
| 60 | +- `vars.S3_BUCKET`: Target S3 bucket name (`prjm`). |
| 61 | +- `vars.CLOUDFRONT_DISTRIBUTION_ID`: Distribution ID exported by Pulumi. |
| 62 | + |
| 63 | +The workflow runs on pushes to `master` and can also be triggered manually. |
0 commit comments