コード例 #1
0
    async def test_unsecret(self):
        x = Output.secret("foo")
        x_is_secret = await x.is_secret()
        self.assertTrue(x_is_secret)

        y = Output.unsecret(x)
        y_val = await y.future()
        y_is_secret = await y.is_secret()
        self.assertEqual(y_val, "foo")
        self.assertFalse(y_is_secret)
コード例 #2
0
 async def test_secret(self):
     x = Output.secret("foo")
     is_secret = await x.is_secret()
     self.assertTrue(is_secret)
コード例 #3
0
ファイル: __main__.py プロジェクト: zebulonj/pulumi
# Copyright 2016-2020, Pulumi Corporation.  All rights reserved.

from pulumi import export, Input, Output, ResourceOptions
from pulumi.dynamic import Resource, ResourceProvider, CreateResult

class Provider(ResourceProvider):
    def create(self, props):
        return CreateResult("1", {"prefix": props["prefix"]})

class R(Resource):
    prefix: Output[str]
    def __init__(self, name, prefix: Input[str], opts: ResourceOptions = None):
        super().__init__(Provider(), name, {"prefix": prefix}, opts)

without_secret = R("without_secret", prefix=Output.from_input("it's a secret to everybody"))
with_secret = R("with_secret", prefix=Output.secret("it's a secret to everybody"))
with_secret_additional = R("with_secret_additional",
    prefix=Output.from_input("it's a secret to everybody"),
    opts=ResourceOptions(additional_secret_outputs=["prefix"]))

export("withoutSecret", without_secret)
export("withSecret", with_secret)
export("withSecretAdditional", with_secret_additional)
コード例 #4
0
 async def test_unwrap_dict_secret(self):
     x = Output.from_input({"hello": Output.secret("world")})
     x_val = await x.future()
     self.assertEqual(x_val, {"hello": "world"})
コード例 #5
0
    node_resource_group='node-resource-group',
    service_principal_profile={
        'client_id': ad_app.application_id,
        'secret': ad_sp_password.value,
    })

# Obtaining the kubeconfig from an Azure K8s cluster requires using the "list_managed_clsuter_user_credentials"
# function.
# That function requires passing values that are not be known until the resources are created.
# Thus, the use of "apply()" to wait for those values before calling the function.
creds = Output.all(resource_group.name, k8s_cluster.name).apply(
    lambda args:
    containerservice.list_managed_cluster_user_credentials(
        resource_group_name=args[0],
        resource_name=args[1]))

# The "list_managed_cluster_user_credentials" function returns an array of base64 encoded kubeconfigs.
# So decode the kubeconfig for our cluster.
## Exercise 2/2a
## How to programmatically create a secret: Use `pulumi.Output.secret()`
kubeconfig = Output.secret(creds.kubeconfigs[0].value.apply(
    lambda enc: base64.b64decode(enc).decode()))

# The K8s provider which supplies the helm chart resource needs to know how to talk to the K8s cluster.
# So, instantiate a K8s provider using the retrieved kubeconfig.
k8s_provider = k8s.Provider('k8s-provider', kubeconfig=kubeconfig)

## Exercise 4 
## For parity with Exercise 2, we'll create a local copy of the password so main can export it.
## The nice thing is that it's secrecy attribute is maintained.
password = config.password
コード例 #6
0
ファイル: __main__.py プロジェクト: t0yv0/pulumi
# Copyright 2016-2021, Pulumi Corporation.  All rights reserved.

from pulumi import Output

from component import Component, ComponentArgs, FooArgs, BarArgs

Component("component", ComponentArgs(
    foo=FooArgs(something="hello"),
    bar=BarArgs(tags={
        "a": "world",
        "b": Output.secret("shh"),
    })
))