Skip to content

Instantly share code, notes, and snippets.

@sielay
Last active April 27, 2018 14:54
Show Gist options
  • Save sielay/75b1b0f9b1e4716fa8f0adc440e792ad to your computer and use it in GitHub Desktop.
Save sielay/75b1b0f9b1e4716fa8f0adc440e792ad to your computer and use it in GitHub Desktop.
JSX to FaaS concept
export const simple = (props) =>
<AWSVPC id={props.vpc}>
<S3Bucket name={props.stage + "-bucket"} />
</AWSVPC>;
export const moreDifficult = (props) => {
const systemBucket = <S3Bucket name={props.stage + "-bucket"}/>
return <AWSVPC id={props.vpc}>
{ systemBucket }
<Labmda handler={ callback => callback(null, "hello world!") } logTo={systemBucket}/>
</AWSVPC>;
}
export const modulesA = (props) => {
const systemBucket = <S3Bucket name={props.stage + "-bucket"}/>
const module = <Module folder="./sommodule" storeIn={systemBucket} />
return <AWSVPC id={props.vpc}>
{ systemBucket }
<APIGateway stage={props.stage}>
<Route path="/some/:path" method="get">
<Lambda from={module} handler="index.handler"/>
</Route>
</APIGateway>
</AWSVPC>;
}
// OR
export const modulesA = (props) => {
const module = <Module folder="./sommodule"/>
const systemBucket = <S3Bucket name={props.stage + "-bucket"}>{ module }</S3Bucket>
return <AWSVPC id={props.vpc}>
{ systemBucket }
<APIGateway stage={props.stage}>
<Route path="/some/:path" method="get">
<Lambda from={module} handler="index.handler"/>
</Route>
</APIGateway>
</AWSVPC>;
}
// OR
export const modulesA = (props) => {
const module = <Module folder="./sommodule"/>
return <VPC id={props.vpc}>
<CodeStoreProvider name={props.stage + "-bucket"}>
<LogStoreProvider name={props.stage + "-bucket"}>
<Router stage={props.stage}>
<Route path="/some/:path" method="get">
<Function from={module} handler="index.handler"/>
</Route>
</Router>
</LogStoreProvider>
</CodeStoreProvider>
</VPC>
const stack = (props) => <Stack {...props}>
<LoadBalancer>
{
(() => {
const a = [];
for( let i = 0; i < (props.instances || 1); i++ ) {
a.push(
<Server os="ubuntu">
<Recipe name="docker"/>
<Repository path="ssh+git://" command="docker-compose up">
<File name=".env">
PORT={ (props.basePort + i).toFixed(0) }
</File>
</Repository>
</Server>
)
}
return a;
})()
}
</LoadBalancer>
</Stack>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment