scaleway logo
Scaleway v1.6.0, Dec 17 22

scaleway.ContainerDomain

Creates and manages Scaleway Container domain name bindings. You can check our containers guide for further information.

Example Usage

Simple

using System.Collections.Generic;
using Pulumi;
using Scaleway = Lbrlabs.PulumiPackage.Scaleway;

return await Deployment.RunAsync(() => 
{
    var appContainer = new Scaleway.Container("appContainer");

    var appContainerDomain = new Scaleway.ContainerDomain("appContainerDomain", new()
    {
        ContainerId = appContainer.Id,
        Hostname = "container.domain.tld",
    });

});
package main

import (
	"github.com/lbrlabs/pulumi-scaleway/sdk/go/scaleway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		appContainer, err := scaleway.NewContainer(ctx, "appContainer", nil)
		if err != nil {
			return err
		}
		_, err = scaleway.NewContainerDomain(ctx, "appContainerDomain", &scaleway.ContainerDomainArgs{
			ContainerId: appContainer.ID(),
			Hostname:    pulumi.String("container.domain.tld"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.Container;
import com.pulumi.scaleway.ContainerDomain;
import com.pulumi.scaleway.ContainerDomainArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var appContainer = new Container("appContainer");

        var appContainerDomain = new ContainerDomain("appContainerDomain", ContainerDomainArgs.builder()        
            .containerId(appContainer.id())
            .hostname("container.domain.tld")
            .build());

    }
}
import pulumi
import lbrlabs_pulumi_scaleway as scaleway

app_container = scaleway.Container("appContainer")
app_container_domain = scaleway.ContainerDomain("appContainerDomain",
    container_id=app_container.id,
    hostname="container.domain.tld")
import * as pulumi from "@pulumi/pulumi";
import * as scaleway from "@lbrlabs/pulumi-scaleway";

const appContainer = new scaleway.Container("appContainer", {});
const appContainerDomain = new scaleway.ContainerDomain("appContainerDomain", {
    containerId: appContainer.id,
    hostname: "container.domain.tld",
});
resources:
  appContainer:
    type: scaleway:Container
  appContainerDomain:
    type: scaleway:ContainerDomain
    properties:
      containerId: ${appContainer.id}
      hostname: container.domain.tld

Complete example with domain

using System.Collections.Generic;
using Pulumi;
using Scaleway = Lbrlabs.PulumiPackage.Scaleway;

return await Deployment.RunAsync(() => 
{
    var main = new Scaleway.ContainerNamespace("main", new()
    {
        Description = "test container",
    });

    var appContainer = new Scaleway.Container("appContainer", new()
    {
        NamespaceId = main.Id,
        RegistryImage = main.RegistryEndpoint.Apply(registryEndpoint => $"{registryEndpoint}/nginx:alpine"),
        Port = 80,
        CpuLimit = 140,
        MemoryLimit = 256,
        MinScale = 1,
        MaxScale = 1,
        Timeout = 600,
        MaxConcurrency = 80,
        Privacy = "public",
        Protocol = "h2c",
        Deploy = true,
    });

    var appDomainRecord = new Scaleway.DomainRecord("appDomainRecord", new()
    {
        DnsZone = "domain.tld",
        Type = "CNAME",
        Data = appContainer.DomainName.Apply(domainName => $"{domainName}."),
        Ttl = 3600,
    });

    var appContainerDomain = new Scaleway.ContainerDomain("appContainerDomain", new()
    {
        ContainerId = appContainer.Id,
        Hostname = Output.Tuple(appDomainRecord.Name, appDomainRecord.DnsZone).Apply(values =>
        {
            var name = values.Item1;
            var dnsZone = values.Item2;
            return $"{name}.{dnsZone}";
        }),
    });

});
package main

import (
	"fmt"

	"github.com/lbrlabs/pulumi-scaleway/sdk/go/scaleway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		main, err := scaleway.NewContainerNamespace(ctx, "main", &scaleway.ContainerNamespaceArgs{
			Description: pulumi.String("test container"),
		})
		if err != nil {
			return err
		}
		appContainer, err := scaleway.NewContainer(ctx, "appContainer", &scaleway.ContainerArgs{
			NamespaceId: main.ID(),
			RegistryImage: main.RegistryEndpoint.ApplyT(func(registryEndpoint string) (string, error) {
				return fmt.Sprintf("%v/nginx:alpine", registryEndpoint), nil
			}).(pulumi.StringOutput),
			Port:           pulumi.Int(80),
			CpuLimit:       pulumi.Int(140),
			MemoryLimit:    pulumi.Int(256),
			MinScale:       pulumi.Int(1),
			MaxScale:       pulumi.Int(1),
			Timeout:        pulumi.Int(600),
			MaxConcurrency: pulumi.Int(80),
			Privacy:        pulumi.String("public"),
			Protocol:       pulumi.String("h2c"),
			Deploy:         pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		appDomainRecord, err := scaleway.NewDomainRecord(ctx, "appDomainRecord", &scaleway.DomainRecordArgs{
			DnsZone: pulumi.String("domain.tld"),
			Type:    pulumi.String("CNAME"),
			Data: appContainer.DomainName.ApplyT(func(domainName string) (string, error) {
				return fmt.Sprintf("%v.", domainName), nil
			}).(pulumi.StringOutput),
			Ttl: pulumi.Int(3600),
		})
		if err != nil {
			return err
		}
		_, err = scaleway.NewContainerDomain(ctx, "appContainerDomain", &scaleway.ContainerDomainArgs{
			ContainerId: appContainer.ID(),
			Hostname: pulumi.All(appDomainRecord.Name, appDomainRecord.DnsZone).ApplyT(func(_args []interface{}) (string, error) {
				name := _args[0].(string)
				dnsZone := _args[1].(string)
				return fmt.Sprintf("%v.%v", name, dnsZone), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.ContainerNamespace;
import com.pulumi.scaleway.ContainerNamespaceArgs;
import com.pulumi.scaleway.Container;
import com.pulumi.scaleway.ContainerArgs;
import com.pulumi.scaleway.DomainRecord;
import com.pulumi.scaleway.DomainRecordArgs;
import com.pulumi.scaleway.ContainerDomain;
import com.pulumi.scaleway.ContainerDomainArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var main = new ContainerNamespace("main", ContainerNamespaceArgs.builder()        
            .description("test container")
            .build());

        var appContainer = new Container("appContainer", ContainerArgs.builder()        
            .namespaceId(main.id())
            .registryImage(main.registryEndpoint().applyValue(registryEndpoint -> String.format("%s/nginx:alpine", registryEndpoint)))
            .port(80)
            .cpuLimit(140)
            .memoryLimit(256)
            .minScale(1)
            .maxScale(1)
            .timeout(600)
            .maxConcurrency(80)
            .privacy("public")
            .protocol("h2c")
            .deploy(true)
            .build());

        var appDomainRecord = new DomainRecord("appDomainRecord", DomainRecordArgs.builder()        
            .dnsZone("domain.tld")
            .type("CNAME")
            .data(appContainer.domainName().applyValue(domainName -> String.format("%s.", domainName)))
            .ttl(3600)
            .build());

        var appContainerDomain = new ContainerDomain("appContainerDomain", ContainerDomainArgs.builder()        
            .containerId(appContainer.id())
            .hostname(Output.tuple(appDomainRecord.name(), appDomainRecord.dnsZone()).applyValue(values -> {
                var name = values.t1;
                var dnsZone = values.t2;
                return String.format("%s.%s", name,dnsZone);
            }))
            .build());

    }
}
import pulumi
import lbrlabs_pulumi_scaleway as scaleway

main = scaleway.ContainerNamespace("main", description="test container")
app_container = scaleway.Container("appContainer",
    namespace_id=main.id,
    registry_image=main.registry_endpoint.apply(lambda registry_endpoint: f"{registry_endpoint}/nginx:alpine"),
    port=80,
    cpu_limit=140,
    memory_limit=256,
    min_scale=1,
    max_scale=1,
    timeout=600,
    max_concurrency=80,
    privacy="public",
    protocol="h2c",
    deploy=True)
app_domain_record = scaleway.DomainRecord("appDomainRecord",
    dns_zone="domain.tld",
    type="CNAME",
    data=app_container.domain_name.apply(lambda domain_name: f"{domain_name}."),
    ttl=3600)
app_container_domain = scaleway.ContainerDomain("appContainerDomain",
    container_id=app_container.id,
    hostname=pulumi.Output.all(app_domain_record.name, app_domain_record.dns_zone).apply(lambda name, dns_zone: f"{name}.{dns_zone}"))
import * as pulumi from "@pulumi/pulumi";
import * as scaleway from "@lbrlabs/pulumi-scaleway";

const main = new scaleway.ContainerNamespace("main", {description: "test container"});
const appContainer = new scaleway.Container("appContainer", {
    namespaceId: main.id,
    registryImage: pulumi.interpolate`${main.registryEndpoint}/nginx:alpine`,
    port: 80,
    cpuLimit: 140,
    memoryLimit: 256,
    minScale: 1,
    maxScale: 1,
    timeout: 600,
    maxConcurrency: 80,
    privacy: "public",
    protocol: "h2c",
    deploy: true,
});
const appDomainRecord = new scaleway.DomainRecord("appDomainRecord", {
    dnsZone: "domain.tld",
    type: "CNAME",
    data: pulumi.interpolate`${appContainer.domainName}.`,
    ttl: 3600,
});
const appContainerDomain = new scaleway.ContainerDomain("appContainerDomain", {
    containerId: appContainer.id,
    hostname: pulumi.interpolate`${appDomainRecord.name}.${appDomainRecord.dnsZone}`,
});
resources:
  main:
    type: scaleway:ContainerNamespace
    properties:
      description: test container
  appContainer:
    type: scaleway:Container
    properties:
      namespaceId: ${main.id}
      registryImage: ${main.registryEndpoint}/nginx:alpine
      port: 80
      cpuLimit: 140
      memoryLimit: 256
      minScale: 1
      maxScale: 1
      timeout: 600
      maxConcurrency: 80
      privacy: public
      protocol: h2c
      deploy: true
  appDomainRecord:
    type: scaleway:DomainRecord
    properties:
      dnsZone: domain.tld
      type: CNAME
      data: ${appContainer.domainName}.
      # Trailing dot is important in CNAME
      ttl: 3600
  appContainerDomain:
    type: scaleway:ContainerDomain
    properties:
      containerId: ${appContainer.id}
      hostname: ${appDomainRecord.name}.${appDomainRecord.dnsZone}

Create ContainerDomain Resource

new ContainerDomain(name: string, args: ContainerDomainArgs, opts?: CustomResourceOptions);
@overload
def ContainerDomain(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    container_id: Optional[str] = None,
                    hostname: Optional[str] = None,
                    region: Optional[str] = None)
@overload
def ContainerDomain(resource_name: str,
                    args: ContainerDomainArgs,
                    opts: Optional[ResourceOptions] = None)
func NewContainerDomain(ctx *Context, name string, args ContainerDomainArgs, opts ...ResourceOption) (*ContainerDomain, error)
public ContainerDomain(string name, ContainerDomainArgs args, CustomResourceOptions? opts = null)
public ContainerDomain(String name, ContainerDomainArgs args)
public ContainerDomain(String name, ContainerDomainArgs args, CustomResourceOptions options)
type: scaleway:ContainerDomain
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args ContainerDomainArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args ContainerDomainArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ContainerDomainArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ContainerDomainArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args ContainerDomainArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

ContainerDomain Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The ContainerDomain resource accepts the following input properties:

ContainerId string

The ID of the container.

Hostname string

The hostname with a CNAME record.

Region string

region) The region in which the container exists

ContainerId string

The ID of the container.

Hostname string

The hostname with a CNAME record.

Region string

region) The region in which the container exists

containerId String

The ID of the container.

hostname String

The hostname with a CNAME record.

region String

region) The region in which the container exists

containerId string

The ID of the container.

hostname string

The hostname with a CNAME record.

region string

region) The region in which the container exists

container_id str

The ID of the container.

hostname str

The hostname with a CNAME record.

region str

region) The region in which the container exists

containerId String

The ID of the container.

hostname String

The hostname with a CNAME record.

region String

region) The region in which the container exists

Outputs

All input properties are implicitly available as output properties. Additionally, the ContainerDomain resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Url string

The URL used to query the container

Id string

The provider-assigned unique ID for this managed resource.

Url string

The URL used to query the container

id String

The provider-assigned unique ID for this managed resource.

url String

The URL used to query the container

id string

The provider-assigned unique ID for this managed resource.

url string

The URL used to query the container

id str

The provider-assigned unique ID for this managed resource.

url str

The URL used to query the container

id String

The provider-assigned unique ID for this managed resource.

url String

The URL used to query the container

Look up Existing ContainerDomain Resource

Get an existing ContainerDomain resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ContainerDomainState, opts?: CustomResourceOptions): ContainerDomain
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        container_id: Optional[str] = None,
        hostname: Optional[str] = None,
        region: Optional[str] = None,
        url: Optional[str] = None) -> ContainerDomain
func GetContainerDomain(ctx *Context, name string, id IDInput, state *ContainerDomainState, opts ...ResourceOption) (*ContainerDomain, error)
public static ContainerDomain Get(string name, Input<string> id, ContainerDomainState? state, CustomResourceOptions? opts = null)
public static ContainerDomain get(String name, Output<String> id, ContainerDomainState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ContainerId string

The ID of the container.

Hostname string

The hostname with a CNAME record.

Region string

region) The region in which the container exists

Url string

The URL used to query the container

ContainerId string

The ID of the container.

Hostname string

The hostname with a CNAME record.

Region string

region) The region in which the container exists

Url string

The URL used to query the container

containerId String

The ID of the container.

hostname String

The hostname with a CNAME record.

region String

region) The region in which the container exists

url String

The URL used to query the container

containerId string

The ID of the container.

hostname string

The hostname with a CNAME record.

region string

region) The region in which the container exists

url string

The URL used to query the container

container_id str

The ID of the container.

hostname str

The hostname with a CNAME record.

region str

region) The region in which the container exists

url str

The URL used to query the container

containerId String

The ID of the container.

hostname String

The hostname with a CNAME record.

region String

region) The region in which the container exists

url String

The URL used to query the container

Import

Container domain binding can be imported using the {region}/{id}, e.g. bash

 $ pulumi import scaleway:index/containerDomain:ContainerDomain main fr-par/11111111-1111-1111-1111-111111111111

Package Details

Repository
scaleway lbrlabs/pulumi-scaleway
License
Apache-2.0
Notes

This Pulumi package is based on the scaleway Terraform Provider.