Sam Hulick
01/19/2022, 4:15 PMSam Hulick
01/20/2022, 6:52 PMAdam Fanello
01/21/2022, 12:34 AMimport { cloudformation_include as cloudformation, aws_iam as iam, aws_s3 as s3, RemovalPolicy } from "aws-cdk-lib";
thdxr
01/21/2022, 3:24 AMexport async function TableStack(props) {
const table = new sst.Table(props.stack, ...);
return { table };
}
export async function StackB(props) {
const { table } = use(TableStack);
new sst.Function(props.stack, { environment: { MYTABLE: table } })
}
It would be totally typesafe + support async functionsthdxr
01/21/2022, 7:45 PMGarret Harp
01/22/2022, 8:31 PMSam Hulick
01/24/2022, 3:22 AMsfn.StartExecution
would do absolutely nothing? not even throw an error?
try {
console.log('Starting execution:', JSON.stringify(startExecParams));
const res = await sfn.send(new StartExecutionCommand(startExecParams));
console.log('execution result:', JSON.stringify(res));
} catch (e) {
console.error('y tho?', e);
}
one Lambda function calls the function that performs the above code, and it works with no problem. but another Lambda calls the same function and I see “Starting execution” in CloudWatch Logs and that’s it. no error, no “execution result”. I don’t get it.
EDIT: forgot an await
🤦♂️Ross Coundon
01/25/2022, 3:37 PMJay
Garret Harp
01/26/2022, 12:33 AMmanitej
01/26/2022, 11:17 AMthdxr
01/26/2022, 10:47 PMimport * as sst from "@serverless-stack/resources"
export type FunctionalStackProps = {
app: <http://sst.App|sst.App>
stack: sst.Stack
}
export type FunctionalStack<T> = (props: FunctionalStackProps) => T
let currentApp: <http://sst.App|sst.App> | undefined = undefined
const cache: Record<string, any> = {}
class EmptyStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string) {
super(scope, id)
}
}
export function createStacks(app: <http://sst.App|sst.App>, ...fns: FunctionalStack<any>[]) {
currentApp = app
for (const fn of fns) {
const name = fn.name.toLowerCase()
const exists = cache[name]
if (exists) continue
const stack = new EmptyStack(app, name)
const result = fn({
app,
stack,
})
console.log(`Synthesized stack ${name}`)
cache[name] = result
}
}
export function defineStack<T>(cb: FunctionalStack<T>) {
return cb
}
export function use<T>(stack: FunctionalStack<T>): T {
if (!currentApp) throw new Error("No app is set")
const name = stack.name.toLowerCase()
const exists = cache[name]
if (exists) return exists
createStacks(currentApp, stack)
return use(stack)
}
Can define stacks like this
export function Solid(props: FunctionalStackProps) {
const api = use(Api)
new StaticSite(props.stack, "web", {
path: "solid/app",
buildCommand: "yarn run build",
environment: {
VITE_GRAPHQL_ENDPOINT: api.graphql.url,
},
})
}
And in your main make sure you load at least one stack with createStacks(app, MyStack)
- it'll use dependency injection to load all the ones MyStack depends onDevin
01/27/2022, 4:02 PM<scripts src="my-cool-embed.bundled.js"></script>
Is that just some kind of minified JS that’s stored in an s3 bucket and the access is by… I guess URL? I don’t really understand the architecture of how something like that would work.Sam Hulick
01/27/2022, 5:36 PMDaniel Gato
01/28/2022, 10:50 PMGarret Harp
01/31/2022, 2:21 AMimport { AlgoliaIndex } from '@garretcharp/cdk-constructs-algolia-v2'
import { SecretValue } from 'aws-cdk-lib'
const MyIndex = new AlgoliaIndex(this, 'MyIndex', {
indexName: `${this.stage}-my-index`,
// See: <https://www.algolia.com/doc/api-reference/settings-api-parameters>
settings: {
searchableAttributes: ['name']
},
apiKey: SecretValue.plainText('my-algolia-api-key'),
appId: 'my-algolia-app-id'
})
If you run into any issues let me know 🙂 Source code: https://github.com/garretcharp/cdk-constructsDillon Peterson
01/31/2022, 4:05 PMSam Hulick
01/31/2022, 8:25 PMJon Holman
02/02/2022, 5:11 PMjustindra
02/03/2022, 4:32 PMthdxr
02/04/2022, 12:41 PMDevin
02/10/2022, 12:33 AMFrank
thdxr
02/13/2022, 10:47 PMDamjan
02/14/2022, 8:46 AMSam Hulick
02/15/2022, 1:50 AM<http://pr-131.reelcrafter.com|pr-131.reelcrafter.com>
) so we can look at it & test things out.
the problem is, ALL front end deployment happens in the production account, and is tied to the GitHub repo. I’m trying to figure out a way for a dev to open a PR, and somehow point that preview instance of the front end to their SST dev stack in their AWS accountJacoby
02/15/2022, 12:53 PMUpdateUserPool
updates all user pool props not specified in the request back to their default values.
Learned the hard way.Ashishkumar Pandey
02/16/2022, 12:23 AMsst.json
?Ashishkumar Pandey
02/16/2022, 1:51 AMRoss Coundon
02/16/2022, 10:39 AM