Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Nov 22, 2023
1 parent a06f89f commit a36fbd5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
29 changes: 23 additions & 6 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var version = "dev"

func main() {
app := &cli.App{
Name: "sst",
Usage: "deploy anything",
Name: "sst",
Description: "deploy anything",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Expand Down Expand Up @@ -53,7 +53,6 @@ func main() {
Commands: []*cli.Command{
{
Name: "deploy",
Usage: "Deploy",
Flags: []cli.Flag{},
Action: func(cli *cli.Context) error {
p, err := initProject()
Expand Down Expand Up @@ -136,7 +135,6 @@ func main() {
},
{
Name: "remove",
Usage: "Remove",
Flags: []cli.Flag{},
Action: func(cli *cli.Context) error {
p, err := initProject()
Expand All @@ -156,9 +154,29 @@ func main() {
return nil
},
},
{
Name: "refresh",
Flags: []cli.Flag{},
Action: func(cli *cli.Context) error {
p, err := initProject()
if err != nil {
return err
}
events, err := p.Stack.Refresh()
if err != nil {
return err
}

for evt := range events {
if evt.ResourcePreEvent != nil {
slog.Info("got op", "op", evt.ResourcePreEvent.Metadata.Op)
}
}
return nil
},
},
{
Name: "create",
Usage: "Create",
Flags: []cli.Flag{},
Action: func(cli *cli.Context) error {
err := project.Create()
Expand All @@ -171,7 +189,6 @@ func main() {
},
{
Name: "cancel",
Usage: "Cancel",
Flags: []cli.Flag{},
Action: func(cli *cli.Context) error {
p, err := initProject()
Expand Down
3 changes: 3 additions & 0 deletions internal/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"@aws-sdk/client-sts": "^3.454.0",
"@pulumi/aws": "5.43.0",
"@pulumi/pulumi": "3.94.2"
},
"devDependencies": {
"@types/node": "^20.9.4"
}
}
7 changes: 5 additions & 2 deletions internal/components/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions internal/components/src/components/ssr-site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from "fs";
import * as path from "path";
import { execSync } from "child_process";
import pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import { Function } from "./function";

export interface SsrSiteArgs extends pulumi.ComponentResourceOptions {
Expand Down Expand Up @@ -90,7 +91,7 @@ export class SsrSite extends pulumi.ComponentResource {
function createCloudFrontOriginAccessIdentity() {
return new aws.cloudfront.OriginAccessIdentity(
`${name}-origin-access-identity`,
{}
{},
);
}

Expand All @@ -106,7 +107,7 @@ export class SsrSite extends pulumi.ComponentResource {
return request;
}`,
},
{ parent: _this }
{ parent: _this },
);
}

Expand Down Expand Up @@ -189,7 +190,7 @@ export class SsrSite extends pulumi.ComponentResource {
queryStringBehavior: "all",
},
},
}
},
);

return new aws.cloudfront.Distribution(`${name}-distribution`, {
Expand Down Expand Up @@ -341,7 +342,7 @@ export class SsrSite extends pulumi.ComponentResource {
const bucket = new aws.s3.BucketV2(
`${name}-bucket`,
{},
{ parent: _this }
{ parent: _this },
);
new aws.s3.BucketPublicAccessBlock("exampleBucketPublicAccessBlock", {
bucket: bucket.id,
Expand Down Expand Up @@ -397,7 +398,7 @@ export class SsrSite extends pulumi.ComponentResource {
},
],
})
.then((doc) => doc.json)
.then((doc) => doc.json),
),
},
],
Expand Down Expand Up @@ -429,7 +430,7 @@ export class SsrSite extends pulumi.ComponentResource {
},
],
})
.then((doc) => doc.json)
.then((doc) => doc.json),
),
},
],
Expand All @@ -442,7 +443,7 @@ export class SsrSite extends pulumi.ComponentResource {
description: "Next.js server",
handler: "index.handler",
code: new pulumi.asset.FileArchive(
path.join(sitePath, ".open-next", "image-optimization-function")
path.join(sitePath, ".open-next", "image-optimization-function"),
),
runtime: "nodejs18.x",
memorySize: 1536,
Expand Down Expand Up @@ -482,33 +483,33 @@ export class SsrSite extends pulumi.ComponentResource {
},
],
})
.then((doc) => doc.json)
.then((doc) => doc.json),
),
},
],
managedPolicyArns: [
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
],
}
},
);
const consumer = new aws.lambda.Function(
`${name}-revalidation-consumer`,
{
handler: "index.handler",
code: new pulumi.asset.FileArchive(
path.join(sitePath, ".open-next", "revalidation-function")
path.join(sitePath, ".open-next", "revalidation-function"),
),
runtime: "nodejs18.x",
timeout: 30,
role: consumerRole.arn,
}
},
);
new aws.lambda.EventSourceMapping(
`${name}-revalidation-consumer-event-source`,
{
functionName: consumer.name,
eventSourceArn: queue.arn,
}
},
);
}
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/project/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,7 @@ func (s *stack) Cancel() (StackEventStream, error) {
func (s *stack) Remove() (StackEventStream, error) {
return s.run("destroy")
}

func (s *stack) Refresh() (StackEventStream, error) {
return s.run("refresh")
}

0 comments on commit a36fbd5

Please sign in to comment.