Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Pulumi resource config cloning #3572

Merged
merged 3 commits into from
Oct 4, 2023

Conversation

Pavel910
Copy link
Collaborator

@Pavel910 Pavel910 commented Oct 4, 2023

Changes

This PR adds an ability to clone a config of an existing Pulumi resource.

Code sample:

import * as aws from "@pulumi/aws";
import { createApiApp } from "@webiny/serverless-cms-aws";

export default createApiApp({
    pulumiResourceNamePrefix: "wby-",
    pulumi(app) {
        const resource = app.resources.graphql.functions.graphql;

        /**
         * Create a clone of the main `graphql` function, but more powerful, and with maximum timeout.
         */
        const internalWorkerFn = app.addResource(aws.lambda.Function, {
            name: "wby-internal-worker",
            config: {
                ...resource.config.clone(),
                timeout: 900,
                memorySize: 3008
            }
        });

        /**
         * Assign the new worker function ARN to the main `graphql` function.
         */
        resource.config.environment(env => {
            return {
                variables: {
                    ...env?.variables,
                    WORKER_FUNCTION: internalWorkerFn.output.arn
                }
            };
        });
    }
});

How Has This Been Tested?

Manually.

@Pavel910 Pavel910 added this to the 5.37.5 milestone Oct 4, 2023
@Pavel910 Pavel910 self-assigned this Oct 4, 2023
@Pavel910 Pavel910 merged commit 88829ab into dev Oct 4, 2023
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants