1. Packages
  2. Harness Provider
  3. API Docs
  4. Environment
Harness v0.4.4 published on Tuesday, Nov 12, 2024 by Pulumi

harness.Environment

Explore with Pulumi AI

harness logo
Harness v0.4.4 published on Tuesday, Nov 12, 2024 by Pulumi

    Resource for creating an environment

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as harness from "@pulumi/harness";
    
    const test = new harness.Application("test", {name: "%[1]s"});
    const testKubernetes = new harness.service.Kubernetes("test", {
        appId: test.id,
        name: "%[1]s",
        helmVersion: "V2",
        description: "description",
        variables: [
            {
                name: "test",
                value: "test_value",
                type: "TEXT",
            },
            {
                name: "test2",
                value: "test_value2",
                type: "TEXT",
            },
        ],
    });
    const testEnvironment = new harness.Environment("test", {
        appId: test.id,
        name: "%[1]s",
        type: "%[2]s",
        variableOverrides: [
            {
                serviceName: testKubernetes.name,
                name: "test",
                value: "override",
                type: "TEXT",
            },
            {
                serviceName: testKubernetes.name,
                name: "test2",
                value: "override2",
                type: "TEXT",
            },
        ],
    });
    
    import pulumi
    import pulumi_harness as harness
    
    test = harness.Application("test", name="%[1]s")
    test_kubernetes = harness.service.Kubernetes("test",
        app_id=test.id,
        name="%[1]s",
        helm_version="V2",
        description="description",
        variables=[
            {
                "name": "test",
                "value": "test_value",
                "type": "TEXT",
            },
            {
                "name": "test2",
                "value": "test_value2",
                "type": "TEXT",
            },
        ])
    test_environment = harness.Environment("test",
        app_id=test.id,
        name="%[1]s",
        type="%[2]s",
        variable_overrides=[
            {
                "service_name": test_kubernetes.name,
                "name": "test",
                "value": "override",
                "type": "TEXT",
            },
            {
                "service_name": test_kubernetes.name,
                "name": "test2",
                "value": "override2",
                "type": "TEXT",
            },
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-harness/sdk/go/harness"
    	"github.com/pulumi/pulumi-harness/sdk/go/harness/service"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		test, err := harness.NewApplication(ctx, "test", &harness.ApplicationArgs{
    			Name: pulumi.String("%[1]s"),
    		})
    		if err != nil {
    			return err
    		}
    		testKubernetes, err := service.NewKubernetes(ctx, "test", &service.KubernetesArgs{
    			AppId:       test.ID(),
    			Name:        pulumi.String("%[1]s"),
    			HelmVersion: pulumi.String("V2"),
    			Description: pulumi.String("description"),
    			Variables: service.KubernetesVariableArray{
    				&service.KubernetesVariableArgs{
    					Name:  pulumi.String("test"),
    					Value: pulumi.String("test_value"),
    					Type:  pulumi.String("TEXT"),
    				},
    				&service.KubernetesVariableArgs{
    					Name:  pulumi.String("test2"),
    					Value: pulumi.String("test_value2"),
    					Type:  pulumi.String("TEXT"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = harness.NewEnvironment(ctx, "test", &harness.EnvironmentArgs{
    			AppId: test.ID(),
    			Name:  pulumi.String("%[1]s"),
    			Type:  pulumi.String("%[2]s"),
    			VariableOverrides: harness.EnvironmentVariableOverrideArray{
    				&harness.EnvironmentVariableOverrideArgs{
    					ServiceName: testKubernetes.Name,
    					Name:        pulumi.String("test"),
    					Value:       pulumi.String("override"),
    					Type:        pulumi.String("TEXT"),
    				},
    				&harness.EnvironmentVariableOverrideArgs{
    					ServiceName: testKubernetes.Name,
    					Name:        pulumi.String("test2"),
    					Value:       pulumi.String("override2"),
    					Type:        pulumi.String("TEXT"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Harness = Pulumi.Harness;
    
    return await Deployment.RunAsync(() => 
    {
        var test = new Harness.Application("test", new()
        {
            Name = "%[1]s",
        });
    
        var testKubernetes = new Harness.Service.Kubernetes("test", new()
        {
            AppId = test.Id,
            Name = "%[1]s",
            HelmVersion = "V2",
            Description = "description",
            Variables = new[]
            {
                new Harness.Service.Inputs.KubernetesVariableArgs
                {
                    Name = "test",
                    Value = "test_value",
                    Type = "TEXT",
                },
                new Harness.Service.Inputs.KubernetesVariableArgs
                {
                    Name = "test2",
                    Value = "test_value2",
                    Type = "TEXT",
                },
            },
        });
    
        var testEnvironment = new Harness.Environment("test", new()
        {
            AppId = test.Id,
            Name = "%[1]s",
            Type = "%[2]s",
            VariableOverrides = new[]
            {
                new Harness.Inputs.EnvironmentVariableOverrideArgs
                {
                    ServiceName = testKubernetes.Name,
                    Name = "test",
                    Value = "override",
                    Type = "TEXT",
                },
                new Harness.Inputs.EnvironmentVariableOverrideArgs
                {
                    ServiceName = testKubernetes.Name,
                    Name = "test2",
                    Value = "override2",
                    Type = "TEXT",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.harness.Application;
    import com.pulumi.harness.ApplicationArgs;
    import com.pulumi.harness.service.Kubernetes;
    import com.pulumi.harness.service.KubernetesArgs;
    import com.pulumi.harness.service.inputs.KubernetesVariableArgs;
    import com.pulumi.harness.Environment;
    import com.pulumi.harness.EnvironmentArgs;
    import com.pulumi.harness.inputs.EnvironmentVariableOverrideArgs;
    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) {
            var test = new Application("test", ApplicationArgs.builder()
                .name("%[1]s")
                .build());
    
            var testKubernetes = new Kubernetes("testKubernetes", KubernetesArgs.builder()
                .appId(test.id())
                .name("%[1]s")
                .helmVersion("V2")
                .description("description")
                .variables(            
                    KubernetesVariableArgs.builder()
                        .name("test")
                        .value("test_value")
                        .type("TEXT")
                        .build(),
                    KubernetesVariableArgs.builder()
                        .name("test2")
                        .value("test_value2")
                        .type("TEXT")
                        .build())
                .build());
    
            var testEnvironment = new Environment("testEnvironment", EnvironmentArgs.builder()
                .appId(test.id())
                .name("%[1]s")
                .type("%[2]s")
                .variableOverrides(            
                    EnvironmentVariableOverrideArgs.builder()
                        .serviceName(testKubernetes.name())
                        .name("test")
                        .value("override")
                        .type("TEXT")
                        .build(),
                    EnvironmentVariableOverrideArgs.builder()
                        .serviceName(testKubernetes.name())
                        .name("test2")
                        .value("override2")
                        .type("TEXT")
                        .build())
                .build());
    
        }
    }
    
    resources:
      test:
        type: harness:Application
        properties:
          name: '%[1]s'
      testKubernetes:
        type: harness:service:Kubernetes
        name: test
        properties:
          appId: ${test.id}
          name: '%[1]s'
          helmVersion: V2
          description: description
          variables:
            - name: test
              value: test_value
              type: TEXT
            - name: test2
              value: test_value2
              type: TEXT
      testEnvironment:
        type: harness:Environment
        name: test
        properties:
          appId: ${test.id}
          name: '%[1]s'
          type: '%[2]s'
          variableOverrides:
            - serviceName: ${testKubernetes.name}
              name: test
              value: override
              type: TEXT
            - serviceName: ${testKubernetes.name}
              name: test2
              value: override2
              type: TEXT
    

    Create Environment Resource

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

    Constructor syntax

    new Environment(name: string, args: EnvironmentArgs, opts?: CustomResourceOptions);
    @overload
    def Environment(resource_name: str,
                    args: EnvironmentArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def Environment(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    app_id: Optional[str] = None,
                    type: Optional[str] = None,
                    description: Optional[str] = None,
                    name: Optional[str] = None,
                    variable_overrides: Optional[Sequence[EnvironmentVariableOverrideArgs]] = None)
    func NewEnvironment(ctx *Context, name string, args EnvironmentArgs, opts ...ResourceOption) (*Environment, error)
    public Environment(string name, EnvironmentArgs args, CustomResourceOptions? opts = null)
    public Environment(String name, EnvironmentArgs args)
    public Environment(String name, EnvironmentArgs args, CustomResourceOptions options)
    
    type: harness:Environment
    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 EnvironmentArgs
    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 EnvironmentArgs
    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 EnvironmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EnvironmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EnvironmentArgs
    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 environmentResource = new Harness.Environment("environmentResource", new()
    {
        AppId = "string",
        Type = "string",
        Description = "string",
        Name = "string",
        VariableOverrides = new[]
        {
            new Harness.Inputs.EnvironmentVariableOverrideArgs
            {
                Name = "string",
                Type = "string",
                Value = "string",
                ServiceName = "string",
            },
        },
    });
    
    example, err := harness.NewEnvironment(ctx, "environmentResource", &harness.EnvironmentArgs{
    	AppId:       pulumi.String("string"),
    	Type:        pulumi.String("string"),
    	Description: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    	VariableOverrides: harness.EnvironmentVariableOverrideArray{
    		&harness.EnvironmentVariableOverrideArgs{
    			Name:        pulumi.String("string"),
    			Type:        pulumi.String("string"),
    			Value:       pulumi.String("string"),
    			ServiceName: pulumi.String("string"),
    		},
    	},
    })
    
    var environmentResource = new Environment("environmentResource", EnvironmentArgs.builder()
        .appId("string")
        .type("string")
        .description("string")
        .name("string")
        .variableOverrides(EnvironmentVariableOverrideArgs.builder()
            .name("string")
            .type("string")
            .value("string")
            .serviceName("string")
            .build())
        .build());
    
    environment_resource = harness.Environment("environmentResource",
        app_id="string",
        type="string",
        description="string",
        name="string",
        variable_overrides=[{
            "name": "string",
            "type": "string",
            "value": "string",
            "service_name": "string",
        }])
    
    const environmentResource = new harness.Environment("environmentResource", {
        appId: "string",
        type: "string",
        description: "string",
        name: "string",
        variableOverrides: [{
            name: "string",
            type: "string",
            value: "string",
            serviceName: "string",
        }],
    });
    
    type: harness:Environment
    properties:
        appId: string
        description: string
        name: string
        type: string
        variableOverrides:
            - name: string
              serviceName: string
              type: string
              value: string
    

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

    AppId string
    The id of the application.
    Type string
    The type of the environment. Valid values are PROD and NON_PROD
    Description string
    The description of the environment.
    Name string
    The name of the environment.
    VariableOverrides List<EnvironmentVariableOverride>
    Override for a service variable
    AppId string
    The id of the application.
    Type string
    The type of the environment. Valid values are PROD and NON_PROD
    Description string
    The description of the environment.
    Name string
    The name of the environment.
    VariableOverrides []EnvironmentVariableOverrideArgs
    Override for a service variable
    appId String
    The id of the application.
    type String
    The type of the environment. Valid values are PROD and NON_PROD
    description String
    The description of the environment.
    name String
    The name of the environment.
    variableOverrides List<EnvironmentVariableOverride>
    Override for a service variable
    appId string
    The id of the application.
    type string
    The type of the environment. Valid values are PROD and NON_PROD
    description string
    The description of the environment.
    name string
    The name of the environment.
    variableOverrides EnvironmentVariableOverride[]
    Override for a service variable
    app_id str
    The id of the application.
    type str
    The type of the environment. Valid values are PROD and NON_PROD
    description str
    The description of the environment.
    name str
    The name of the environment.
    variable_overrides Sequence[EnvironmentVariableOverrideArgs]
    Override for a service variable
    appId String
    The id of the application.
    type String
    The type of the environment. Valid values are PROD and NON_PROD
    description String
    The description of the environment.
    name String
    The name of the environment.
    variableOverrides List<Property Map>
    Override for a service variable

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Environment 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 Environment Resource

    Get an existing Environment 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?: EnvironmentState, opts?: CustomResourceOptions): Environment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            app_id: Optional[str] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            type: Optional[str] = None,
            variable_overrides: Optional[Sequence[EnvironmentVariableOverrideArgs]] = None) -> Environment
    func GetEnvironment(ctx *Context, name string, id IDInput, state *EnvironmentState, opts ...ResourceOption) (*Environment, error)
    public static Environment Get(string name, Input<string> id, EnvironmentState? state, CustomResourceOptions? opts = null)
    public static Environment get(String name, Output<String> id, EnvironmentState 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.
    The following state arguments are supported:
    AppId string
    The id of the application.
    Description string
    The description of the environment.
    Name string
    The name of the environment.
    Type string
    The type of the environment. Valid values are PROD and NON_PROD
    VariableOverrides List<EnvironmentVariableOverride>
    Override for a service variable
    AppId string
    The id of the application.
    Description string
    The description of the environment.
    Name string
    The name of the environment.
    Type string
    The type of the environment. Valid values are PROD and NON_PROD
    VariableOverrides []EnvironmentVariableOverrideArgs
    Override for a service variable
    appId String
    The id of the application.
    description String
    The description of the environment.
    name String
    The name of the environment.
    type String
    The type of the environment. Valid values are PROD and NON_PROD
    variableOverrides List<EnvironmentVariableOverride>
    Override for a service variable
    appId string
    The id of the application.
    description string
    The description of the environment.
    name string
    The name of the environment.
    type string
    The type of the environment. Valid values are PROD and NON_PROD
    variableOverrides EnvironmentVariableOverride[]
    Override for a service variable
    app_id str
    The id of the application.
    description str
    The description of the environment.
    name str
    The name of the environment.
    type str
    The type of the environment. Valid values are PROD and NON_PROD
    variable_overrides Sequence[EnvironmentVariableOverrideArgs]
    Override for a service variable
    appId String
    The id of the application.
    description String
    The description of the environment.
    name String
    The name of the environment.
    type String
    The type of the environment. Valid values are PROD and NON_PROD
    variableOverrides List<Property Map>
    Override for a service variable

    Supporting Types

    EnvironmentVariableOverride, EnvironmentVariableOverrideArgs

    Name string
    The name of the variable
    Type string
    The type of the service variable. Valid values are TEXT and ENCRYPTED_TEXT
    Value string
    The value of the service variable
    ServiceName string
    The name of the service
    Name string
    The name of the variable
    Type string
    The type of the service variable. Valid values are TEXT and ENCRYPTED_TEXT
    Value string
    The value of the service variable
    ServiceName string
    The name of the service
    name String
    The name of the variable
    type String
    The type of the service variable. Valid values are TEXT and ENCRYPTED_TEXT
    value String
    The value of the service variable
    serviceName String
    The name of the service
    name string
    The name of the variable
    type string
    The type of the service variable. Valid values are TEXT and ENCRYPTED_TEXT
    value string
    The value of the service variable
    serviceName string
    The name of the service
    name str
    The name of the variable
    type str
    The type of the service variable. Valid values are TEXT and ENCRYPTED_TEXT
    value str
    The value of the service variable
    service_name str
    The name of the service
    name String
    The name of the variable
    type String
    The type of the service variable. Valid values are TEXT and ENCRYPTED_TEXT
    value String
    The value of the service variable
    serviceName String
    The name of the service

    Import

    Import using the Harness application id and environment id.

    $ pulumi import harness:index/environment:Environment dev <application_id>/<environment_id>
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    harness pulumi/pulumi-harness
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the harness Terraform Provider.
    harness logo
    Harness v0.4.4 published on Tuesday, Nov 12, 2024 by Pulumi