rancher2.Secret
Explore with Pulumi AI
Provides a Rancher v2 Secret resource. This can be used to create secrets for Rancher v2 environments and retrieve their information.
Depending of the availability, there are 2 types of Rancher v2 secrets:
- Project secret: Available to all namespaces in the
project_id
- Namespaced secret: Available to just
namespace_id
in theproject_id
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as rancher2 from "@pulumi/rancher2";
import * as std from "@pulumi/std";
// Create a new rancher2 Project Secret
const foo = new rancher2.Secret("foo", {
name: "foo",
description: "Terraform secret foo",
projectId: "<project_id>",
data: {
address: std.base64encode({
input: "test.io",
}).then(invoke => invoke.result),
username: std.base64encode({
input: "user2",
}).then(invoke => invoke.result),
password: std.base64encode({
input: "pass",
}).then(invoke => invoke.result),
},
});
import pulumi
import pulumi_rancher2 as rancher2
import pulumi_std as std
# Create a new rancher2 Project Secret
foo = rancher2.Secret("foo",
name="foo",
description="Terraform secret foo",
project_id="<project_id>",
data={
"address": std.base64encode(input="test.io").result,
"username": std.base64encode(input="user2").result,
"password": std.base64encode(input="pass").result,
})
package main
import (
"github.com/pulumi/pulumi-rancher2/sdk/v7/go/rancher2"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeBase64encode, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "test.io",
}, nil)
if err != nil {
return err
}
invokeBase64encode1, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "user2",
}, nil)
if err != nil {
return err
}
invokeBase64encode2, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "pass",
}, nil)
if err != nil {
return err
}
// Create a new rancher2 Project Secret
_, err = rancher2.NewSecret(ctx, "foo", &rancher2.SecretArgs{
Name: pulumi.String("foo"),
Description: pulumi.String("Terraform secret foo"),
ProjectId: pulumi.String("<project_id>"),
Data: pulumi.StringMap{
"address": pulumi.String(invokeBase64encode.Result),
"username": pulumi.String(invokeBase64encode1.Result),
"password": pulumi.String(invokeBase64encode2.Result),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Rancher2 = Pulumi.Rancher2;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
// Create a new rancher2 Project Secret
var foo = new Rancher2.Secret("foo", new()
{
Name = "foo",
Description = "Terraform secret foo",
ProjectId = "<project_id>",
Data =
{
{ "address", Std.Base64encode.Invoke(new()
{
Input = "test.io",
}).Apply(invoke => invoke.Result) },
{ "username", Std.Base64encode.Invoke(new()
{
Input = "user2",
}).Apply(invoke => invoke.Result) },
{ "password", Std.Base64encode.Invoke(new()
{
Input = "pass",
}).Apply(invoke => invoke.Result) },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.rancher2.Secret;
import com.pulumi.rancher2.SecretArgs;
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) {
// Create a new rancher2 Project Secret
var foo = new Secret("foo", SecretArgs.builder()
.name("foo")
.description("Terraform secret foo")
.projectId("<project_id>")
.data(Map.ofEntries(
Map.entry("address", StdFunctions.base64encode(Base64encodeArgs.builder()
.input("test.io")
.build()).result()),
Map.entry("username", StdFunctions.base64encode(Base64encodeArgs.builder()
.input("user2")
.build()).result()),
Map.entry("password", StdFunctions.base64encode(Base64encodeArgs.builder()
.input("pass")
.build()).result())
))
.build());
}
}
resources:
# Create a new rancher2 Project Secret
foo:
type: rancher2:Secret
properties:
name: foo
description: Terraform secret foo
projectId: <project_id>
data:
address:
fn::invoke:
Function: std:base64encode
Arguments:
input: test.io
Return: result
username:
fn::invoke:
Function: std:base64encode
Arguments:
input: user2
Return: result
password:
fn::invoke:
Function: std:base64encode
Arguments:
input: pass
Return: result
import * as pulumi from "@pulumi/pulumi";
import * as rancher2 from "@pulumi/rancher2";
import * as std from "@pulumi/std";
// Create a new rancher2 Namespaced Secret
const foo = new rancher2.Secret("foo", {
name: "foo",
description: "Terraform secret foo",
projectId: "<project_id>",
namespaceId: "<namespace_id>",
data: {
address: std.base64encode({
input: "test.io",
}).then(invoke => invoke.result),
username: std.base64encode({
input: "user2",
}).then(invoke => invoke.result),
password: std.base64encode({
input: "pass",
}).then(invoke => invoke.result),
},
});
import pulumi
import pulumi_rancher2 as rancher2
import pulumi_std as std
# Create a new rancher2 Namespaced Secret
foo = rancher2.Secret("foo",
name="foo",
description="Terraform secret foo",
project_id="<project_id>",
namespace_id="<namespace_id>",
data={
"address": std.base64encode(input="test.io").result,
"username": std.base64encode(input="user2").result,
"password": std.base64encode(input="pass").result,
})
package main
import (
"github.com/pulumi/pulumi-rancher2/sdk/v7/go/rancher2"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeBase64encode, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "test.io",
}, nil)
if err != nil {
return err
}
invokeBase64encode1, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "user2",
}, nil)
if err != nil {
return err
}
invokeBase64encode2, err := std.Base64encode(ctx, &std.Base64encodeArgs{
Input: "pass",
}, nil)
if err != nil {
return err
}
// Create a new rancher2 Namespaced Secret
_, err = rancher2.NewSecret(ctx, "foo", &rancher2.SecretArgs{
Name: pulumi.String("foo"),
Description: pulumi.String("Terraform secret foo"),
ProjectId: pulumi.String("<project_id>"),
NamespaceId: pulumi.String("<namespace_id>"),
Data: pulumi.StringMap{
"address": pulumi.String(invokeBase64encode.Result),
"username": pulumi.String(invokeBase64encode1.Result),
"password": pulumi.String(invokeBase64encode2.Result),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Rancher2 = Pulumi.Rancher2;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
// Create a new rancher2 Namespaced Secret
var foo = new Rancher2.Secret("foo", new()
{
Name = "foo",
Description = "Terraform secret foo",
ProjectId = "<project_id>",
NamespaceId = "<namespace_id>",
Data =
{
{ "address", Std.Base64encode.Invoke(new()
{
Input = "test.io",
}).Apply(invoke => invoke.Result) },
{ "username", Std.Base64encode.Invoke(new()
{
Input = "user2",
}).Apply(invoke => invoke.Result) },
{ "password", Std.Base64encode.Invoke(new()
{
Input = "pass",
}).Apply(invoke => invoke.Result) },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.rancher2.Secret;
import com.pulumi.rancher2.SecretArgs;
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) {
// Create a new rancher2 Namespaced Secret
var foo = new Secret("foo", SecretArgs.builder()
.name("foo")
.description("Terraform secret foo")
.projectId("<project_id>")
.namespaceId("<namespace_id>")
.data(Map.ofEntries(
Map.entry("address", StdFunctions.base64encode(Base64encodeArgs.builder()
.input("test.io")
.build()).result()),
Map.entry("username", StdFunctions.base64encode(Base64encodeArgs.builder()
.input("user2")
.build()).result()),
Map.entry("password", StdFunctions.base64encode(Base64encodeArgs.builder()
.input("pass")
.build()).result())
))
.build());
}
}
resources:
# Create a new rancher2 Namespaced Secret
foo:
type: rancher2:Secret
properties:
name: foo
description: Terraform secret foo
projectId: <project_id>
namespaceId: <namespace_id>
data:
address:
fn::invoke:
Function: std:base64encode
Arguments:
input: test.io
Return: result
username:
fn::invoke:
Function: std:base64encode
Arguments:
input: user2
Return: result
password:
fn::invoke:
Function: std:base64encode
Arguments:
input: pass
Return: result
Create Secret Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Secret(name: string, args: SecretArgs, opts?: CustomResourceOptions);
@overload
def Secret(resource_name: str,
args: SecretArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Secret(resource_name: str,
opts: Optional[ResourceOptions] = None,
data: Optional[Mapping[str, str]] = None,
project_id: Optional[str] = None,
annotations: Optional[Mapping[str, str]] = None,
description: Optional[str] = None,
labels: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
namespace_id: Optional[str] = None)
func NewSecret(ctx *Context, name string, args SecretArgs, opts ...ResourceOption) (*Secret, error)
public Secret(string name, SecretArgs args, CustomResourceOptions? opts = null)
public Secret(String name, SecretArgs args)
public Secret(String name, SecretArgs args, CustomResourceOptions options)
type: rancher2:Secret
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 SecretArgs
- 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 SecretArgs
- 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 SecretArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SecretArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SecretArgs
- 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 secretResource = new Rancher2.Secret("secretResource", new()
{
Data =
{
{ "string", "string" },
},
ProjectId = "string",
Annotations =
{
{ "string", "string" },
},
Description = "string",
Labels =
{
{ "string", "string" },
},
Name = "string",
NamespaceId = "string",
});
example, err := rancher2.NewSecret(ctx, "secretResource", &rancher2.SecretArgs{
Data: pulumi.StringMap{
"string": pulumi.String("string"),
},
ProjectId: pulumi.String("string"),
Annotations: pulumi.StringMap{
"string": pulumi.String("string"),
},
Description: pulumi.String("string"),
Labels: pulumi.StringMap{
"string": pulumi.String("string"),
},
Name: pulumi.String("string"),
NamespaceId: pulumi.String("string"),
})
var secretResource = new Secret("secretResource", SecretArgs.builder()
.data(Map.of("string", "string"))
.projectId("string")
.annotations(Map.of("string", "string"))
.description("string")
.labels(Map.of("string", "string"))
.name("string")
.namespaceId("string")
.build());
secret_resource = rancher2.Secret("secretResource",
data={
"string": "string",
},
project_id="string",
annotations={
"string": "string",
},
description="string",
labels={
"string": "string",
},
name="string",
namespace_id="string")
const secretResource = new rancher2.Secret("secretResource", {
data: {
string: "string",
},
projectId: "string",
annotations: {
string: "string",
},
description: "string",
labels: {
string: "string",
},
name: "string",
namespaceId: "string",
});
type: rancher2:Secret
properties:
annotations:
string: string
data:
string: string
description: string
labels:
string: string
name: string
namespaceId: string
projectId: string
Secret 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 Secret resource accepts the following input properties:
- Data Dictionary<string, string>
- Secret key/value data. Base64 encoding required for values (map)
- Project
Id string - The project id where to assign the secret (string)
- Annotations Dictionary<string, string>
- Annotations for secret object (map)
- Description string
- A secret description (string)
- Labels Dictionary<string, string>
- Labels for secret object (map)
- Name string
- The name of the secret (string)
- Namespace
Id string - The namespace id where to assign the namespaced secret (string)
- Data map[string]string
- Secret key/value data. Base64 encoding required for values (map)
- Project
Id string - The project id where to assign the secret (string)
- Annotations map[string]string
- Annotations for secret object (map)
- Description string
- A secret description (string)
- Labels map[string]string
- Labels for secret object (map)
- Name string
- The name of the secret (string)
- Namespace
Id string - The namespace id where to assign the namespaced secret (string)
- data Map<String,String>
- Secret key/value data. Base64 encoding required for values (map)
- project
Id String - The project id where to assign the secret (string)
- annotations Map<String,String>
- Annotations for secret object (map)
- description String
- A secret description (string)
- labels Map<String,String>
- Labels for secret object (map)
- name String
- The name of the secret (string)
- namespace
Id String - The namespace id where to assign the namespaced secret (string)
- data {[key: string]: string}
- Secret key/value data. Base64 encoding required for values (map)
- project
Id string - The project id where to assign the secret (string)
- annotations {[key: string]: string}
- Annotations for secret object (map)
- description string
- A secret description (string)
- labels {[key: string]: string}
- Labels for secret object (map)
- name string
- The name of the secret (string)
- namespace
Id string - The namespace id where to assign the namespaced secret (string)
- data Mapping[str, str]
- Secret key/value data. Base64 encoding required for values (map)
- project_
id str - The project id where to assign the secret (string)
- annotations Mapping[str, str]
- Annotations for secret object (map)
- description str
- A secret description (string)
- labels Mapping[str, str]
- Labels for secret object (map)
- name str
- The name of the secret (string)
- namespace_
id str - The namespace id where to assign the namespaced secret (string)
- data Map<String>
- Secret key/value data. Base64 encoding required for values (map)
- project
Id String - The project id where to assign the secret (string)
- annotations Map<String>
- Annotations for secret object (map)
- description String
- A secret description (string)
- labels Map<String>
- Labels for secret object (map)
- name String
- The name of the secret (string)
- namespace
Id String - The namespace id where to assign the namespaced secret (string)
Outputs
All input properties are implicitly available as output properties. Additionally, the Secret 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.
Look up Existing Secret Resource
Get an existing Secret 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?: SecretState, opts?: CustomResourceOptions): Secret
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
annotations: Optional[Mapping[str, str]] = None,
data: Optional[Mapping[str, str]] = None,
description: Optional[str] = None,
labels: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
namespace_id: Optional[str] = None,
project_id: Optional[str] = None) -> Secret
func GetSecret(ctx *Context, name string, id IDInput, state *SecretState, opts ...ResourceOption) (*Secret, error)
public static Secret Get(string name, Input<string> id, SecretState? state, CustomResourceOptions? opts = null)
public static Secret get(String name, Output<String> id, SecretState 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.
- Annotations Dictionary<string, string>
- Annotations for secret object (map)
- Data Dictionary<string, string>
- Secret key/value data. Base64 encoding required for values (map)
- Description string
- A secret description (string)
- Labels Dictionary<string, string>
- Labels for secret object (map)
- Name string
- The name of the secret (string)
- Namespace
Id string - The namespace id where to assign the namespaced secret (string)
- Project
Id string - The project id where to assign the secret (string)
- Annotations map[string]string
- Annotations for secret object (map)
- Data map[string]string
- Secret key/value data. Base64 encoding required for values (map)
- Description string
- A secret description (string)
- Labels map[string]string
- Labels for secret object (map)
- Name string
- The name of the secret (string)
- Namespace
Id string - The namespace id where to assign the namespaced secret (string)
- Project
Id string - The project id where to assign the secret (string)
- annotations Map<String,String>
- Annotations for secret object (map)
- data Map<String,String>
- Secret key/value data. Base64 encoding required for values (map)
- description String
- A secret description (string)
- labels Map<String,String>
- Labels for secret object (map)
- name String
- The name of the secret (string)
- namespace
Id String - The namespace id where to assign the namespaced secret (string)
- project
Id String - The project id where to assign the secret (string)
- annotations {[key: string]: string}
- Annotations for secret object (map)
- data {[key: string]: string}
- Secret key/value data. Base64 encoding required for values (map)
- description string
- A secret description (string)
- labels {[key: string]: string}
- Labels for secret object (map)
- name string
- The name of the secret (string)
- namespace
Id string - The namespace id where to assign the namespaced secret (string)
- project
Id string - The project id where to assign the secret (string)
- annotations Mapping[str, str]
- Annotations for secret object (map)
- data Mapping[str, str]
- Secret key/value data. Base64 encoding required for values (map)
- description str
- A secret description (string)
- labels Mapping[str, str]
- Labels for secret object (map)
- name str
- The name of the secret (string)
- namespace_
id str - The namespace id where to assign the namespaced secret (string)
- project_
id str - The project id where to assign the secret (string)
- annotations Map<String>
- Annotations for secret object (map)
- data Map<String>
- Secret key/value data. Base64 encoding required for values (map)
- description String
- A secret description (string)
- labels Map<String>
- Labels for secret object (map)
- name String
- The name of the secret (string)
- namespace
Id String - The namespace id where to assign the namespaced secret (string)
- project
Id String - The project id where to assign the secret (string)
Import
Secrets can be imported using the secret ID in the format <namespace_id>.<project_id>.<secret_id>
$ pulumi import rancher2:index/secret:Secret foo <namespace_id>.<project_id>.<secret_id>
<namespace_id>
is optional, just needed for namespaced secret.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Rancher2 pulumi/pulumi-rancher2
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
rancher2
Terraform Provider.