How to use the @pulumi/cloud.API function in @pulumi/cloud

To help you get started, we’ve selected a few @pulumi/cloud 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 / pulumi-cloud / examples / containers / index.ts View on Github external
// build an anonymous image:
let builtService = new cloud.Service("examples-nginx2", {
    containers: {
        nginx: {
            build: "./app",
            memory: 128,
            ports: [{ port: 80 }],
        },
    },
    replicas: 2,
    waitForSteadyState: false,
});

// expose some APIs meant for testing purposes.
let api = new cloud.API("examples-containers");
api.get("/test", async (req, res) => {
    try {
        res.json({
            nginx: await nginx.getEndpoint(),
            nginx2: await builtService.getEndpoint(),
        });
    } catch (err) {
        console.error(errorJSON(err));
        res.status(500).json(errorJSON(err));
    }
});

function errorJSON(err: any) {
    const result: any = Object.create(null);
    Object.getOwnPropertyNames(err).forEach(key => result[key] = err[key]);
    return result;
github pulumi / pulumi-awsx / nodejs / aws-infra / examples / containers / index.ts View on Github external
nginx: {
                    build: "./app",
                    memory: 128,
                    loadBalancerPort: {
                        external: true,
                        port: 80,
                    },
                },
            },
        },
        desiredCount: 2,
        waitForSteadyState: false,
    });

    // expose some APIs meant for testing purposes.
    let api = new cloud.API("examples-containers");
    api.get("/test", async (req, res) => {
        try {
            res.json({
                nginx: await nginx.getEndpoint(),
                nginx2: await builtService.getEndpoint(),
            });
        } catch (err) {
            console.error(errorJSON(err));
            res.status(500).json(errorJSON(err));
        }
    });

    function errorJSON(err: any) {
        const result: any = Object.create(null);
        Object.getOwnPropertyNames(err).forEach(key => result[key] = err[key]);
        return result;
github pulumi / pulumi-cloud / examples / api / index.ts View on Github external
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as cloud from "@pulumi/cloud";
import { Output } from "@pulumi/pulumi";

const api = new cloud.API("examples-test");
api.get("/test1.txt", (req, res) => {
    res.setHeader("Content-Type", "text/html");
    res.end("You got test1");
});
api.proxy("/google", "http://www.google.com/")

export let url = api.publish().url;
github pulumi / pulumi-cloud / examples / api / variants / updateGetEndpoint / index.ts View on Github external
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

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

const api = new cloud.API("examples-test");
api.get("/test2.txt", (req, res) => {
    res.setHeader("Content-Type", "text/html");
    res.end("You got test2");
});

api.publish();

@pulumi/cloud

A highly productive, cloud neutral programming model.

Apache-2.0
Latest version published 10 months ago

Package Health Score

72 / 100
Full package analysis