How to use the @pulumi/cloud-aws.Table function in @pulumi/cloud-aws

To help you get started, we’ve selected a few @pulumi/cloud-aws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / examples / cloud-ts-slack-slash-command / index.ts View on Github external
console.log(now);
    res.status(200).end(now.toString());
});

endpoint.post("/echo", async (req, res) => {
    const data = parseUrlEncodedBody(req.body);

    const response: SlackSlashCommandResponse = {
        response_type: "in_channel",
        text: data.text,
    };

    res.status(200).json(response);
});

const quoteTable = new cloud.Table("quotes");

// quote-add [name] [value]
endpoint.post("/quote-add", async (req, res) => {
    const data = parseUrlEncodedBody(req.body);

    const kvp = getIdValue(data.text);
    if (!kvp) {
        res.status(400).end();
        return;
    }

    console.log(`Saving '${kvp.key}'='${kvp.value}'`);

    // Fetch the array.
    const value = await quoteTable.get({ id: kvp.key });
    const array: string[] = (value && value.array) || [];
github pulumi / examples / cloud-js-api / index.js View on Github external
const cloud = require("@pulumi/cloud-aws");

// Create a mapping from 'route' to a count
let counterTable = new cloud.Table("counterTable", "route");

// Create an API endpoint
let endpoint = new cloud.API("hello-world");

endpoint.get("/{route+}", (req, res) => {
    let route = req.params["route"];
    console.log(`Getting count for '${route}'`);

    // get previous value and increment
    // reference outer `counterTable` object
    counterTable.get({ route }).then(value => {
        let count = (value && value.count) || 0;
        counterTable.insert({ route, count: ++count }).then(() => {
            res.status(200).json({ route, count });
            console.log(`Got count ${count} for '${route}'`);
        });
github pulumi / examples / cloud-ts-url-shortener / index.ts View on Github external
// Copyright 2016-2018, Pulumi Corporation.  All rights reserved.

// Note: @pulumi/cloud is a preview package demonstrating how to create cross-cloud Pulumi
// components. If you are targeting a specific cloud like AWS, Azure, or GCP, we recommend you use
// platform-specific packages like @pulumi/aws, @pulumi/azure or @pulumi/gcp. These packages give
// you full access to the breadth of the platform's capabilities and comes with many abstractions to
// make developing against that platform easier.

import * as cloud from "@pulumi/cloud-aws";

// Create a web server.
const endpoint = new cloud.API("urlshortener");

// Create a table `urls`, with `name` as primary key.
const urlTable = new cloud.Table("urls", "name");

// Serve all files in the www directory to the root.
endpoint.static("/", "www");

// GET /url lists all URLs currently registered.
endpoint.get("/url", async (req, res) => {
    try {
        const items = await urlTable.scan();
        res.status(200).json(items);
        console.log(`GET /url retrieved ${items.length} items`);
    } catch (err) {
        res.status(500).json(err.stack);
        console.log(`GET /url error: ${err.stack}`);
    }
});

@pulumi/cloud-aws

An implementation of the Pulumi Framework for targeting Amazon Web Services (AWS).

Apache-2.0
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis