如何使用 pulumi 将特定入口点设置为 google 云函数
How to set an specific entrypoint to a google cloud function with pulumi
目前我开始使用 pulumi 作为 IaC 工具,同时我也在使用 TypeScript。对于带有 HTTP 触发器的 google 云函数,有谁知道如何使用特定名称设置 urn?我正在创建一个新函数作为下面的代码。
我使用以下代码作为参考:https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/gcp/cloudfunctions
这是我的代码:
const functionArchives = new gcp.storage.BucketObject("functionName", {
bucket: bucket.name,
source: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive("./path"),
}),
});
const myFunction = new gcp.cloudfunctions.Function("functionName", {
availableMemoryMb: 128,
description: "Description",
entryPoint: "functionName",
environmentVariables: envVariables,
labels: {
"key": "val"
},
runtime: "nodejs8",
sourceArchiveBucket: bucket.name,
sourceArchiveObject: functionArchives.name,
timeout: 60,
triggerHttp: true,
});
但该代码总是在创建骨灰盒时在我最初设置的字符串末尾添加一些字符。即:
https://<region-projectname>.cloudfunctions.net/functionName-43db05f
我希望骨灰盒是
https://<region-projectname>.cloudfunctions.net/functionName
您可以通过将 name
参数传递给 Function
构造函数来实现:
const myFunction = new gcp.cloudfunctions.Function("functionName", {
// ... other args
name: "functionName",
// ... other args
});
默认情况下,Pulumi 会为所有名称附加一个唯一代码。来自 https://www.pulumi.com/docs/reference/programming-model/#autonaming:
This random postfix is added by default for two reasons. First, it ensures that two instances of a program can be deployed to the same environment without risk of name collisions. Second, it ensures that it will be possible to do zero-downtime replacements when needed, by creating the new resource first, updating any references to point to it, and then deleting the old resource.
可以通过在资源上显式设置 name
属性 来针对每个资源覆盖此行为。
目前我开始使用 pulumi 作为 IaC 工具,同时我也在使用 TypeScript。对于带有 HTTP 触发器的 google 云函数,有谁知道如何使用特定名称设置 urn?我正在创建一个新函数作为下面的代码。
我使用以下代码作为参考:https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/gcp/cloudfunctions
这是我的代码:
const functionArchives = new gcp.storage.BucketObject("functionName", {
bucket: bucket.name,
source: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive("./path"),
}),
});
const myFunction = new gcp.cloudfunctions.Function("functionName", {
availableMemoryMb: 128,
description: "Description",
entryPoint: "functionName",
environmentVariables: envVariables,
labels: {
"key": "val"
},
runtime: "nodejs8",
sourceArchiveBucket: bucket.name,
sourceArchiveObject: functionArchives.name,
timeout: 60,
triggerHttp: true,
});
但该代码总是在创建骨灰盒时在我最初设置的字符串末尾添加一些字符。即:
https://<region-projectname>.cloudfunctions.net/functionName-43db05f
我希望骨灰盒是
https://<region-projectname>.cloudfunctions.net/functionName
您可以通过将 name
参数传递给 Function
构造函数来实现:
const myFunction = new gcp.cloudfunctions.Function("functionName", {
// ... other args
name: "functionName",
// ... other args
});
默认情况下,Pulumi 会为所有名称附加一个唯一代码。来自 https://www.pulumi.com/docs/reference/programming-model/#autonaming:
This random postfix is added by default for two reasons. First, it ensures that two instances of a program can be deployed to the same environment without risk of name collisions. Second, it ensures that it will be possible to do zero-downtime replacements when needed, by creating the new resource first, updating any references to point to it, and then deleting the old resource.
可以通过在资源上显式设置 name
属性 来针对每个资源覆盖此行为。