Confluent Cloud

v1.6.0 published on Wednesday, Nov 23, 2022 by Pulumi

getEnvironment

General Availability

confluentcloud.Environment describes an Environment data source.

Example Usage

using System.Collections.Generic;
using Pulumi;
using ConfluentCloud = Pulumi.ConfluentCloud;

return await Deployment.RunAsync(() => 
{
    var exampleUsingIdEnvironment = ConfluentCloud.GetEnvironment.Invoke(new()
    {
        Id = "env-abc123",
    });

    var exampleUsingNameEnvironment = ConfluentCloud.GetEnvironment.Invoke(new()
    {
        DisplayName = "stag",
    });

    var exampleUsingNameServiceAccount = ConfluentCloud.GetServiceAccount.Invoke(new()
    {
        DisplayName = "test_sa",
    });

    var test_role_binding = new ConfluentCloud.RoleBinding("test-role-binding", new()
    {
        Principal = $"User:{exampleUsingNameServiceAccount.Apply(getServiceAccountResult => getServiceAccountResult.Id)}",
        RoleName = "EnvironmentAdmin",
        CrnPattern = exampleUsingNameEnvironment.Apply(getEnvironmentResult => getEnvironmentResult.ResourceName),
    });

    return new Dictionary<string, object?>
    {
        ["exampleUsingId"] = exampleUsingIdEnvironment.Apply(getEnvironmentResult => getEnvironmentResult),
    };
});
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-confluentcloud/sdk/go/confluentcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleUsingIdEnvironment, err := confluentcloud.LookupEnvironment(ctx, &GetEnvironmentArgs{
			Id: pulumi.StringRef("env-abc123"),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("exampleUsingId", exampleUsingIdEnvironment)
		exampleUsingNameEnvironment, err := confluentcloud.LookupEnvironment(ctx, &GetEnvironmentArgs{
			DisplayName: pulumi.StringRef("stag"),
		}, nil)
		if err != nil {
			return err
		}
		exampleUsingNameServiceAccount, err := confluentcloud.LookupServiceAccount(ctx, &GetServiceAccountArgs{
			DisplayName: pulumi.StringRef("test_sa"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = confluentcloud.NewRoleBinding(ctx, "test-role-binding", &confluentcloud.RoleBindingArgs{
			Principal:  pulumi.String(fmt.Sprintf("User:%v", exampleUsingNameServiceAccount.Id)),
			RoleName:   pulumi.String("EnvironmentAdmin"),
			CrnPattern: pulumi.String(exampleUsingNameEnvironment.ResourceName),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.confluentcloud.ConfluentcloudFunctions;
import com.pulumi.confluentcloud.inputs.GetEnvironmentArgs;
import com.pulumi.confluentcloud.inputs.GetServiceAccountArgs;
import com.pulumi.confluentcloud.RoleBinding;
import com.pulumi.confluentcloud.RoleBindingArgs;
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 exampleUsingIdEnvironment = ConfluentcloudFunctions.getEnvironment(GetEnvironmentArgs.builder()
            .id("env-abc123")
            .build());

        ctx.export("exampleUsingId", exampleUsingIdEnvironment.applyValue(getEnvironmentResult -> getEnvironmentResult));
        final var exampleUsingNameEnvironment = ConfluentcloudFunctions.getEnvironment(GetEnvironmentArgs.builder()
            .displayName("stag")
            .build());

        final var exampleUsingNameServiceAccount = ConfluentcloudFunctions.getServiceAccount(GetServiceAccountArgs.builder()
            .displayName("test_sa")
            .build());

        var test_role_binding = new RoleBinding("test-role-binding", RoleBindingArgs.builder()        
            .principal(String.format("User:%s", exampleUsingNameServiceAccount.applyValue(getServiceAccountResult -> getServiceAccountResult.id())))
            .roleName("EnvironmentAdmin")
            .crnPattern(exampleUsingNameEnvironment.applyValue(getEnvironmentResult -> getEnvironmentResult.resourceName()))
            .build());

    }
}
import pulumi
import pulumi_confluentcloud as confluentcloud

example_using_id_environment = confluentcloud.get_environment(id="env-abc123")
pulumi.export("exampleUsingId", example_using_id_environment)
example_using_name_environment = confluentcloud.get_environment(display_name="stag")
example_using_name_service_account = confluentcloud.get_service_account(display_name="test_sa")
test_role_binding = confluentcloud.RoleBinding("test-role-binding",
    principal=f"User:{example_using_name_service_account.id}",
    role_name="EnvironmentAdmin",
    crn_pattern=example_using_name_environment.resource_name)
import * as pulumi from "@pulumi/pulumi";
import * as confluentcloud from "@pulumi/confluentcloud";

const exampleUsingIdEnvironment = confluentcloud.getEnvironment({
    id: "env-abc123",
});
export const exampleUsingId = exampleUsingIdEnvironment;
const exampleUsingNameEnvironment = confluentcloud.getEnvironment({
    displayName: "stag",
});
const exampleUsingNameServiceAccount = confluentcloud.getServiceAccount({
    displayName: "test_sa",
});
const test_role_binding = new confluentcloud.RoleBinding("test-role-binding", {
    principal: exampleUsingNameServiceAccount.then(exampleUsingNameServiceAccount => `User:${exampleUsingNameServiceAccount.id}`),
    roleName: "EnvironmentAdmin",
    crnPattern: exampleUsingNameEnvironment.then(exampleUsingNameEnvironment => exampleUsingNameEnvironment.resourceName),
});
resources:
  test-role-binding:
    type: confluentcloud:RoleBinding
    properties:
      principal: User:${exampleUsingNameServiceAccount.id}
      roleName: EnvironmentAdmin
      crnPattern: ${exampleUsingNameEnvironment.resourceName}
variables:
  exampleUsingIdEnvironment:
    Fn::Invoke:
      Function: confluentcloud:getEnvironment
      Arguments:
        id: env-abc123
  exampleUsingNameEnvironment:
    Fn::Invoke:
      Function: confluentcloud:getEnvironment
      Arguments:
        displayName: stag
  exampleUsingNameServiceAccount:
    Fn::Invoke:
      Function: confluentcloud:getServiceAccount
      Arguments:
        displayName: test_sa
outputs:
  exampleUsingId: ${exampleUsingIdEnvironment}

Using getEnvironment

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 getEnvironment(args: GetEnvironmentArgs, opts?: InvokeOptions): Promise<GetEnvironmentResult>
function getEnvironmentOutput(args: GetEnvironmentOutputArgs, opts?: InvokeOptions): Output<GetEnvironmentResult>
def get_environment(display_name: Optional[str] = None,
                    id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetEnvironmentResult
def get_environment_output(display_name: Optional[pulumi.Input[str]] = None,
                    id: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetEnvironmentResult]
func LookupEnvironment(ctx *Context, args *LookupEnvironmentArgs, opts ...InvokeOption) (*LookupEnvironmentResult, error)
func LookupEnvironmentOutput(ctx *Context, args *LookupEnvironmentOutputArgs, opts ...InvokeOption) LookupEnvironmentResultOutput

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

public static class GetEnvironment 
{
    public static Task<GetEnvironmentResult> InvokeAsync(GetEnvironmentArgs args, InvokeOptions? opts = null)
    public static Output<GetEnvironmentResult> Invoke(GetEnvironmentInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetEnvironmentResult> getEnvironment(GetEnvironmentArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: confluentcloud:index/getEnvironment:getEnvironment
  arguments:
    # arguments dictionary

The following arguments are supported:

DisplayName string

A human-readable name for the Environment.

Id string

The ID of the Environment, for example, env-abc123.

DisplayName string

A human-readable name for the Environment.

Id string

The ID of the Environment, for example, env-abc123.

displayName String

A human-readable name for the Environment.

id String

The ID of the Environment, for example, env-abc123.

displayName string

A human-readable name for the Environment.

id string

The ID of the Environment, for example, env-abc123.

display_name str

A human-readable name for the Environment.

id str

The ID of the Environment, for example, env-abc123.

displayName String

A human-readable name for the Environment.

id String

The ID of the Environment, for example, env-abc123.

getEnvironment Result

The following output properties are available:

DisplayName string

(Required String) A human-readable name for the Environment.

Id string

(Required String) The ID of the Environment, for example, env-abc123.

ResourceName string

(Required String) The Confluent Resource Name of the Environment, for example, crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-abc123.

DisplayName string

(Required String) A human-readable name for the Environment.

Id string

(Required String) The ID of the Environment, for example, env-abc123.

ResourceName string

(Required String) The Confluent Resource Name of the Environment, for example, crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-abc123.

displayName String

(Required String) A human-readable name for the Environment.

id String

(Required String) The ID of the Environment, for example, env-abc123.

resourceName String

(Required String) The Confluent Resource Name of the Environment, for example, crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-abc123.

displayName string

(Required String) A human-readable name for the Environment.

id string

(Required String) The ID of the Environment, for example, env-abc123.

resourceName string

(Required String) The Confluent Resource Name of the Environment, for example, crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-abc123.

display_name str

(Required String) A human-readable name for the Environment.

id str

(Required String) The ID of the Environment, for example, env-abc123.

resource_name str

(Required String) The Confluent Resource Name of the Environment, for example, crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-abc123.

displayName String

(Required String) A human-readable name for the Environment.

id String

(Required String) The ID of the Environment, for example, env-abc123.

resourceName String

(Required String) The Confluent Resource Name of the Environment, for example, crn://confluent.cloud/organization=1111aaaa-11aa-11aa-11aa-111111aaaaaa/environment=env-abc123.

Package Details

Repository
https://github.com/pulumi/pulumi-confluentcloud
License
Apache-2.0
Notes

This Pulumi package is based on the confluent Terraform Provider.