1. Packages
  2. Juju Provider
  3. API Docs
  4. getSecret
juju 1.0.0-beta2 published on Wednesday, Sep 10, 2025 by juju

juju.getSecret

Explore with Pulumi AI

juju logo
juju 1.0.0-beta2 published on Wednesday, Sep 10, 2025 by juju

    A data source representing a Juju Secret.

    Example Usage

    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    Example coming soon!
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.juju.JujuFunctions;
    import com.pulumi.juju.inputs.GetModelArgs;
    import com.pulumi.juju.inputs.GetSecretArgs;
    import com.pulumi.juju.Application;
    import com.pulumi.juju.ApplicationArgs;
    import com.pulumi.juju.inputs.ApplicationCharmArgs;
    import com.pulumi.juju.AccessSecret;
    import com.pulumi.juju.AccessSecretArgs;
    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) {
            final var myModel = JujuFunctions.getModel(GetModelArgs.builder()
                .name("default")
                .build());
    
            final var mySecretDataSource = JujuFunctions.getSecret(GetSecretArgs.builder()
                .name("my_secret")
                .modelUuid(myModel.applyValue(getModelResult -> getModelResult.uuid()))
                .build());
    
            var ubuntu = new Application("ubuntu", ApplicationArgs.builder()
                .modelUuid(myModel.applyValue(getModelResult -> getModelResult.uuid()))
                .charms(ApplicationCharmArgs.builder()
                    .name("ubuntu")
                    .build())
                .config(Map.of("secret", mySecretDataSource.applyValue(getSecretResult -> getSecretResult.secretId())))
                .build());
    
            var mySecretAccess = new AccessSecret("mySecretAccess", AccessSecretArgs.builder()
                .modelUuid(myModel.applyValue(getModelResult -> getModelResult.uuid()))
                .applications(ubuntu.name())
                .secretId(mySecretDataSource.applyValue(getSecretResult -> getSecretResult.secretId()))
                .build());
    
        }
    }
    
    resources:
      ubuntu:
        type: juju:Application
        properties:
          modelUuid: ${myModel.uuid}
          charms:
            - name: ubuntu
          config:
            secret: ${mySecretDataSource.secretId}
      mySecretAccess:
        type: juju:AccessSecret
        properties:
          modelUuid: ${myModel.uuid}
          applications:
            - ${ubuntu.name}
          secretId: ${mySecretDataSource.secretId}
    variables:
      myModel:
        fn::invoke:
          function: juju:getModel
          arguments:
            name: default
      mySecretDataSource:
        fn::invoke:
          function: juju:getSecret
          arguments:
            name: my_secret
            modelUuid: ${myModel.uuid}
    

    Using getSecret

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSecret(args: GetSecretArgs, opts?: InvokeOptions): Promise<GetSecretResult>
    function getSecretOutput(args: GetSecretOutputArgs, opts?: InvokeOptions): Output<GetSecretResult>
    def get_secret(model_uuid: Optional[str] = None,
                   name: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetSecretResult
    def get_secret_output(model_uuid: Optional[pulumi.Input[str]] = None,
                   name: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetSecretResult]
    func LookupSecret(ctx *Context, args *LookupSecretArgs, opts ...InvokeOption) (*LookupSecretResult, error)
    func LookupSecretOutput(ctx *Context, args *LookupSecretOutputArgs, opts ...InvokeOption) LookupSecretResultOutput

    > Note: This function is named LookupSecret in the Go SDK.

    public static class GetSecret 
    {
        public static Task<GetSecretResult> InvokeAsync(GetSecretArgs args, InvokeOptions? opts = null)
        public static Output<GetSecretResult> Invoke(GetSecretInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSecretResult> getSecret(GetSecretArgs args, InvokeOptions options)
    public static Output<GetSecretResult> getSecret(GetSecretArgs args, InvokeOptions options)
    
    fn::invoke:
      function: juju:index/getSecret:getSecret
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ModelUuid string
    The uuid of the model containing the secret.
    Name string
    The name of the secret.
    ModelUuid string
    The uuid of the model containing the secret.
    Name string
    The name of the secret.
    modelUuid String
    The uuid of the model containing the secret.
    name String
    The name of the secret.
    modelUuid string
    The uuid of the model containing the secret.
    name string
    The name of the secret.
    model_uuid str
    The uuid of the model containing the secret.
    name str
    The name of the secret.
    modelUuid String
    The uuid of the model containing the secret.
    name String
    The name of the secret.

    getSecret Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    ModelUuid string
    The uuid of the model containing the secret.
    Name string
    The name of the secret.
    SecretId string
    The ID of the secret.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModelUuid string
    The uuid of the model containing the secret.
    Name string
    The name of the secret.
    SecretId string
    The ID of the secret.
    id String
    The provider-assigned unique ID for this managed resource.
    modelUuid String
    The uuid of the model containing the secret.
    name String
    The name of the secret.
    secretId String
    The ID of the secret.
    id string
    The provider-assigned unique ID for this managed resource.
    modelUuid string
    The uuid of the model containing the secret.
    name string
    The name of the secret.
    secretId string
    The ID of the secret.
    id str
    The provider-assigned unique ID for this managed resource.
    model_uuid str
    The uuid of the model containing the secret.
    name str
    The name of the secret.
    secret_id str
    The ID of the secret.
    id String
    The provider-assigned unique ID for this managed resource.
    modelUuid String
    The uuid of the model containing the secret.
    name String
    The name of the secret.
    secretId String
    The ID of the secret.

    Package Details

    Repository
    juju juju/terraform-provider-juju
    License
    Notes
    This Pulumi package is based on the juju Terraform Provider.
    juju logo
    juju 1.0.0-beta2 published on Wednesday, Sep 10, 2025 by juju