@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
409 lines • 18.5 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* The `scaleway.containers.Container` resource allows you to create and manage [Serverless Containers](https://www.scaleway.com/en/docs/serverless/containers/).
*
* Refer to the Serverless Containers [product documentation](https://www.scaleway.com/en/docs/serverless/containers/) and [API documentation](https://www.scaleway.com/en/developers/api/serverless-containers/) for more information.
*
* For more information on the limitations of Serverless Containers, refer to the [dedicated documentation](https://www.scaleway.com/en/docs/serverless-containers/reference-content/containers-limitations/).
*
* ## Example Usage
*
* ### Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.containers.Namespace("main", {});
* const mainContainer = new scaleway.containers.Container("main", {
* name: "my-container",
* description: "This container has a description.",
* tags: [
* "tag1",
* "tag2",
* ],
* namespaceId: main.id,
* image: "nginx:latest",
* port: 80,
* cpuLimit: 1024,
* memoryLimitBytes: 2048000000,
* minScale: 3,
* maxScale: 5,
* timeout: 600,
* protocol: "http1",
* commands: [
* "bash",
* "-c",
* "script.sh",
* ],
* args: [
* "some",
* "args",
* ],
* environmentVariables: {
* foo: "var",
* },
* secretEnvironmentVariables: {
* key: "secret",
* },
* });
* ```
*
* ### VPC integration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const vpc = new scaleway.network.Vpc("vpc", {});
* const pn = new scaleway.network.PrivateNetwork("pn", {vpcId: vpc.id});
* const withPn = new scaleway.containers.Namespace("with_pn", {});
* const withPnContainer = new scaleway.containers.Container("with_pn", {
* namespaceId: withPn.id,
* name: "container-with-private-network",
* image: "my-image:latest",
* privateNetworkId: pn.id,
* });
* ```
*
* ### Redeploy the container everytime an update is made
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
* import * as std from "@pulumi/std";
*
* const main = scaleway.registry.getNamespace({
* name: "my-registry",
* });
* const mainGetImage = main.then(main => scaleway.registry.getImage({
* namespaceId: main.id,
* name: "nginx-1-29-2-alpine",
* }));
* const mainNamespace = new scaleway.containers.Namespace("main", {});
* const mainContainer = new scaleway.containers.Container("main", {
* name: "my-container",
* namespaceId: mainNamespace.id,
* image: Promise.all([main, mainGetImage, mainGetImage]).then(([main, mainGetImage, mainGetImage1]) => `${main.endpoint}/${mainGetImage.name}:${mainGetImage1.tags?.[0]}`),
* port: 80,
* registrySha256: std.timestamp({}).result,
* });
* ```
*
* ### Redeploy the container when the image changes
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* // When using mutable images (e.g., `latest` tag), you can use the `scaleway_registry_image_tag` data source along
* // with the `registry_sha256` argument to trigger container redeployments when the image is updated.
* // Ideally, you would create the namespace separately.
* // For demonstration purposes, this example assumes the "nginx:latest" image is already available
* // in the referenced namespace.
* const main = new scaleway.registry.Namespace("main", {name: "some-unique-name"});
* const nginx = scaleway.registry.getImageOutput({
* namespaceId: main.id,
* name: "nginx",
* });
* const nginxLatest = nginx.apply(nginx => scaleway.registry.getImageTagOutput({
* imageId: nginx.id,
* name: "latest",
* }));
* const mainNamespace = new scaleway.containers.Namespace("main", {name: "my-container-namespace"});
* const mainContainer = new scaleway.containers.Container("main", {
* name: "nginx-latest",
* namespaceId: mainNamespace.id,
* image: pulumi.all([nginx, nginxLatest]).apply(([nginx, nginxLatest]) => `${mainScalewayRegistryNamespace.endpoint}/${nginx.name}:${nginxLatest.name}`),
* port: 80,
* registrySha256: nginxLatest.apply(nginxLatest => nginxLatest.digest),
* });
* ```
*
* ### Managing authentication of private containers with IAM
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* // Project to be referenced in the IAM policy
* const _default = scaleway.account.getProject({
* name: "default",
* });
* // IAM resources
* const containerAuth = new scaleway.iam.Application("container_auth", {name: "container-auth"});
* const accessPrivateContainers = new scaleway.iam.Policy("access_private_containers", {
* applicationId: containerAuth.id,
* rules: [{
* projectIds: [_default.then(_default => _default.id)],
* permissionSetNames: ["ContainersPrivateAccess"],
* }],
* });
* const apiKey = new scaleway.iam.ApiKey("api_key", {applicationId: containerAuth.id});
* // Container resources
* const _private = new scaleway.containers.Namespace("private", {name: "private-container-namespace"});
* const privateContainer = new scaleway.containers.Container("private", {
* namespaceId: _private.id,
* image: "rg.fr-par.scw.cloud/my-registry-ns/my-image:latest",
* privacy: "private",
* });
* export const secretKey = apiKey.secretKey;
* export const containerEndpoint = privateContainer.domainName;
* ```
*
* ## Protocols
*
* The following protocols are supported:
*
* - `h2c`: HTTP/2 over TCP.
* - `http1`: Hypertext Transfer Protocol.
*
* > **Important:** Refer to the official [Apache documentation](https://httpd.apache.org/docs/2.4/howto/http2.html) for more information.
*
* ## Privacy
*
* By default, creating a container will make it `public`, meaning that anybody knowing the endpoint can execute it.
*
* A container can be made `private` with the privacy parameter.
*
* Refer to the [technical information](https://www.scaleway.com/en/developers/api/serverless-containers/#protocol-9dd4c8) for more information on container authentication.
*
* ## Memory and vCPUs configuration
*
* The vCPU represents a portion of the underlying, physical CPU that is assigned to a particular virtual machine (VM).
*
* You can determine the computing resources to allocate to each container.
*
* The `memoryLimitBytes` must correspond with the right amount of vCPU. Refer to the table below to determine the right memory/vCPU combination.
*
* | Memory (in MB) | vCPU |
* |----------------|------|
* | 128 | 70m |
* | 256 | 140m |
* | 512 | 280m |
* | 1024 | 560m |
* | 2048 | 1120 |
* | 3072 | 1680 |
* | 4096 | 2240 |
*
* ~>**Important:** Make sure to select the right resources, as you will be billed based on compute usage over time and the number of Containers executions.
* Refer to the [Serverless Containers pricing](https://www.scaleway.com/en/docs/faq/serverless-containers/#prices) for more information.
*
* ## Health check configuration
*
* Custom health checks can be configured on the container.
*
* It's possible to specify the HTTP path that the probe will listen to and the number of failures before considering the container as unhealthy.
* During a deployment, if a newly created container fails to pass the health check, the deployment is aborted.
* As a result, lowering this value can help to reduce the time it takes to detect a failed deployment.
* The period between health checks is also configurable.
*
* Example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.containers.Container("main", {
* name: "my-container",
* namespaceId: mainScalewayContainerNamespace.id,
* image: "nginx:latest",
* livenessProbe: {
* http: {
* path: "/ping",
* },
* failureThreshold: 40,
* interval: "5s",
* timeout: "1m",
* },
* });
* ```
*
* ~>**Important:** Another probe type can be set to TCP with the API, but currently the SDK has not been updated with this parameter.
* This is why the only probe that can be used here is the HTTP probe.
* Refer to the [Serverless Containers pricing](https://www.scaleway.com/en/docs/faq/serverless-containers/#prices) for more information.
*
* ## Scaling option configuration
*
* Scaling option block configuration allows you to choose which parameter will scale up/down containers.
* Options are number of concurrent requests, CPU or memory usage.
*
* Example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.containers.Container("main", {
* name: "my-container-02",
* namespaceId: mainScalewayContainerNamespace.id,
* scalingOptions: [{
* concurrentRequestsThreshold: 15,
* }],
* });
* ```
*
* ~>**Important**: A maximum of one of these parameters may be set. Also, when `cpuUsageThreshold` or `memoryUsageThreshold` are used, `minScale` can't be set to 0.
* Refer to the [API Reference](https://www.scaleway.com/en/developers/api/serverless-containers/#path-containers-create-a-new-container) for more information.
*
* ## Import
*
* Containers can be imported using, `{region}/{id}`, as shown below:
*
* ```sh
* $ pulumi import scaleway:index/container:Container main fr-par/11111111-1111-1111-1111-111111111111
* ```
*
* @deprecated scaleway.index/container.Container has been deprecated in favor of scaleway.containers/container.Container
*/
class Container extends pulumi.CustomResource {
/**
* Get an existing Container resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
pulumi.log.warn("Container is deprecated: scaleway.index/container.Container has been deprecated in favor of scaleway.containers/container.Container");
return new Container(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'scaleway:index/container:Container';
/**
* Returns true if the given object is an instance of Container. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Container.__pulumiType;
}
/** @deprecated scaleway.index/container.Container has been deprecated in favor of scaleway.containers/container.Container */
constructor(name, argsOrState, opts) {
pulumi.log.warn("Container is deprecated: scaleway.index/container.Container has been deprecated in favor of scaleway.containers/container.Container");
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["args"] = state?.args;
resourceInputs["commands"] = state?.commands;
resourceInputs["cpuLimit"] = state?.cpuLimit;
resourceInputs["cronStatus"] = state?.cronStatus;
resourceInputs["deploy"] = state?.deploy;
resourceInputs["description"] = state?.description;
resourceInputs["domainName"] = state?.domainName;
resourceInputs["environmentVariables"] = state?.environmentVariables;
resourceInputs["errorMessage"] = state?.errorMessage;
resourceInputs["healthChecks"] = state?.healthChecks;
resourceInputs["httpOption"] = state?.httpOption;
resourceInputs["httpsConnectionsOnly"] = state?.httpsConnectionsOnly;
resourceInputs["image"] = state?.image;
resourceInputs["livenessProbe"] = state?.livenessProbe;
resourceInputs["localStorageLimit"] = state?.localStorageLimit;
resourceInputs["localStorageLimitBytes"] = state?.localStorageLimitBytes;
resourceInputs["maxScale"] = state?.maxScale;
resourceInputs["memoryLimit"] = state?.memoryLimit;
resourceInputs["memoryLimitBytes"] = state?.memoryLimitBytes;
resourceInputs["minScale"] = state?.minScale;
resourceInputs["name"] = state?.name;
resourceInputs["namespaceId"] = state?.namespaceId;
resourceInputs["port"] = state?.port;
resourceInputs["privacy"] = state?.privacy;
resourceInputs["privateNetworkId"] = state?.privateNetworkId;
resourceInputs["protocol"] = state?.protocol;
resourceInputs["publicEndpoint"] = state?.publicEndpoint;
resourceInputs["region"] = state?.region;
resourceInputs["registryImage"] = state?.registryImage;
resourceInputs["registrySha256"] = state?.registrySha256;
resourceInputs["sandbox"] = state?.sandbox;
resourceInputs["scalingOptions"] = state?.scalingOptions;
resourceInputs["secretEnvironmentVariables"] = state?.secretEnvironmentVariables;
resourceInputs["startupProbe"] = state?.startupProbe;
resourceInputs["status"] = state?.status;
resourceInputs["tags"] = state?.tags;
resourceInputs["timeout"] = state?.timeout;
}
else {
const args = argsOrState;
if (args?.namespaceId === undefined && !opts.urn) {
throw new Error("Missing required property 'namespaceId'");
}
resourceInputs["args"] = args?.args;
resourceInputs["commands"] = args?.commands;
resourceInputs["cpuLimit"] = args?.cpuLimit;
resourceInputs["deploy"] = args?.deploy;
resourceInputs["description"] = args?.description;
resourceInputs["environmentVariables"] = args?.environmentVariables;
resourceInputs["healthChecks"] = args?.healthChecks;
resourceInputs["httpOption"] = args?.httpOption;
resourceInputs["httpsConnectionsOnly"] = args?.httpsConnectionsOnly;
resourceInputs["image"] = args?.image;
resourceInputs["livenessProbe"] = args?.livenessProbe;
resourceInputs["localStorageLimit"] = args?.localStorageLimit;
resourceInputs["localStorageLimitBytes"] = args?.localStorageLimitBytes;
resourceInputs["maxScale"] = args?.maxScale;
resourceInputs["memoryLimit"] = args?.memoryLimit;
resourceInputs["memoryLimitBytes"] = args?.memoryLimitBytes;
resourceInputs["minScale"] = args?.minScale;
resourceInputs["name"] = args?.name;
resourceInputs["namespaceId"] = args?.namespaceId;
resourceInputs["port"] = args?.port;
resourceInputs["privacy"] = args?.privacy;
resourceInputs["privateNetworkId"] = args?.privateNetworkId;
resourceInputs["protocol"] = args?.protocol;
resourceInputs["region"] = args?.region;
resourceInputs["registryImage"] = args?.registryImage;
resourceInputs["registrySha256"] = args?.registrySha256;
resourceInputs["sandbox"] = args?.sandbox;
resourceInputs["scalingOptions"] = args?.scalingOptions;
resourceInputs["secretEnvironmentVariables"] = args?.secretEnvironmentVariables ? pulumi.secret(args.secretEnvironmentVariables) : undefined;
resourceInputs["startupProbe"] = args?.startupProbe;
resourceInputs["tags"] = args?.tags;
resourceInputs["timeout"] = args?.timeout;
resourceInputs["cronStatus"] = undefined /*out*/;
resourceInputs["domainName"] = undefined /*out*/;
resourceInputs["errorMessage"] = undefined /*out*/;
resourceInputs["publicEndpoint"] = undefined /*out*/;
resourceInputs["status"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["secretEnvironmentVariables"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Container.__pulumiType, name, resourceInputs, opts);
}
}
exports.Container = Container;
//# sourceMappingURL=container.js.map