pulumi/tests/testdata/codegen/secrets/docs/resource/_index.md

37 KiB


title: "Resource" title_tag: "mypkg.Resource" meta_desc: "Documentation for the mypkg.Resource resource with examples, input properties, output properties, lookup functions, and supporting types." layout: api no_edit_this_page: true

Create Resource Resource

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

Constructor syntax

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

@overload
def Resource(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             config: Optional[ConfigArgs] = None,
             config_array: Optional[Sequence[ConfigArgs]] = None,
             config_map: Optional[Mapping[str, ConfigArgs]] = None,
             foo: Optional[str] = None,
             foo_array: Optional[Sequence[str]] = None,
             foo_map: Optional[Mapping[str, str]] = None)
func NewResource(ctx *Context, name string, args ResourceArgs, opts ...ResourceOption) (*Resource, error)
public Resource(string name, ResourceArgs args, CustomResourceOptions? opts = null)
public Resource(String name, ResourceArgs args)
public Resource(String name, ResourceArgs args, CustomResourceOptions options)
type: mypkg:Resource
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 ResourceArgs
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 ResourceArgs
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 ResourceArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ResourceArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args ResourceArgs
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 resourceResource = new Mypkg.Resource("resourceResource", new()
{
    Config = new Mypkg.Inputs.ConfigArgs
    {
        Foo = "string",
    },
    ConfigArray = new[]
    {
        new Mypkg.Inputs.ConfigArgs
        {
            Foo = "string",
        },
    },
    ConfigMap = 
    {
        { "string", new Mypkg.Inputs.ConfigArgs
        {
            Foo = "string",
        } },
    },
    Foo = "string",
    FooArray = new[]
    {
        "string",
    },
    FooMap = 
    {
        { "string", "string" },
    },
});
example, err := mypkg.NewResource(ctx, "resourceResource", &mypkg.ResourceArgs{
	Config: &mypkg.ConfigArgs{
		Foo: pulumi.String("string"),
	},
	ConfigArray: mypkg.ConfigArray{
		&mypkg.ConfigArgs{
			Foo: pulumi.String("string"),
		},
	},
	ConfigMap: mypkg.ConfigMap{
		"string": &mypkg.ConfigArgs{
			Foo: pulumi.String("string"),
		},
	},
	Foo: pulumi.String("string"),
	FooArray: pulumi.StringArray{
		pulumi.String("string"),
	},
	FooMap: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
})
var resourceResource = new Resource("resourceResource", ResourceArgs.builder()
    .config(ConfigArgs.builder()
        .foo("string")
        .build())
    .configArray(ConfigArgs.builder()
        .foo("string")
        .build())
    .configMap(Map.of("string", Map.of("foo", "string")))
    .foo("string")
    .fooArray("string")
    .fooMap(Map.of("string", "string"))
    .build());
resource_resource = mypkg.Resource("resourceResource",
    config={
        "foo": "string",
    },
    config_array=[{
        "foo": "string",
    }],
    config_map={
        "string": {
            "foo": "string",
        },
    },
    foo="string",
    foo_array=["string"],
    foo_map={
        "string": "string",
    })
const resourceResource = new mypkg.Resource("resourceResource", {
    config: {
        foo: "string",
    },
    configArray: [{
        foo: "string",
    }],
    configMap: {
        string: {
            foo: "string",
        },
    },
    foo: "string",
    fooArray: ["string"],
    fooMap: {
        string: "string",
    },
});
type: mypkg:Resource
properties:
    config:
        foo: string
    configArray:
        - foo: string
    configMap:
        string:
            foo: string
    foo: string
    fooArray:
        - string
    fooMap:
        string: string

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

Config Config
ConfigArray List<Config>
ConfigMap Dictionary<string, ConfigArgs>
Foo string
FooArray List<string>
FooMap Dictionary<string, string>
Config ConfigArgs
ConfigArray []ConfigArgs
ConfigMap map[string]ConfigArgs
Foo string
FooArray []string
FooMap map[string]string
config Config
configArray List<Config>
configMap Map<String,ConfigArgs>
foo String
fooArray List<String>
fooMap Map<String,String>
config Config
configArray Config[]
configMap {[key: string]: ConfigArgs}
foo string
fooArray string[]
fooMap {[key: string]: string}
config ConfigArgs
config_array Sequence[ConfigArgs]
config_map Mapping[str, ConfigArgs]
foo str
foo_array Sequence[str]
foo_map Mapping[str, str]
config Property Map
configArray List<Property Map>
configMap Map<Property Map>
foo String
fooArray List<String>
fooMap Map<String>

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Supporting Types

Config, ConfigArgs

Foo string
Foo string
foo String
foo string
foo str
foo String

Package Details

Repository
mypkg
License