Skip to content

Instantly share code, notes, and snippets.

@southpolesteve
Last active May 24, 2024 04:53
Show Gist options
  • Save southpolesteve/96adbac7e492c16c23c9f0b0e3054dc3 to your computer and use it in GitHub Desktop.
Save southpolesteve/96adbac7e492c16c23c9f0b0e3054dc3 to your computer and use it in GitHub Desktop.
Infrastructure as *code*
import { AWS } from 'infastructure-as-code'
import fs from 'fs'
AWS.region = 'us-east-1'
const ENV = process.env.NODE_ENV || 'development'
const lambdaRole = new AWS.IAM.Role({
RoleName: `lambda-execution-${env}`
})
const userTable = new AWS.Dynamo.Table({
TableName: `user-${env}`
})
dynamoTable.grantAccess(lambdaRole)
const createUser = new AWS.Lambda({
Name: 'create-user'
Runtime: 'node6.10',
Code: fs.readFileSync('./create-user.zip')
Role: lambdaRole
})
const api = new AWS.APIGateway({
paths: {
'/users' : {
method: 'POST'
type: 'AWS_PROXY',
lambdaFunction: createUser
}
}
})
AWS.createStack()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment