1. Error waiting for Updating CloudFunctions Function: Error code 3, message: Build failed: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function; Error ID: 5c04ec9c

    Python

    It seems like you're encountering an error when trying to deploy a Google Cloud Function using Pulumi. The error message suggests that the 'main.py' file is missing in your directory, and the GOOGLE_FUNCTION_SOURCE environment variable isn't set. This file or variable is required because it specifies the Python script that contains your Cloud Function.

    You can solve this issue by ensuring that you have a 'main.py' file in your project root directory that contains your Cloud Function. The name of this file can be changed by setting the GOOGLE_FUNCTION_SOURCE environment variable to point to your Python script.

    Alternatively, you can create an environment configuration using the pulumi.config.set method to set GOOGLE_FUNCTION_SOURCE to your file. Here's an example of how to set this up:

    import pulumi from pulumi_gcp import cloudfunctions # Makes an environment variable with key 'GOOGLE_FUNCTION_SOURCE' and value 'my_function.py' pulumi.config.set('GOOGLE_FUNCTION_SOURCE', 'my_function.py') f = cloudfunctions.Function('myFunction', source_archive_bucket="source-archive-bucket", runtime="python37", entry_point="my_function", # Name of the function in your python file trigger_http="true", available_memory_mb=128, )

    Remember to replace 'my_function.py' with the actual filename where your function resides (if it's different than 'main.py'), and 'my_function' with the name of your function in your Python file.

    And ensure that 'my_function.py' is located in the same directory from which you're running your Pulumi program or in a directory referenced in the GOOGLE_FUNCTION_SOURCE environment variable.

    This should fix the issue, and you should be able to successfully deploy your Cloud Function using Pulumi afterward.



  2. pulumi.config does not have the method set.

    Python

    You are correct that pulumi.config in Python does not have a set function as with some other programming languages like JavaScript or TypeScript. Instead, it uses the Pythonic way of setting attributes.

    Here is an example of how you can set a configuration value in Python.

    import pulumi cfg = pulumi.Config() cfg['key_name'] = 'value' # sets the configuration key 'key_name' to 'value'

    In this example, we first initialize a pulumi.Config() object and assign it to the variable cfg. Then, we use the indexing operator [] to set a key-value pair in the config. The key is specified as a string, and can be assigned any string value.

    Remember, this will set the configuration value for the current Pulumi stack. This is often done in the main program. If you haven't set up a stack or you run this code outside the context of a Pulumi program, it could lead to an error.