How to use the @pulumi/cloud.Service 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
constructor(name: string, memory: number = 128) {
        let redis = new cloud.Service(name, {
            containers: {
                redis: {
                    image: "redis:alpine",
                    memory: memory,
                    ports: [{ port: 6379 }],
                    command: ["redis-server", "--requirepass", redisPassword],
                },
            },
        });
        this.get = (key: string) => {
            return redis.getEndpoint("redis", 6379).then(endpoint => {
                // console.log(`Endpoint: ${JSON.stringify(endpoint)}`);
                let client = require("redis").createClient(
                    endpoint.port,
                    endpoint.hostname,
                    { password: redisPassword },
github pulumi / pulumi-cloud / examples / containers / index.ts View on Github external
replicas: 2,
});

export let nginxEndpoint: Output = nginx.defaultEndpoint;

// A simple NGINX service, scaled out over two containers, using a single container rather than a map.
let simpleNginx = new cloud.Service("examples-simple-nginx", {
    image: "nginx",
    memory: 128,
    ports: [{ port: 80 }],
    replicas: 2,
});

export let simpleNginxEndpoint: Output = simpleNginx.defaultEndpoint;

let cachedNginx = new cloud.Service("examples-cached-nginx", {
    containers: {
        nginx: {
            build: {
                context: "./app",
                cacheFrom: true,
            },
            memory: 128,
            ports: [{ port: 80 }],
        },
    },
    replicas: 2,
});

let multistageCachedNginx = new cloud.Service("examples-multistage-cached-nginx", {
    containers: {
        nginx: {
github pulumi / pulumi-cloud / examples / containers / index.ts View on Github external
// 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 pulumi from "@pulumi/pulumi";
import * as cloud from "@pulumi/cloud";
import { Config, Output } from "@pulumi/pulumi";

// A simple NGINX service, scaled out over two containers.
let nginx = new cloud.Service("examples-nginx", {
    containers: {
        nginx: {
            image: "nginx",
            memory: 128,
            ports: [{ port: 80 }],
        },
    },
    replicas: 2,
});

export let nginxEndpoint: Output = nginx.defaultEndpoint;

// A simple NGINX service, scaled out over two containers, using a single container rather than a map.
let simpleNginx = new cloud.Service("examples-simple-nginx", {
    image: "nginx",
    memory: 128,
github pulumi / examples / cloud-ts-voting-app / index.ts View on Github external
containers: {
        redis: {
            image: "redis:alpine",
            memory: 512,
            ports: [{ port: redisPort }],
            command: ["redis-server", "--requirepass", redisPassword],
        },
    },
});

const redisEndpoint = redisCache.endpoints.redis[redisPort];

// A custom container for the frontend, which is a Python Flask app
// Use the 'build' property to specify a folder that contains a Dockerfile.
// Pulumi builds the container for you and pushes to an ECR registry
const frontend = new cloud.Service("voting-app-frontend", {
    containers: {
        votingAppFrontend: {
            build: "./frontend",   // path to the folder containing the Dockerfile
            memory: 512,
            ports: [{ port: 80 }],
            environment: {
                // pass the Redis container info in environment variables
                "REDIS":      redisEndpoint.hostname,
                "REDIS_PORT": redisEndpoint.apply(e => e.port.toString()),
                "REDIS_PWD":  redisPassword,
            },
        },
    },
});

// Export a variable that will be displayed during 'pulumi up'
github pulumi / examples / cloud-ts-voting-app / index.ts View on Github external
// 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";
import * as pulumi from "@pulumi/pulumi";

// Get the password to use for Redis from config.
const config = new pulumi.Config();
const redisPassword = config.require("redisPassword");
const redisPort = 6379;

// The data layer for the application
// Use the 'image' property to point to a pre-built Docker image.
const redisCache = new cloud.Service("voting-app-cache", {
    containers: {
        redis: {
            image: "redis:alpine",
            memory: 512,
            ports: [{ port: redisPort }],
            command: ["redis-server", "--requirepass", redisPassword],
        },
    },
});

const redisEndpoint = redisCache.endpoints.redis[redisPort];

// A custom container for the frontend, which is a Python Flask app
// Use the 'build' property to specify a folder that contains a Dockerfile.
// Pulumi builds the container for you and pushes to an ECR registry
const frontend = new cloud.Service("voting-app-frontend", {
github pulumi / pulumi-cloud / examples / containers / index.ts View on Github external
// A simple NGINX service, scaled out over two containers.
let nginx = new cloud.Service("examples-nginx", {
    containers: {
        nginx: {
            image: "nginx",
            memory: 128,
            ports: [{ port: 80 }],
        },
    },
    replicas: 2,
});

export let nginxEndpoint: Output = nginx.defaultEndpoint;

// A simple NGINX service, scaled out over two containers, using a single container rather than a map.
let simpleNginx = new cloud.Service("examples-simple-nginx", {
    image: "nginx",
    memory: 128,
    ports: [{ port: 80 }],
    replicas: 2,
});

export let simpleNginxEndpoint: Output = simpleNginx.defaultEndpoint;

let cachedNginx = new cloud.Service("examples-cached-nginx", {
    containers: {
        nginx: {
            build: {
                context: "./app",
                cacheFrom: true,
            },
            memory: 128,
github pulumi / pulumi-cloud / examples / containers / index.ts View on Github external
});
                });
            });
        };
    }
}

let cache = new Cache("examples-mycache");

let helloTask = new cloud.Task("examples-hello-world", {
    image: "hello-world",
    memory: 20,
});

// 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({
github pulumi / examples / cloud-ts-url-shortener-cache / cache.ts View on Github external
constructor(name: string, memory: number = 128) {
        const pw = config.redisPassword;
        this.redis = new cloud.Service(name, {
            containers: {
                redis: {
                    image: "redis:alpine",
                    memory: memory,
                    ports: [{ port: 6379 }],
                    command: ["redis-server", "--requirepass", pw],
                },
            },
        });

        const endpoint = this.redis.endpoints.redis[6379];
        this.get = async (key: string) => {
            const ep = (await endpoint).get();
            console.log(`Getting key '${key}' on Redis@${ep.hostname}:${ep.port}`);

            const client = require("redis").createClient(ep.port, ep.hostname, { password: pw });
github pulumi / pulumi-cloud / examples / containers / index.ts View on Github external
let cachedNginx = new cloud.Service("examples-cached-nginx", {
    containers: {
        nginx: {
            build: {
                context: "./app",
                cacheFrom: true,
            },
            memory: 128,
            ports: [{ port: 80 }],
        },
    },
    replicas: 2,
});

let multistageCachedNginx = new cloud.Service("examples-multistage-cached-nginx", {
    containers: {
        nginx: {
            build: {
                context: "./app",
                dockerfile: "./app/Dockerfile-multistage",
                cacheFrom: {stages: ["build"]},
            },
            memory: 128,
            ports: [{ port: 80 }],
        },
    },
    replicas: 2,
});

let customWebServer = new cloud.Service("mycustomservice", {
    containers: {
github pulumi / examples / cloud-ts-url-shortener-cache-http / cache.ts View on Github external
constructor(name: string, memory: number = 128) {
        const pw = config.redisPassword;
        this.redis = new cloud.Service(name, {
            containers: {
                redis: {
                    image: "redis:alpine",
                    memory: memory,
                    ports: [{ port: 6379, external: true }],
                    command: ["redis-server", "--requirepass", pw],
                },
            },
        });

        this.endpoint = this.redis.endpoints.redis[6379];
    }

@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