diff --git a/README.md b/README.md index af159f1..ece9a70 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,9 @@ functions: input: key-a: "value-a" key-b: "value-b" + + # ID of the private network to attach the function to + privateNetworkId: "3fd741d4-f686-4afc-bcea-d720c695748f" ``` ### Container-specific configuration @@ -264,6 +267,9 @@ custom: # Deprecated: number of simultaneous requests to handle # Please use scalingOption of type concurrentRequests instead # maxConcurrency: 20 + + # ID of the private network to attach the container to + privateNetworkId: "3fd741d4-f686-4afc-bcea-d720c695748f" ``` ## Supported commands diff --git a/deploy/lib/createContainers.js b/deploy/lib/createContainers.js index 0315876..b227229 100644 --- a/deploy/lib/createContainers.js +++ b/deploy/lib/createContainers.js @@ -154,6 +154,7 @@ module.exports = { sandbox: container.sandbox, health_check: adaptHealthCheckToAPI(container.healthCheck), scaling_option: adaptScalingOptionToAPI(container.scalingOption), + private_network_id: container.privateNetworkId, }; // checking if there is custom_domains set on container creation. @@ -177,6 +178,13 @@ module.exports = { }, async updateSingleContainer(container, foundContainer) { + let privateNetworkId = container.privateNetworkId; + const hasToDeletePrivateNetwork = + foundContainer.private_network_id && !container.privateNetworkId; + if (hasToDeletePrivateNetwork) { + privateNetworkId = ""; + } + const params = { redeploy: false, environment_variables: container.env, @@ -201,6 +209,7 @@ module.exports = { sandbox: container.sandbox, health_check: adaptHealthCheckToAPI(container.healthCheck), scaling_option: adaptScalingOptionToAPI(container.scalingOption), + private_network_id: privateNetworkId, }; // note about maxConcurrency deprecation diff --git a/deploy/lib/createFunctions.js b/deploy/lib/createFunctions.js index a4a4cda..e48b471 100644 --- a/deploy/lib/createFunctions.js +++ b/deploy/lib/createFunctions.js @@ -183,6 +183,7 @@ Runtime lifecycle doc : https://www.scaleway.com/en/docs/compute/functions/refer domain_name: func.domain_name, http_option: func.httpOption, sandbox: func.sandbox, + private_network_id: func.privateNetworkId, }; const availableRuntimes = await this.listRuntimes(); @@ -208,6 +209,13 @@ Runtime lifecycle doc : https://www.scaleway.com/en/docs/compute/functions/refer }, async updateSingleFunction(func, foundFunc) { + let privateNetworkId = func.privateNetworkId; + const hasToDeletePrivateNetwork = + foundFunc.private_network_id && !func.privateNetworkId; + if (hasToDeletePrivateNetwork) { + privateNetworkId = ""; + } + const params = { redeploy: false, environment_variables: func.env, @@ -226,6 +234,7 @@ Runtime lifecycle doc : https://www.scaleway.com/en/docs/compute/functions/refer domain_name: func.domain_name, http_option: func.httpOption, sandbox: func.sandbox, + private_network_id: privateNetworkId, }; const availableRuntimes = await this.listRuntimes();