How to use the @pulumi/cloud-aws.API 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-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}`);
github pulumi / pulumi-cloud / aws / examples / customDomain / index.ts View on Github external
// We'll host our API on this subdomain.
let subdomain = "testsubdomain1234";

// Also get the Hosted Zone Id for the above domain.
//
// IDEA: Use `aws.route53.getZone()`
let hostedZoneId = "ZAH2GWTP2BEOU";

// Next, create an Amazon Certificate Manager cert for *. in us-east-1 in the same account.
//
// IDEA: Use `aws.acm.getCertificate()`
let certficateArn = "arn:aws:acm:us-east-1:153052954103:certificate/2a5c225d-de86-4e08-8639-e3a843089c57";

// Create an HTTP Endpoint.
let endpoint = new awscloud.API("endpoint");
endpoint.get("/", async (req, res) => {
    res.json(req);
});

// Attach our custom domain using the AWS-specific ACM certificate.
endpoint.attachCustomDomain({
    domainName: subdomain + "." + domainName,
    certificateArn: certficateArn,
});
let deployment = endpoint.publish();

// Add a DNS CNAME record for the subdomain pointing to the API custom domain.
let recordSet = new aws.route53.Record(subdomain, {
    name: subdomain,
    zoneId: hostedZoneId,
    type: "A",

@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