1. Packages
  2. Commercetools Provider
  3. API Docs
  4. CustomObject
commercetools 1.19.3 published on Friday, Apr 4, 2025 by labd

commercetools.CustomObject

Explore with Pulumi AI

Custom objects are a way to store arbitrary JSON-formatted data on the commercetools platform. It allows you to persist data that does not fit the standard data model. This frees your application completely from any third-party persistence solution and means that all your data stays on the commercetools platform.

See also the Custom Object API Documentation

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as commercetools from "@pulumi/commercetools";

const my_custom_object = new commercetools.CustomObject("my-custom-object", {
    container: "my-container",
    key: "my-key",
    value: JSON.stringify(10),
});
Copy
import pulumi
import json
import pulumi_commercetools as commercetools

my_custom_object = commercetools.CustomObject("my-custom-object",
    container="my-container",
    key="my-key",
    value=json.dumps(10))
Copy
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-terraform-provider/sdks/go/commercetools/commercetools"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal(10)
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = commercetools.NewCustomObject(ctx, "my-custom-object", &commercetools.CustomObjectArgs{
			Container: pulumi.String("my-container"),
			Key:       pulumi.String("my-key"),
			Value:     pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Commercetools = Pulumi.Commercetools;

return await Deployment.RunAsync(() => 
{
    var my_custom_object = new Commercetools.CustomObject("my-custom-object", new()
    {
        Container = "my-container",
        Key = "my-key",
        Value = JsonSerializer.Serialize(10),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.commercetools.CustomObject;
import com.pulumi.commercetools.CustomObjectArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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 my_custom_object = new CustomObject("my-custom-object", CustomObjectArgs.builder()
            .container("my-container")
            .key("my-key")
            .value(serializeJson(
                10))
            .build());

    }
}
Copy
resources:
  my-custom-object:
    type: commercetools:CustomObject
    properties:
      container: my-container
      key: my-key
      value:
        fn::toJSON: 10
Copy

Create CustomObject Resource

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

Constructor syntax

new CustomObject(name: string, args: CustomObjectArgs, opts?: CustomResourceOptions);
@overload
def CustomObject(resource_name: str,
                 args: CustomObjectArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def CustomObject(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 container: Optional[str] = None,
                 key: Optional[str] = None,
                 value: Optional[str] = None,
                 custom_object_id: Optional[str] = None)
func NewCustomObject(ctx *Context, name string, args CustomObjectArgs, opts ...ResourceOption) (*CustomObject, error)
public CustomObject(string name, CustomObjectArgs args, CustomResourceOptions? opts = null)
public CustomObject(String name, CustomObjectArgs args)
public CustomObject(String name, CustomObjectArgs args, CustomResourceOptions options)
type: commercetools:CustomObject
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. CustomObjectArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. CustomObjectArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. CustomObjectArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. CustomObjectArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. CustomObjectArgs
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 customObjectResource = new Commercetools.CustomObject("customObjectResource", new()
{
    Container = "string",
    Key = "string",
    Value = "string",
    CustomObjectId = "string",
});
Copy
example, err := commercetools.NewCustomObject(ctx, "customObjectResource", &commercetools.CustomObjectArgs{
	Container:      pulumi.String("string"),
	Key:            pulumi.String("string"),
	Value:          pulumi.String("string"),
	CustomObjectId: pulumi.String("string"),
})
Copy
var customObjectResource = new CustomObject("customObjectResource", CustomObjectArgs.builder()
    .container("string")
    .key("string")
    .value("string")
    .customObjectId("string")
    .build());
Copy
custom_object_resource = commercetools.CustomObject("customObjectResource",
    container="string",
    key="string",
    value="string",
    custom_object_id="string")
Copy
const customObjectResource = new commercetools.CustomObject("customObjectResource", {
    container: "string",
    key: "string",
    value: "string",
    customObjectId: "string",
});
Copy
type: commercetools:CustomObject
properties:
    container: string
    customObjectId: string
    key: string
    value: string
Copy

CustomObject 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 CustomObject resource accepts the following input properties:

Container This property is required. string
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
Key This property is required. string
String matching the pattern '[-_~.a-zA-Z0-9]+'
Value This property is required. string
JSON types Number, String, Boolean, Array, Object
CustomObjectId string
The ID of this resource.
Container This property is required. string
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
Key This property is required. string
String matching the pattern '[-_~.a-zA-Z0-9]+'
Value This property is required. string
JSON types Number, String, Boolean, Array, Object
CustomObjectId string
The ID of this resource.
container This property is required. String
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
key This property is required. String
String matching the pattern '[-_~.a-zA-Z0-9]+'
value This property is required. String
JSON types Number, String, Boolean, Array, Object
customObjectId String
The ID of this resource.
container This property is required. string
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
key This property is required. string
String matching the pattern '[-_~.a-zA-Z0-9]+'
value This property is required. string
JSON types Number, String, Boolean, Array, Object
customObjectId string
The ID of this resource.
container This property is required. str
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
key This property is required. str
String matching the pattern '[-_~.a-zA-Z0-9]+'
value This property is required. str
JSON types Number, String, Boolean, Array, Object
custom_object_id str
The ID of this resource.
container This property is required. String
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
key This property is required. String
String matching the pattern '[-_~.a-zA-Z0-9]+'
value This property is required. String
JSON types Number, String, Boolean, Array, Object
customObjectId String
The ID of this resource.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Version double
Id string
The provider-assigned unique ID for this managed resource.
Version float64
id String
The provider-assigned unique ID for this managed resource.
version Double
id string
The provider-assigned unique ID for this managed resource.
version number
id str
The provider-assigned unique ID for this managed resource.
version float
id String
The provider-assigned unique ID for this managed resource.
version Number

Look up Existing CustomObject Resource

Get an existing CustomObject 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?: CustomObjectState, opts?: CustomResourceOptions): CustomObject
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        container: Optional[str] = None,
        custom_object_id: Optional[str] = None,
        key: Optional[str] = None,
        value: Optional[str] = None,
        version: Optional[float] = None) -> CustomObject
func GetCustomObject(ctx *Context, name string, id IDInput, state *CustomObjectState, opts ...ResourceOption) (*CustomObject, error)
public static CustomObject Get(string name, Input<string> id, CustomObjectState? state, CustomResourceOptions? opts = null)
public static CustomObject get(String name, Output<String> id, CustomObjectState state, CustomResourceOptions options)
resources:  _:    type: commercetools:CustomObject    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Container string
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
CustomObjectId string
The ID of this resource.
Key string
String matching the pattern '[-_~.a-zA-Z0-9]+'
Value string
JSON types Number, String, Boolean, Array, Object
Version double
Container string
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
CustomObjectId string
The ID of this resource.
Key string
String matching the pattern '[-_~.a-zA-Z0-9]+'
Value string
JSON types Number, String, Boolean, Array, Object
Version float64
container String
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
customObjectId String
The ID of this resource.
key String
String matching the pattern '[-_~.a-zA-Z0-9]+'
value String
JSON types Number, String, Boolean, Array, Object
version Double
container string
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
customObjectId string
The ID of this resource.
key string
String matching the pattern '[-_~.a-zA-Z0-9]+'
value string
JSON types Number, String, Boolean, Array, Object
version number
container str
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
custom_object_id str
The ID of this resource.
key str
String matching the pattern '[-_~.a-zA-Z0-9]+'
value str
JSON types Number, String, Boolean, Array, Object
version float
container String
A namespace to group custom objects matching the pattern '[-_~.a-zA-Z0-9]+'
customObjectId String
The ID of this resource.
key String
String matching the pattern '[-_~.a-zA-Z0-9]+'
value String
JSON types Number, String, Boolean, Array, Object
version Number

Package Details

Repository
commercetools labd/terraform-provider-commercetools
License
Notes
This Pulumi package is based on the commercetools Terraform Provider.