How to use the @pulumi/pulumi.dynamic 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 / stack_parenting / index.ts View on Github external
this.create = async (inputs: any) => {
            return {
                id: (currentID++).toString(),
                outs: undefined,
            };
        };
    }
}

class Component extends pulumi.ComponentResource {
    constructor(name: string, parent?: pulumi.ComponentResource) {
        super("component", name, {}, { parent: parent });
    }
}

class Resource extends pulumi.dynamic.Resource {
    constructor(name: string, parent?: pulumi.ComponentResource) {
        super(Provider.instance, name, {}, { parent: parent });
    }
}

// Just allocate a few resources and make sure their URNs are correct with respect to parents, etc.  This
// should form a tree of roughly the following structure:
//
//     A      F
//    / \      \
//   B   C      G
//      / \
//     D   E
//
// with the caveat, of course, that A and F will share a common parent, the implicit stack.
let a = new Component("a");
github pulumi / pulumi / tests / integration / single_resource / resource.ts View on Github external
export class Provider implements pulumi.dynamic.ResourceProvider {
    public static readonly instance = new Provider();

    public readonly create: (inputs: any) => Promise;

    constructor() {
        this.create = async (inputs: any) => {
            return {
                id: (currentID++).toString(),
                outs: undefined,
            };
        };
    }
}

export class Resource extends pulumi.dynamic.Resource {
    public readonly state?: any;

    constructor(name: string, props: ResourceProps, opts?: pulumi.ResourceOptions) {
        super(Provider.instance, name, props, opts);
        this.state = props.state;
    }
}

export interface ResourceProps {
    state?: any; // arbitrary state bag that can be updated without replacing.
}
github pulumi / pulumi / tests / integration / protect_resources / step1 / resource.ts View on Github external
export class Provider implements pulumi.dynamic.ResourceProvider {
    public static readonly instance = new Provider();

    public readonly create: (inputs: any) => Promise;

    constructor() {
        this.create = async (inputs: any) => {
            return {
                id: (currentID++).toString(),
                outs: undefined,
            };
        };
    }
}

export class Resource extends pulumi.dynamic.Resource {
    constructor(name: string, props: ResourceProps, opts?: pulumi.ResourceOptions) {
        super(Provider.instance, name, props, opts);
    }
}

export interface ResourceProps {
    state?: any; // arbitrary state bag that can be updated without replacing.
}
github pulumi / actions-pulumify / infra / bucketDirectory.ts View on Github external
}).promise();
        if (resp && resp.FunctionError) {
            throw new Error(
                `Invoking sync function '${syncFunc}' failed [${resp.FunctionError}]: ${JSON.stringify(resp.Payload)}`);
        }
    } catch (err) {
        // TODO[pulumi/pulumi#2721]: this can go away once diagnostics for dynamic providers is improved.
        console.log(err);
        throw err;
    }
}

/**
 * BucketDirectoryLambdaSyncer is the implementation of the "server-lambda" sync strategy.
 */
class BucketDirectoryLambdaSyncer extends pulumi.dynamic.Resource  {
    private static provider = {
        create: async(inputs: any): Promise => {
            await invokeLambdaSync(inputs, "Create");
            return { id: uuid(), outs: inputs };
        },
        update: async(id: pulumi.ID, olds: any, news: any): Promise => {
            if (olds.archiveEtag !== news.archiveEtag) {
                await invokeLambdaSync(news, "Update");
            }
            return { outs: news };
        },
        delete: async(id: pulumi.ID, olds: any): Promise => {
            await invokeLambdaSync(olds, "Delete");
        },
    };
github pulumi / examples / azure-ts-dynamicresource / cdnCustomDomain.ts View on Github external
currentOutputs.httpsEnabled = false;
        return { outs: currentOutputs };
    }
}

/**
 * CDNCustomDomainResource is a resource that can be used to create
 * custom domains against Azure CDN resources.
 * The Azure CDN resource itself must exist in order to create a custom domain for it.
 *
 * Outputs from the dynamic resource provider must be declared in the dynamic resource itself
 * as `public readonly` members with the type `Output`. These are automatically set by the dynamic
 * provider engine. The names of these properties must match the names of the properties exactly as
 * returned in the outputs of the dynamic resource provider functions.
 */
export class CDNCustomDomainResource extends pulumi.dynamic.Resource {
    /**
     * These are the same properties that were originally passed as inputs, but available as outputs
     * for convenience. The names of these properties must match with `CustomDomainOptions`.
     */
    public readonly resourceGroupName: pulumi.Output;
    public readonly profileName: pulumi.Output;
    public readonly endpointName: pulumi.Output;
    public readonly customDomainHostName: pulumi.Output;
    public readonly httpsEnabled: pulumi.Output;

    // The following are properties set by the CDN rest client.
    public readonly customHttpsProvisioningState: pulumi.Output;
    public readonly customHttpsProvisioningSubstate: pulumi.Output;
    public readonly provisioningState: pulumi.Output;
    public readonly resourceState: pulumi.Output;
    public readonly type: pulumi.Output;
github pulumi / examples / azure-ts-static-website / staticWebsite.ts View on Github external
// Extract the web endpoint and the hostname from the storage account
        const endpoint = executeToJson(`az storage account show -n "${accountName}" --query "primaryEndpoints.web"`);
        const hostName = url.parse(endpoint).hostname;

        // Files for static websites should be stored in a special built-in container called '$web', see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website
        const webContainerName = "$web";

        return {
            id: `${accountName}StaticWebsite`,
            outs: { endpoint, hostName, webContainerName },
        };
    }
}

export class StorageStaticWebsite extends pulumi.dynamic.Resource {
    public readonly endpoint: pulumi.Output;
    public readonly hostName: pulumi.Output;
    public readonly webContainerName: pulumi.Output;

    constructor(name: string, args: StorageStaticWebsiteArgs, opts?: pulumi.CustomResourceOptions) {
        super(new StorageStaticWebsiteProvider(), name, { ...args, endpoint: undefined, hostName: undefined, webContainerName: undefined }, opts);
    }
}
github pulumi / pulumi / tests / integration / read / read_dbr / step1 / resource.ts View on Github external
}
    }

    public async update(id: string, olds: any, news: any): Promise {
        throw Error("this resource is replace-only and can't be updated");
    }

    public async read(id: pulumi.ID, props: any): Promise {
        return {
            id: id,
            props: props,
        }
    }
}

export class Resource extends pulumi.dynamic.Resource {
    public readonly state: pulumi.Output;

    constructor(name: string, props: any, opts?: pulumi.ResourceOptions) {
        super(Provider.instance, name, props, opts);
    }
}
github pulumi / pulumi / tests / integration / transformations / nodejs / simple / index.ts View on Github external
const simpleProvider: pulumi.dynamic.ResourceProvider = {
    async create(inputs: any) {
        return {
            id: "0",
            outs: { output: "a", output2: "b" },
        };
    },
};

interface SimpleArgs {
    input: pulumi.Input;
    optionalInput?: pulumi.Input;
}

class SimpleResource extends pulumi.dynamic.Resource {
    output: pulumi.Output;
    output2: pulumi.Output;
    constructor(name, args: SimpleArgs, opts?: pulumi.CustomResourceOptions) {
        super(simpleProvider, name, { ...args, output: undefined, output2: undefined }, opts);
    }
}

class MyComponent extends pulumi.ComponentResource {
    child: SimpleResource;
    constructor(name: string, opts?: pulumi.ComponentResourceOptions) {
        super("my:component:MyComponent", name, {}, opts);
        this.child = new SimpleResource(`${name}-child`, { input: "hello" }, {
            parent: this,
            additionalSecretOutputs: ["output2"],
        });
        this.registerOutputs({});
github pulumi / pulumi / tests / integration / read / read_relinquish / step1 / resource.ts View on Github external
}
    }

    public async update(id: string, olds: any, news: any): Promise {
        throw Error("this resource is replace-only and can't be updated");
    }

    public async read(id: pulumi.ID, props: any): Promise {
        return {
            id: id,
            props: props,
        }
    }
}

export class Resource extends pulumi.dynamic.Resource {
    public readonly state: pulumi.Output;

    constructor(name: string, props: any, opts?: pulumi.ResourceOptions) {
        super(Provider.instance, name, props, opts);
    }
}
github pulumi / pulumi / tests / integration / delete_before_create / step1 / resource.ts View on Github external
}

        return {
            changes: false,
        };
    }

    public async create(inputs: any): Promise {
        return {
            id: uuidv4(),
            outs: inputs,
        };
    }
}

export class Resource extends pulumi.dynamic.Resource {
    public uniqueKey?: pulumi.Output;
    public state: pulumi.Output;
    public noReplace?: pulumi.Output;

    constructor(name: string, props: ResourceProps, opts?: pulumi.CustomResourceOptions) {
        super(Provider.instance, name, props, opts);
    }
}

export interface ResourceProps {
    readonly uniqueKey?: pulumi.Input;
    readonly state: pulumi.Input;
    readonly noReplace?: pulumi.Input;
    readonly noDBR?: pulumi.Input;
}