stage.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. export const domain = (() => {
  2. if ($app.stage === "production") return "opencode.ai"
  3. if ($app.stage === "dev") return "dev.opencode.ai"
  4. return `${$app.stage}.dev.opencode.ai`
  5. })()
  6. export const zoneID = "430ba34c138cfb5360826c4909f99be8"
  7. // Dev owns the shared AWS lake/stats infra for all non-production stages.
  8. export const awsStage = $app.stage === "production" ? "production" : "dev"
  9. export const deployAws = $app.stage === awsStage
  10. const githubActionsDeployRole = (() => {
  11. if ($app.stage !== "dev" && $app.stage !== "production") return
  12. const provider = new aws.iam.OpenIdConnectProvider("GithubActionsOidcProvider", {
  13. url: "https://token.actions.githubusercontent.com",
  14. clientIdLists: ["sts.amazonaws.com"],
  15. })
  16. const role = new aws.iam.Role("GithubActionsDeployRole", {
  17. name: `opencode-${$app.stage}-github-actions-deploy`,
  18. maxSessionDuration: 3600,
  19. assumeRolePolicy: aws.iam.getPolicyDocumentOutput({
  20. statements: [
  21. {
  22. effect: "Allow",
  23. actions: ["sts:AssumeRoleWithWebIdentity"],
  24. principals: [{ type: "Federated", identifiers: [provider.arn] }],
  25. conditions: [
  26. {
  27. test: "StringEquals",
  28. variable: "token.actions.githubusercontent.com:aud",
  29. values: ["sts.amazonaws.com"],
  30. },
  31. {
  32. test: "StringEquals",
  33. variable: "token.actions.githubusercontent.com:sub",
  34. values: [`repo:anomalyco/opencode:environment:${$app.stage}`],
  35. },
  36. ],
  37. },
  38. ],
  39. }).json,
  40. })
  41. new aws.iam.RolePolicyAttachment("GithubActionsDeployRoleAdmin", {
  42. role: role.name,
  43. policyArn: "arn:aws:iam::aws:policy/AdministratorAccess",
  44. })
  45. return role
  46. })()
  47. export const githubActionsDeployRoleArn = githubActionsDeployRole?.arn
  48. new cloudflare.RegionalHostname("RegionalHostname", {
  49. hostname: domain,
  50. regionKey: "us",
  51. zoneId: zoneID,
  52. })
  53. export const shortDomain = (() => {
  54. if ($app.stage === "production") return "opncd.ai"
  55. if ($app.stage === "dev") return "dev.opncd.ai"
  56. return `${$app.stage}.dev.opncd.ai`
  57. })()