Last active
May 24, 2024 04:53
-
-
Save southpolesteve/96adbac7e492c16c23c9f0b0e3054dc3 to your computer and use it in GitHub Desktop.
Infrastructure as *code*
This file contains hidden or 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
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