This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
2,414 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
/* This file is auto-generated by SST. Do not edit. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import "sst" | ||
export {} | ||
declare module "sst" { | ||
export interface Resource { | ||
"MyBucket": { | ||
"name": string | ||
"type": "sst.aws.Bucket" | ||
} | ||
"MyService": { | ||
"service": string | ||
"type": "sst.aws.Service" | ||
"url": string | ||
} | ||
"MyVpc": { | ||
"type": "sst.aws.Vpc" | ||
} | ||
} | ||
} | ||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Cluster } from "ioredis"; | ||
import { Resource } from "sst"; | ||
|
||
const client = new Cluster( | ||
[ | ||
{ | ||
host: Resource.MyRedis.host, | ||
port: Resource.MyRedis.port, | ||
}, | ||
], | ||
{ | ||
redisOptions: { | ||
tls: { | ||
checkServerIdentity: () => undefined, | ||
}, | ||
username: Resource.MyRedis.username, | ||
password: Resource.MyRedis.password, | ||
}, | ||
} | ||
); | ||
|
||
export async function handler() { | ||
await client.set("foo", `bar-${Date.now()}`); | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
foo: await client.get("foo"), | ||
}), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "aws-redis", | ||
"version": "1.0.0", | ||
"description": "", | ||
"type": "module", | ||
"main": "index.js", | ||
"scripts": { | ||
"deploy": "go run ../../cmd/sst deploy", | ||
"remove": "go run ../../cmd/sst remove", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"ioredis": "^5.4.1", | ||
"sst": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* This file is auto-generated by SST. Do not edit. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import "sst" | ||
export {} | ||
declare module "sst" { | ||
export interface Resource { | ||
"MyApp": { | ||
"name": string | ||
"type": "sst.aws.Function" | ||
"url": string | ||
} | ||
"MyRedis": { | ||
"clusterArn": string | ||
"host": string | ||
"password": string | ||
"port": number | ||
"type": "sst.aws.Redis" | ||
"username": string | ||
} | ||
"MyVpc": { | ||
"type": "sst.aws.Vpc" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/// <reference path="./.sst/platform/config.d.ts" /> | ||
|
||
export default $config({ | ||
app(input) { | ||
return { | ||
name: "aws-redis", | ||
removal: input?.stage === "production" ? "retain" : "remove", | ||
home: "aws", | ||
}; | ||
}, | ||
async run() { | ||
// NAT Gateways are required for Lambda functions | ||
const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); | ||
const redis = new sst.aws.Redis("MyRedis", { vpc }); | ||
const app = new sst.aws.Function("MyApp", { | ||
handler: "index.handler", | ||
url: true, | ||
vpc, | ||
link: [redis], | ||
}); | ||
|
||
return { | ||
app: app.url, | ||
}; | ||
}, | ||
}); |
Oops, something went wrong.