How to use the @pulumi/pulumi.ComponentResource function in @pulumi/pulumi

To help you get started, we’ve selected a few @pulumi/pulumi 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 / tests / integration / aliases / nodejs / retype_component / step2 / index.ts View on Github external
// Copyright 2016-2018, Pulumi Corporation.  All rights reserved.

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

class Resource extends pulumi.ComponentResource {
    constructor(name: string, opts?: pulumi.ComponentResourceOptions) {
        super("my:module:Resource", name, {}, opts);
    }
}

// Scenario #4 - change the type of a component
class ComponentFour extends pulumi.ComponentResource {
    resource: Resource;
    constructor(name: string, opts?: pulumi.ComponentResourceOptions) {
        // Add an alias that references the old type of this resource...
        const aliases = [{ type: "my:module:ComponentFour" }, ...((opts && opts.aliases) || [])];
        // ..and then make the super call with the new type of this resource and the added alias.
        super("my:differentmodule:ComponentFourWithADifferentTypeName", name, {}, { ...opts, aliases });
        // The child resource will also pick up an implicit alias due to the new type of the component it is parented
        // to.
        this.resource = new Resource("otherchild", { parent: this });
    }
}
const comp4 = new ComponentFour("comp4");
github pulumi / pulumi / tests / integration / aliases / nodejs / rename_component / step1 / index.ts View on Github external
// Copyright 2016-2018, Pulumi Corporation.  All rights reserved.

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

class Resource extends pulumi.ComponentResource {
    constructor(name: string, opts?: pulumi.ComponentResourceOptions) {
        super("my:module:Resource", name, {}, opts);
    }
}

// Scenario #3 - rename a component (and all it's children)
class ComponentThree extends pulumi.ComponentResource {
    resource1: Resource;
    resource2: Resource;
    constructor(name: string, opts?: pulumi.ComponentResourceOptions) {
        super("my:module:ComponentThree", name, {}, opts);
        // Note that both un-prefixed and parent-name-prefixed child names are supported. For the later, the implicit
        // alias inherited from the parent alias will include replacing the name prefix to match the parent alias name.
        this.resource1 = new Resource(`${name}-child`, {parent: this});
        this.resource2 = new Resource("otherchild", {parent: this});
    }
}
const comp3 = new ComponentThree("comp3");
github pulumi / pulumi-cloud / azure / api.ts View on Github external
public all(path: string, ...handlers: cloud.RouteHandler[]) {
        throw new Error("Method not implemented.");
    }

    public attachCustomDomain(domain: cloud.Domain): void {
        throw new Error("Method not implemented.");
    }

    public publish(): HttpDeployment {
        throw new Error("Method not implemented.");
    }
}

// HttpDeployment actually performs a deployment of a set of HTTP API Gateway resources.
export class HttpDeployment extends pulumi.ComponentResource implements cloud.HttpDeployment {
    public /*out*/ readonly url: pulumi.Output; // the URL for this deployment.
    public /*out*/ readonly customDomainNames: pulumi.Output[]; // any custom domain names.

    constructor(name: string, opts?: pulumi.ResourceOptions) {
        super("cloud:http:API", name, {}, opts);

        throw new Error("Method not implemented.");

        this.registerOutputs({
            url: this.url,
            customDomainNames: this.customDomainNames,
        });
    }
}

/**
github pulumi / examples / kubernetes-ts-jenkins / jenkins.ts View on Github external
memory: args.resources.memory,
                                    cpu: args.resources.cpu,
                                },
                            },
                        }, // container
                    ], // containers
                }, // spec
            }, // template
        }, // spec
    }; // deployment
}

/**
 * ComponentResource for a Jenkins instance running in a Kubernetes cluster.
 */
export class Instance extends pulumi.ComponentResource {
    constructor(args: JenkinsArgs, opts?: pulumi.ResourceOptions) {
        super("jenkins:jenkins:Instance", args.name, args, opts);

        // The Secret will contain the root password for this instance.
        const secret = new k8s.core.v1.Secret(`${args.name}-secret`, {
            metadata: {
                name: args.name,
            },
            type: "Opaque",
            data: {
                "jenkins-password": Buffer.from(args.credentials.password).toString("base64"),
            },
        }, { parent: this });

        // The PVC provides persistent storage for Jenkins state.
        const pvc = new k8s.core.v1.PersistentVolumeClaim(`${args.name}-pvc`, {
github pulumi / pulumi-awsx / nodejs / awsx / autoscaling / autoscaling.ts View on Github external
// 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 aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

import * as x from "..";
import * as utils from "../utils";

import { AutoScalingLaunchConfiguration, AutoScalingLaunchConfigurationArgs } from "./launchConfiguration";
import { cronExpression, ScheduleArgs } from "./schedule";
import * as stepScaling from "./stepScaling";
import * as targetTracking from "./targetTracking";

export class AutoScalingGroup extends pulumi.ComponentResource {
    public readonly vpc: x.ec2.Vpc;

    /**
     * The [cloudformation.Stack] that was used to create this [AutoScalingGroup].  [CloudFormation]
     * is used here as the existing AWS apis for creating [AutoScalingGroup]s are not rich enough to
     * express everything that can be configured through [CloudFormation] itself.
     */
    public readonly stack: aws.cloudformation.Stack;

    /**
     * The launch configuration for this auto scaling group.
     */
    public readonly launchConfiguration: AutoScalingLaunchConfiguration;

    /**
     * Underlying [autoscaling.Group] that is created by cloudformation.
github pulumi / examples / kubernetes-ts-multicloud / app.ts View on Github external
// 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 k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";

// Arguments for the demo app.
export interface DemoAppArgs {
    provider: k8s.Provider; // Provider resource for the target Kubernetes cluster.
    imageTag: string; // Tag for the kuard image to deploy.
    staticAppIP?: pulumi.Input; // Optional static IP to use for the service. (Required for AKS).
}

export class DemoApp extends pulumi.ComponentResource {
    public appUrl: pulumi.Output;

    constructor(name: string,
                args: DemoAppArgs,
                opts: pulumi.ComponentResourceOptions = {}) {
        super("examples:kubernetes-ts-multicloud:demo-app", name, args, opts);

        // Create the kuard Deployment.
        const appLabels = {app: "kuard"};
        const deployment = new k8s.apps.v1.Deployment(`${name}-demo-app`, {
            spec: {
                selector: {matchLabels: appLabels},
                replicas: 1,
                template: {
                    metadata: {labels: appLabels},
                    spec: {
github pulumi / pulumi-awsx / nodejs / awsx / ecs / cluster.ts View on Github external
// See the License for the specific language governing permissions and
// limitations under the License.

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

import * as x from "..";
import * as utils from "../utils";

let defaultCluster: Cluster;

/**
 * A Cluster is a general purpose ECS cluster configured to run in a provided Network.
 */
export class Cluster
        extends pulumi.ComponentResource
        implements x.autoscaling.AutoScalingUserData {
    public readonly cluster: Promise;
    public readonly id: pulumi.Output;

    /**
     * The network in which to create this cluster.
     */
    public readonly vpc: Promise;
    /**
     * Security groups associated with this this ECS Cluster.
     */
    public readonly securityGroups: Promise;

    public readonly extraBootcmdLines: () => pulumi.Input;

    public readonly autoScalingGroups: x.autoscaling.AutoScalingGroup[] = [];
github pulumi / pulumi-awsx / nodejs / awsx / ecs / taskDefinition.ts View on Github external
// 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 aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

import * as awssdk from "aws-sdk";

import * as ecs from ".";
import * as x from "..";
import * as role from "../role";
import * as utils from "../utils";

export abstract class TaskDefinition extends pulumi.ComponentResource {
    public readonly taskDefinition: aws.ecs.TaskDefinition;
    public readonly logGroup?: aws.cloudwatch.LogGroup;
    public readonly containers: Record;
    public readonly taskRole?: aws.iam.Role;
    public readonly executionRole?: aws.iam.Role;

    /**
     * Mapping from container in this task to the ELB listener exposing it through a load balancer.
     * Only present if a listener was provided in [Container.portMappings] or in
     * [Container.applicationListener] or [Container.networkListener].
     */
    public readonly listeners: Record = {};
    public readonly applicationListeners: Record = {};
    public readonly networkListeners: Record = {};

    /**
github pulumi / pulumi-aws / sdk / nodejs / serverless / function.ts View on Github external
* The packages relative to the program folder to not include the Lambda upload. This can be
     * used to override the default serialization logic that includes all packages referenced by
     * project.json (except @pulumi packages).  Default is `[]`.
     *
     * @deprecated Use [codePathOptions] instead.
     */
    excludePackages?: string[];
}>;

/**
 * Function is a higher-level API for creating and managing AWS Lambda Function resources
 * implemented by a Pulumi lambda expression and with a set of attached policies.
 *
 * @deprecated Use [lambda.CallbackFunction] instead.
 */
export class Function extends pulumi.ComponentResource {
    public readonly options: FunctionOptions;
    public readonly lambda: lambda.Function;
    public readonly role: Role | undefined;

    /**
     * @param func Deprecated.  Pass the function as [options.func] or [options.factoryFunc] instead.
     */
    constructor(name: string,
                options: FunctionOptions,
                func?: Handler,
                opts?: pulumi.ResourceOptions) {

        super("aws:serverless:Function", name, {}, opts);

        opts = opts || { parent: this };
github pulumi / pulumi-aws / sdk / nodejs / lambda / zMixins.ts View on Github external
* the entrypoint for the AWS Lambda. Either [callback] or [callbackFactory] must be
     * provided.
     *
     * This form is useful when there is expensive initialization work that should only be executed
     * once.  The factory-function will be invoked once when the final AWS Lambda module is loaded.
     * It can run whatever code it needs, and will end by returning the actual function that Lambda
     * will call into each time the Lambda is invoked.
     */
    callbackFactory?: CallbackFactory;
};

/**
 * Base type for all subscription types.  An event subscription represents a connection between some
 * AWS resource and an AWS lambda that will be triggered when something happens to that resource.
 */
export class EventSubscription extends pulumi.ComponentResource {
    public permission!: permission.Permission;
    public func!: LambdaFunction;

    public constructor(
        type: string, name: string, opts?: pulumi.ComponentResourceOptions) {

        super(type, name, {}, opts);
    }
}

export function isEventHandler(obj: any): obj is EventHandler {
    return LambdaFunction.isInstance(obj) || obj instanceof Function;
}

export function createFunctionFromEventHandler(
    name: string, handler: EventHandler, opts?: pulumi.ResourceOptions): LambdaFunction {