1. Packages
  2. Scaleway
  3. API Docs
  4. ContainerDomain
Scaleway v1.20.0 published on Monday, Nov 4, 2024 by pulumiverse

scaleway.ContainerDomain

Explore with Pulumi AI

scaleway logo
Scaleway v1.20.0 published on Monday, Nov 4, 2024 by pulumiverse

    The scaleway.ContainerDomain resource allows you to create and manage domain name bindings for Scaleway Serverless Containers.

    Refer to the Containers domain documentation and the API documentation for more information.

    Example Usage

    The commands below shows how to bind a custom domain name to a container.

    Simple

    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@pulumiverse/scaleway";
    
    const app = new scaleway.Container("app", {});
    const appContainerDomain = new scaleway.ContainerDomain("app", {
        containerId: app.id,
        hostname: "container.domain.tld",
    });
    
    import pulumi
    import pulumiverse_scaleway as scaleway
    
    app = scaleway.Container("app")
    app_container_domain = scaleway.ContainerDomain("app",
        container_id=app.id,
        hostname="container.domain.tld")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		app, err := scaleway.NewContainer(ctx, "app", nil)
    		if err != nil {
    			return err
    		}
    		_, err = scaleway.NewContainerDomain(ctx, "app", &scaleway.ContainerDomainArgs{
    			ContainerId: app.ID(),
    			Hostname:    pulumi.String("container.domain.tld"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scaleway = Pulumiverse.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var app = new Scaleway.Container("app");
    
        var appContainerDomain = new Scaleway.ContainerDomain("app", new()
        {
            ContainerId = app.Id,
            Hostname = "container.domain.tld",
        });
    
    });
    
    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 app = new Container("app");
    
            var appContainerDomain = new ContainerDomain("appContainerDomain", ContainerDomainArgs.builder()
                .containerId(app.id())
                .hostname("container.domain.tld")
                .build());
    
        }
    }
    
    resources:
      app:
        type: scaleway:Container
      appContainerDomain:
        type: scaleway:ContainerDomain
        name: app
        properties:
          containerId: ${app.id}
          hostname: container.domain.tld
    

    Complete example with domain

    import * as pulumi from "@pulumi/pulumi";
    import * as scaleway from "@pulumiverse/scaleway";
    
    const main = new scaleway.ContainerNamespace("main", {
        name: "my-ns-test",
        description: "test container",
    });
    const app = new scaleway.Container("app", {
        name: "app",
        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: "http1",
        deploy: true,
    });
    const appDomainRecord = new scaleway.DomainRecord("app", {
        dnsZone: "domain.tld",
        name: "subdomain",
        type: "CNAME",
        data: pulumi.interpolate`${app.domainName}.`,
        ttl: 3600,
    });
    const appContainerDomain = new scaleway.ContainerDomain("app", {
        containerId: app.id,
        hostname: pulumi.interpolate`${appDomainRecord.name}.${appDomainRecord.dnsZone}`,
    });
    
    import pulumi
    import pulumiverse_scaleway as scaleway
    
    main = scaleway.ContainerNamespace("main",
        name="my-ns-test",
        description="test container")
    app = scaleway.Container("app",
        name="app",
        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="http1",
        deploy=True)
    app_domain_record = scaleway.DomainRecord("app",
        dns_zone="domain.tld",
        name="subdomain",
        type="CNAME",
        data=app.domain_name.apply(lambda domain_name: f"{domain_name}."),
        ttl=3600)
    app_container_domain = scaleway.ContainerDomain("app",
        container_id=app.id,
        hostname=pulumi.Output.all(
            name=app_domain_record.name,
            dns_zone=app_domain_record.dns_zone
    ).apply(lambda resolved_outputs: f"{resolved_outputs['name']}.{resolved_outputs['dns_zone']}")
    )
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-scaleway/sdk/go/scaleway"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		main, err := scaleway.NewContainerNamespace(ctx, "main", &scaleway.ContainerNamespaceArgs{
    			Name:        pulumi.String("my-ns-test"),
    			Description: pulumi.String("test container"),
    		})
    		if err != nil {
    			return err
    		}
    		app, err := scaleway.NewContainer(ctx, "app", &scaleway.ContainerArgs{
    			Name:        pulumi.String("app"),
    			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("http1"),
    			Deploy:         pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		appDomainRecord, err := scaleway.NewDomainRecord(ctx, "app", &scaleway.DomainRecordArgs{
    			DnsZone: pulumi.String("domain.tld"),
    			Name:    pulumi.String("subdomain"),
    			Type:    pulumi.String("CNAME"),
    			Data: app.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, "app", &scaleway.ContainerDomainArgs{
    			ContainerId: app.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
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Scaleway = Pulumiverse.Scaleway;
    
    return await Deployment.RunAsync(() => 
    {
        var main = new Scaleway.ContainerNamespace("main", new()
        {
            Name = "my-ns-test",
            Description = "test container",
        });
    
        var app = new Scaleway.Container("app", new()
        {
            Name = "app",
            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 = "http1",
            Deploy = true,
        });
    
        var appDomainRecord = new Scaleway.DomainRecord("app", new()
        {
            DnsZone = "domain.tld",
            Name = "subdomain",
            Type = "CNAME",
            Data = app.DomainName.Apply(domainName => $"{domainName}."),
            Ttl = 3600,
        });
    
        var appContainerDomain = new Scaleway.ContainerDomain("app", new()
        {
            ContainerId = app.Id,
            Hostname = Output.Tuple(appDomainRecord.Name, appDomainRecord.DnsZone).Apply(values =>
            {
                var name = values.Item1;
                var dnsZone = values.Item2;
                return $"{name}.{dnsZone}";
            }),
        });
    
    });
    
    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()
                .name("my-ns-test")
                .description("test container")
                .build());
    
            var app = new Container("app", ContainerArgs.builder()
                .name("app")
                .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("http1")
                .deploy(true)
                .build());
    
            var appDomainRecord = new DomainRecord("appDomainRecord", DomainRecordArgs.builder()
                .dnsZone("domain.tld")
                .name("subdomain")
                .type("CNAME")
                .data(app.domainName().applyValue(domainName -> String.format("%s.", domainName)))
                .ttl(3600)
                .build());
    
            var appContainerDomain = new ContainerDomain("appContainerDomain", ContainerDomainArgs.builder()
                .containerId(app.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());
    
        }
    }
    
    resources:
      main:
        type: scaleway:ContainerNamespace
        properties:
          name: my-ns-test
          description: test container
      app:
        type: scaleway:Container
        properties:
          name: app
          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: http1
          deploy: true
      appDomainRecord:
        type: scaleway:DomainRecord
        name: app
        properties:
          dnsZone: domain.tld
          name: subdomain
          type: CNAME
          data: ${app.domainName}.
          ttl: 3600
      appContainerDomain:
        type: scaleway:ContainerDomain
        name: app
        properties:
          containerId: ${app.id}
          hostname: ${appDomainRecord.name}.${appDomainRecord.dnsZone}
    

    Create ContainerDomain Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new ContainerDomain(name: string, args: ContainerDomainArgs, opts?: CustomResourceOptions);
    @overload
    def ContainerDomain(resource_name: str,
                        args: ContainerDomainArgs,
                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def ContainerDomain(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        container_id: Optional[str] = None,
                        hostname: Optional[str] = None,
                        region: Optional[str] = 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.
    
    

    Parameters

    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.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var containerDomainResource = new Scaleway.ContainerDomain("containerDomainResource", new()
    {
        ContainerId = "string",
        Hostname = "string",
        Region = "string",
    });
    
    example, err := scaleway.NewContainerDomain(ctx, "containerDomainResource", &scaleway.ContainerDomainArgs{
    	ContainerId: pulumi.String("string"),
    	Hostname:    pulumi.String("string"),
    	Region:      pulumi.String("string"),
    })
    
    var containerDomainResource = new ContainerDomain("containerDomainResource", ContainerDomainArgs.builder()
        .containerId("string")
        .hostname("string")
        .region("string")
        .build());
    
    container_domain_resource = scaleway.ContainerDomain("containerDomainResource",
        container_id="string",
        hostname="string",
        region="string")
    
    const containerDomainResource = new scaleway.ContainerDomain("containerDomainResource", {
        containerId: "string",
        hostname: "string",
        region: "string",
    });
    
    type: scaleway:ContainerDomain
    properties:
        containerId: string
        hostname: string
        region: string
    

    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

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The ContainerDomain resource accepts the following input properties:

    ContainerId string
    The unique identifier of the container.
    Hostname string
    The hostname with a CNAME record.
    Region string
    region) The region in which the container exists.
    ContainerId string
    The unique identifier of the container.
    Hostname string
    The hostname with a CNAME record.
    Region string
    region) The region in which the container exists.
    containerId String
    The unique identifier of the container.
    hostname String
    The hostname with a CNAME record.
    region String
    region) The region in which the container exists.
    containerId string
    The unique identifier 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 unique identifier of the container.
    hostname str
    The hostname with a CNAME record.
    region str
    region) The region in which the container exists.
    containerId String
    The unique identifier 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 unique identifier 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 unique identifier 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 unique identifier 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 unique identifier 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 unique identifier 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 unique identifier 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 {region}/{id}, as shown below:

    bash

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

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    scaleway pulumiverse/pulumi-scaleway
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the scaleway Terraform Provider.
    scaleway logo
    Scaleway v1.20.0 published on Monday, Nov 4, 2024 by pulumiverse