1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. apig
  5. Environment
Alibaba Cloud v3.86.1 published on Saturday, Sep 27, 2025 by Pulumi

alicloud.apig.Environment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.86.1 published on Saturday, Sep 27, 2025 by Pulumi

    Provides a APIG Environment resource.

    For information about APIG Environment and how to use it, see What is Environment.

    NOTE: Available since v1.240.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    import * as std from "@pulumi/std";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.resourcemanager.getResourceGroups({});
    const defaultGetNetworks = alicloud.vpc.getNetworks({
        nameRegex: "^default-NODELETING$",
    });
    const defaultGetSwitches = defaultGetNetworks.then(defaultGetNetworks => alicloud.vpc.getSwitches({
        vpcId: defaultGetNetworks.ids?.[0],
    }));
    const defaultgateway = new alicloud.apig.Gateway("defaultgateway", {
        networkAccessConfig: {
            type: "Intranet",
        },
        vswitch: {
            vswitchId: defaultGetSwitches.then(defaultGetSwitches => defaultGetSwitches.ids?.[0]),
        },
        zoneConfig: {
            selectOption: "Auto",
        },
        vpc: {
            vpcId: defaultGetNetworks.then(defaultGetNetworks => defaultGetNetworks.ids?.[0]),
        },
        paymentType: "PayAsYouGo",
        gatewayName: std.format({
            input: "%s2",
            args: [name],
        }).then(invoke => invoke.result),
        spec: "apigw.small.x1",
        logConfig: {
            sls: {},
        },
    });
    const defaultEnvironment = new alicloud.apig.Environment("default", {
        description: name,
        environmentName: name,
        gatewayId: defaultgateway.id,
        resourceGroupId: _default.then(_default => _default.ids?.[1]),
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    import pulumi_std as std
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.resourcemanager.get_resource_groups()
    default_get_networks = alicloud.vpc.get_networks(name_regex="^default-NODELETING$")
    default_get_switches = alicloud.vpc.get_switches(vpc_id=default_get_networks.ids[0])
    defaultgateway = alicloud.apig.Gateway("defaultgateway",
        network_access_config={
            "type": "Intranet",
        },
        vswitch={
            "vswitch_id": default_get_switches.ids[0],
        },
        zone_config={
            "select_option": "Auto",
        },
        vpc={
            "vpc_id": default_get_networks.ids[0],
        },
        payment_type="PayAsYouGo",
        gateway_name=std.format(input="%s2",
            args=[name]).result,
        spec="apigw.small.x1",
        log_config={
            "sls": {},
        })
    default_environment = alicloud.apig.Environment("default",
        description=name,
        environment_name=name,
        gateway_id=defaultgateway.id,
        resource_group_id=default.ids[1])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/apig"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := resourcemanager.GetResourceGroups(ctx, &resourcemanager.GetResourceGroupsArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
    			NameRegex: pulumi.StringRef("^default-NODELETING$"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetSwitches, err := vpc.GetSwitches(ctx, &vpc.GetSwitchesArgs{
    			VpcId: pulumi.StringRef(defaultGetNetworks.Ids[0]),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		invokeFormat, err := std.Format(ctx, &std.FormatArgs{
    			Input: "%s2",
    			Args: []string{
    				name,
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultgateway, err := apig.NewGateway(ctx, "defaultgateway", &apig.GatewayArgs{
    			NetworkAccessConfig: &apig.GatewayNetworkAccessConfigArgs{
    				Type: pulumi.String("Intranet"),
    			},
    			Vswitch: &apig.GatewayVswitchArgs{
    				VswitchId: pulumi.String(defaultGetSwitches.Ids[0]),
    			},
    			ZoneConfig: &apig.GatewayZoneConfigArgs{
    				SelectOption: pulumi.String("Auto"),
    			},
    			Vpc: &apig.GatewayVpcArgs{
    				VpcId: pulumi.String(defaultGetNetworks.Ids[0]),
    			},
    			PaymentType: pulumi.String("PayAsYouGo"),
    			GatewayName: pulumi.String(invokeFormat.Result),
    			Spec:        pulumi.String("apigw.small.x1"),
    			LogConfig: &apig.GatewayLogConfigArgs{
    				Sls: &apig.GatewayLogConfigSlsArgs{},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = apig.NewEnvironment(ctx, "default", &apig.EnvironmentArgs{
    			Description:     pulumi.String(name),
    			EnvironmentName: pulumi.String(name),
    			GatewayId:       defaultgateway.ID(),
    			ResourceGroupId: pulumi.String(_default.Ids[1]),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.ResourceManager.GetResourceGroups.Invoke();
    
        var defaultGetNetworks = AliCloud.Vpc.GetNetworks.Invoke(new()
        {
            NameRegex = "^default-NODELETING$",
        });
    
        var defaultGetSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
        {
            VpcId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
        });
    
        var defaultgateway = new AliCloud.Apig.Gateway("defaultgateway", new()
        {
            NetworkAccessConfig = new AliCloud.Apig.Inputs.GatewayNetworkAccessConfigArgs
            {
                Type = "Intranet",
            },
            Vswitch = new AliCloud.Apig.Inputs.GatewayVswitchArgs
            {
                VswitchId = defaultGetSwitches.Apply(getSwitchesResult => getSwitchesResult.Ids[0]),
            },
            ZoneConfig = new AliCloud.Apig.Inputs.GatewayZoneConfigArgs
            {
                SelectOption = "Auto",
            },
            Vpc = new AliCloud.Apig.Inputs.GatewayVpcArgs
            {
                VpcId = defaultGetNetworks.Apply(getNetworksResult => getNetworksResult.Ids[0]),
            },
            PaymentType = "PayAsYouGo",
            GatewayName = Std.Format.Invoke(new()
            {
                Input = "%s2",
                Args = new[]
                {
                    name,
                },
            }).Apply(invoke => invoke.Result),
            Spec = "apigw.small.x1",
            LogConfig = new AliCloud.Apig.Inputs.GatewayLogConfigArgs
            {
                Sls = null,
            },
        });
    
        var defaultEnvironment = new AliCloud.Apig.Environment("default", new()
        {
            Description = name,
            EnvironmentName = name,
            GatewayId = defaultgateway.Id,
            ResourceGroupId = @default.Apply(@default => @default.Apply(getResourceGroupsResult => getResourceGroupsResult.Ids[1])),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
    import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
    import com.pulumi.alicloud.vpc.VpcFunctions;
    import com.pulumi.alicloud.vpc.inputs.GetNetworksArgs;
    import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
    import com.pulumi.alicloud.apig.Gateway;
    import com.pulumi.alicloud.apig.GatewayArgs;
    import com.pulumi.alicloud.apig.inputs.GatewayNetworkAccessConfigArgs;
    import com.pulumi.alicloud.apig.inputs.GatewayVswitchArgs;
    import com.pulumi.alicloud.apig.inputs.GatewayZoneConfigArgs;
    import com.pulumi.alicloud.apig.inputs.GatewayVpcArgs;
    import com.pulumi.alicloud.apig.inputs.GatewayLogConfigArgs;
    import com.pulumi.alicloud.apig.inputs.GatewayLogConfigSlsArgs;
    import com.pulumi.std.StdFunctions;
    import com.pulumi.std.inputs.FormatArgs;
    import com.pulumi.alicloud.apig.Environment;
    import com.pulumi.alicloud.apig.EnvironmentArgs;
    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 config = ctx.config();
            final var name = config.get("name").orElse("terraform-example");
            final var default = ResourcemanagerFunctions.getResourceGroups(GetResourceGroupsArgs.builder()
                .build());
    
            final var defaultGetNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
                .nameRegex("^default-NODELETING$")
                .build());
    
            final var defaultGetSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
                .vpcId(defaultGetNetworks.ids()[0])
                .build());
    
            var defaultgateway = new Gateway("defaultgateway", GatewayArgs.builder()
                .networkAccessConfig(GatewayNetworkAccessConfigArgs.builder()
                    .type("Intranet")
                    .build())
                .vswitch(GatewayVswitchArgs.builder()
                    .vswitchId(defaultGetSwitches.ids()[0])
                    .build())
                .zoneConfig(GatewayZoneConfigArgs.builder()
                    .selectOption("Auto")
                    .build())
                .vpc(GatewayVpcArgs.builder()
                    .vpcId(defaultGetNetworks.ids()[0])
                    .build())
                .paymentType("PayAsYouGo")
                .gatewayName(StdFunctions.format(FormatArgs.builder()
                    .input("%s2")
                    .args(name)
                    .build()).result())
                .spec("apigw.small.x1")
                .logConfig(GatewayLogConfigArgs.builder()
                    .sls(GatewayLogConfigSlsArgs.builder()
                        .build())
                    .build())
                .build());
    
            var defaultEnvironment = new Environment("defaultEnvironment", EnvironmentArgs.builder()
                .description(name)
                .environmentName(name)
                .gatewayId(defaultgateway.id())
                .resourceGroupId(default_.ids()[1])
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      defaultgateway:
        type: alicloud:apig:Gateway
        properties:
          networkAccessConfig:
            type: Intranet
          vswitch:
            vswitchId: ${defaultGetSwitches.ids[0]}
          zoneConfig:
            selectOption: Auto
          vpc:
            vpcId: ${defaultGetNetworks.ids[0]}
          paymentType: PayAsYouGo
          gatewayName:
            fn::invoke:
              function: std:format
              arguments:
                input: '%s2'
                args:
                  - ${name}
              return: result
          spec: apigw.small.x1
          logConfig:
            sls: {}
      defaultEnvironment:
        type: alicloud:apig:Environment
        name: default
        properties:
          description: ${name}
          environmentName: ${name}
          gatewayId: ${defaultgateway.id}
          resourceGroupId: ${default.ids[1]}
    variables:
      default:
        fn::invoke:
          function: alicloud:resourcemanager:getResourceGroups
          arguments: {}
      defaultGetNetworks:
        fn::invoke:
          function: alicloud:vpc:getNetworks
          arguments:
            nameRegex: ^default-NODELETING$
      defaultGetSwitches:
        fn::invoke:
          function: alicloud:vpc:getSwitches
          arguments:
            vpcId: ${defaultGetNetworks.ids[0]}
    

    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,
                    environment_name: Optional[str] = None,
                    gateway_id: Optional[str] = None,
                    description: Optional[str] = None,
                    resource_group_id: Optional[str] = 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: alicloud:apig: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 AliCloud.Apig.Environment("environmentResource", new()
    {
        EnvironmentName = "string",
        GatewayId = "string",
        Description = "string",
        ResourceGroupId = "string",
    });
    
    example, err := apig.NewEnvironment(ctx, "environmentResource", &apig.EnvironmentArgs{
    	EnvironmentName: pulumi.String("string"),
    	GatewayId:       pulumi.String("string"),
    	Description:     pulumi.String("string"),
    	ResourceGroupId: pulumi.String("string"),
    })
    
    var environmentResource = new com.pulumi.alicloud.apig.Environment("environmentResource", com.pulumi.alicloud.apig.EnvironmentArgs.builder()
        .environmentName("string")
        .gatewayId("string")
        .description("string")
        .resourceGroupId("string")
        .build());
    
    environment_resource = alicloud.apig.Environment("environmentResource",
        environment_name="string",
        gateway_id="string",
        description="string",
        resource_group_id="string")
    
    const environmentResource = new alicloud.apig.Environment("environmentResource", {
        environmentName: "string",
        gatewayId: "string",
        description: "string",
        resourceGroupId: "string",
    });
    
    type: alicloud:apig:Environment
    properties:
        description: string
        environmentName: string
        gatewayId: string
        resourceGroupId: 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:

    EnvironmentName string
    The name of the resource
    GatewayId string
    Gateway id
    Description string
    Description
    ResourceGroupId string
    The ID of the resource group
    EnvironmentName string
    The name of the resource
    GatewayId string
    Gateway id
    Description string
    Description
    ResourceGroupId string
    The ID of the resource group
    environmentName String
    The name of the resource
    gatewayId String
    Gateway id
    description String
    Description
    resourceGroupId String
    The ID of the resource group
    environmentName string
    The name of the resource
    gatewayId string
    Gateway id
    description string
    Description
    resourceGroupId string
    The ID of the resource group
    environment_name str
    The name of the resource
    gateway_id str
    Gateway id
    description str
    Description
    resource_group_id str
    The ID of the resource group
    environmentName String
    The name of the resource
    gatewayId String
    Gateway id
    description String
    Description
    resourceGroupId String
    The ID of the resource group

    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,
            description: Optional[str] = None,
            environment_name: Optional[str] = None,
            gateway_id: Optional[str] = None,
            resource_group_id: Optional[str] = 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)
    resources:  _:    type: alicloud:apig:Environment    get:      id: ${id}
    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:
    Description string
    Description
    EnvironmentName string
    The name of the resource
    GatewayId string
    Gateway id
    ResourceGroupId string
    The ID of the resource group
    Description string
    Description
    EnvironmentName string
    The name of the resource
    GatewayId string
    Gateway id
    ResourceGroupId string
    The ID of the resource group
    description String
    Description
    environmentName String
    The name of the resource
    gatewayId String
    Gateway id
    resourceGroupId String
    The ID of the resource group
    description string
    Description
    environmentName string
    The name of the resource
    gatewayId string
    Gateway id
    resourceGroupId string
    The ID of the resource group
    description str
    Description
    environment_name str
    The name of the resource
    gateway_id str
    Gateway id
    resource_group_id str
    The ID of the resource group
    description String
    Description
    environmentName String
    The name of the resource
    gatewayId String
    Gateway id
    resourceGroupId String
    The ID of the resource group

    Import

    APIG Environment can be imported using the id, e.g.

    $ pulumi import alicloud:apig/environment:Environment example <id>
    

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

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.86.1 published on Saturday, Sep 27, 2025 by Pulumi