alicloud.apigateway.Plugin
Explore with Pulumi AI
Provides a Api Gateway Plugin resource.
For information about Api Gateway Plugin and how to use it, see What is Plugin.
NOTE: Available since v1.187.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "terraform_example";
const _default = new alicloud.apigateway.Plugin("default", {
description: name,
pluginName: name,
pluginData: JSON.stringify({
routes: [
{
name: "Vip",
condition: "$CaAppId = 123456",
backend: {
type: "HTTP-VPC",
vpcAccessName: "slbAccessForVip",
},
},
{
name: "MockForOldClient",
condition: "$ClientVersion < '2.0.5'",
backend: {
type: "MOCK",
statusCode: 400,
mockBody: "This version is not supported!!!",
},
},
{
name: "BlueGreenPercent05",
condition: "1 = 1",
backend: {
type: "HTTP",
address: "https://beta-version.api.foo.com",
},
"constant-parameters": [{
name: "x-route-blue-green",
location: "header",
value: "route-blue-green",
}],
},
],
}),
pluginType: "routing",
});
import pulumi
import json
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform_example"
default = alicloud.apigateway.Plugin("default",
description=name,
plugin_name=name,
plugin_data=json.dumps({
"routes": [
{
"name": "Vip",
"condition": "$CaAppId = 123456",
"backend": {
"type": "HTTP-VPC",
"vpcAccessName": "slbAccessForVip",
},
},
{
"name": "MockForOldClient",
"condition": "$ClientVersion < '2.0.5'",
"backend": {
"type": "MOCK",
"statusCode": 400,
"mockBody": "This version is not supported!!!",
},
},
{
"name": "BlueGreenPercent05",
"condition": "1 = 1",
"backend": {
"type": "HTTP",
"address": "https://beta-version.api.foo.com",
},
"constant-parameters": [{
"name": "x-route-blue-green",
"location": "header",
"value": "route-blue-green",
}],
},
],
}),
plugin_type="routing")
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/apigateway"
"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
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"routes": []interface{}{
map[string]interface{}{
"name": "Vip",
"condition": "$CaAppId = 123456",
"backend": map[string]interface{}{
"type": "HTTP-VPC",
"vpcAccessName": "slbAccessForVip",
},
},
map[string]interface{}{
"name": "MockForOldClient",
"condition": "$ClientVersion < '2.0.5'",
"backend": map[string]interface{}{
"type": "MOCK",
"statusCode": 400,
"mockBody": "This version is not supported!!!",
},
},
map[string]interface{}{
"name": "BlueGreenPercent05",
"condition": "1 = 1",
"backend": map[string]interface{}{
"type": "HTTP",
"address": "https://beta-version.api.foo.com",
},
"constant-parameters": []map[string]interface{}{
map[string]interface{}{
"name": "x-route-blue-green",
"location": "header",
"value": "route-blue-green",
},
},
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
_, err = apigateway.NewPlugin(ctx, "default", &apigateway.PluginArgs{
Description: pulumi.String(name),
PluginName: pulumi.String(name),
PluginData: pulumi.String(json0),
PluginType: pulumi.String("routing"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform_example";
var @default = new AliCloud.ApiGateway.Plugin("default", new()
{
Description = name,
PluginName = name,
PluginData = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["routes"] = new[]
{
new Dictionary<string, object?>
{
["name"] = "Vip",
["condition"] = "$CaAppId = 123456",
["backend"] = new Dictionary<string, object?>
{
["type"] = "HTTP-VPC",
["vpcAccessName"] = "slbAccessForVip",
},
},
new Dictionary<string, object?>
{
["name"] = "MockForOldClient",
["condition"] = "$ClientVersion < '2.0.5'",
["backend"] = new Dictionary<string, object?>
{
["type"] = "MOCK",
["statusCode"] = 400,
["mockBody"] = "This version is not supported!!!",
},
},
new Dictionary<string, object?>
{
["name"] = "BlueGreenPercent05",
["condition"] = "1 = 1",
["backend"] = new Dictionary<string, object?>
{
["type"] = "HTTP",
["address"] = "https://beta-version.api.foo.com",
},
["constant-parameters"] = new[]
{
new Dictionary<string, object?>
{
["name"] = "x-route-blue-green",
["location"] = "header",
["value"] = "route-blue-green",
},
},
},
},
}),
PluginType = "routing",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.apigateway.Plugin;
import com.pulumi.alicloud.apigateway.PluginArgs;
import static com.pulumi.codegen.internal.Serialization.*;
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");
var default_ = new Plugin("default", PluginArgs.builder()
.description(name)
.pluginName(name)
.pluginData(serializeJson(
jsonObject(
jsonProperty("routes", jsonArray(
jsonObject(
jsonProperty("name", "Vip"),
jsonProperty("condition", "$CaAppId = 123456"),
jsonProperty("backend", jsonObject(
jsonProperty("type", "HTTP-VPC"),
jsonProperty("vpcAccessName", "slbAccessForVip")
))
),
jsonObject(
jsonProperty("name", "MockForOldClient"),
jsonProperty("condition", "$ClientVersion < '2.0.5'"),
jsonProperty("backend", jsonObject(
jsonProperty("type", "MOCK"),
jsonProperty("statusCode", 400),
jsonProperty("mockBody", "This version is not supported!!!")
))
),
jsonObject(
jsonProperty("name", "BlueGreenPercent05"),
jsonProperty("condition", "1 = 1"),
jsonProperty("backend", jsonObject(
jsonProperty("type", "HTTP"),
jsonProperty("address", "https://beta-version.api.foo.com")
)),
jsonProperty("constant-parameters", jsonArray(jsonObject(
jsonProperty("name", "x-route-blue-green"),
jsonProperty("location", "header"),
jsonProperty("value", "route-blue-green")
)))
)
))
)))
.pluginType("routing")
.build());
}
}
configuration:
name:
type: string
default: terraform_example
resources:
default:
type: alicloud:apigateway:Plugin
properties:
description: ${name}
pluginName: ${name}
pluginData:
fn::toJSON:
routes:
- name: Vip
condition: $CaAppId = 123456
backend:
type: HTTP-VPC
vpcAccessName: slbAccessForVip
- name: MockForOldClient
condition: $ClientVersion < '2.0.5'
backend:
type: MOCK
statusCode: 400
mockBody: This version is not supported!!!
- name: BlueGreenPercent05
condition: 1 = 1
backend:
type: HTTP
address: https://beta-version.api.foo.com
constant-parameters:
- name: x-route-blue-green
location: header
value: route-blue-green
pluginType: routing
Create Plugin Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Plugin(name: string, args: PluginArgs, opts?: CustomResourceOptions);
@overload
def Plugin(resource_name: str,
args: PluginArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Plugin(resource_name: str,
opts: Optional[ResourceOptions] = None,
plugin_data: Optional[str] = None,
plugin_name: Optional[str] = None,
plugin_type: Optional[str] = None,
description: Optional[str] = None,
tags: Optional[Mapping[str, Any]] = None)
func NewPlugin(ctx *Context, name string, args PluginArgs, opts ...ResourceOption) (*Plugin, error)
public Plugin(string name, PluginArgs args, CustomResourceOptions? opts = null)
public Plugin(String name, PluginArgs args)
public Plugin(String name, PluginArgs args, CustomResourceOptions options)
type: alicloud:apigateway:Plugin
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 PluginArgs
- 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 PluginArgs
- 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 PluginArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PluginArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args PluginArgs
- 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 pluginResource = new AliCloud.ApiGateway.Plugin("pluginResource", new()
{
PluginData = "string",
PluginName = "string",
PluginType = "string",
Description = "string",
Tags =
{
{ "string", "any" },
},
});
example, err := apigateway.NewPlugin(ctx, "pluginResource", &apigateway.PluginArgs{
PluginData: pulumi.String("string"),
PluginName: pulumi.String("string"),
PluginType: pulumi.String("string"),
Description: pulumi.String("string"),
Tags: pulumi.Map{
"string": pulumi.Any("any"),
},
})
var pluginResource = new Plugin("pluginResource", PluginArgs.builder()
.pluginData("string")
.pluginName("string")
.pluginType("string")
.description("string")
.tags(Map.of("string", "any"))
.build());
plugin_resource = alicloud.apigateway.Plugin("pluginResource",
plugin_data="string",
plugin_name="string",
plugin_type="string",
description="string",
tags={
"string": "any",
})
const pluginResource = new alicloud.apigateway.Plugin("pluginResource", {
pluginData: "string",
pluginName: "string",
pluginType: "string",
description: "string",
tags: {
string: "any",
},
});
type: alicloud:apigateway:Plugin
properties:
description: string
pluginData: string
pluginName: string
pluginType: string
tags:
string: any
Plugin Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Plugin resource accepts the following input properties:
- Plugin
Data string - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- Plugin
Name string - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- Plugin
Type string - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- Description string
- The description of the plug-in, which cannot exceed 200 characters.
- Dictionary<string, object>
- The tag of the resource.
- Plugin
Data string - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- Plugin
Name string - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- Plugin
Type string - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- Description string
- The description of the plug-in, which cannot exceed 200 characters.
- map[string]interface{}
- The tag of the resource.
- plugin
Data String - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin
Name String - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin
Type String - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- description String
- The description of the plug-in, which cannot exceed 200 characters.
- Map<String,Object>
- The tag of the resource.
- plugin
Data string - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin
Name string - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin
Type string - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- description string
- The description of the plug-in, which cannot exceed 200 characters.
- {[key: string]: any}
- The tag of the resource.
- plugin_
data str - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin_
name str - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin_
type str - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- description str
- The description of the plug-in, which cannot exceed 200 characters.
- Mapping[str, Any]
- The tag of the resource.
- plugin
Data String - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin
Name String - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin
Type String - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- description String
- The description of the plug-in, which cannot exceed 200 characters.
- Map<Any>
- The tag of the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the Plugin resource produces the following output properties:
- Create
Time string - Create time.
- Id string
- The provider-assigned unique ID for this managed resource.
- Create
Time string - Create time.
- Id string
- The provider-assigned unique ID for this managed resource.
- create
Time String - Create time.
- id String
- The provider-assigned unique ID for this managed resource.
- create
Time string - Create time.
- id string
- The provider-assigned unique ID for this managed resource.
- create_
time str - Create time.
- id str
- The provider-assigned unique ID for this managed resource.
- create
Time String - Create time.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Plugin Resource
Get an existing Plugin 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?: PluginState, opts?: CustomResourceOptions): Plugin
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
create_time: Optional[str] = None,
description: Optional[str] = None,
plugin_data: Optional[str] = None,
plugin_name: Optional[str] = None,
plugin_type: Optional[str] = None,
tags: Optional[Mapping[str, Any]] = None) -> Plugin
func GetPlugin(ctx *Context, name string, id IDInput, state *PluginState, opts ...ResourceOption) (*Plugin, error)
public static Plugin Get(string name, Input<string> id, PluginState? state, CustomResourceOptions? opts = null)
public static Plugin get(String name, Output<String> id, PluginState 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.
- Create
Time string - Create time.
- Description string
- The description of the plug-in, which cannot exceed 200 characters.
- Plugin
Data string - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- Plugin
Name string - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- Plugin
Type string - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- Dictionary<string, object>
- The tag of the resource.
- Create
Time string - Create time.
- Description string
- The description of the plug-in, which cannot exceed 200 characters.
- Plugin
Data string - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- Plugin
Name string - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- Plugin
Type string - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- map[string]interface{}
- The tag of the resource.
- create
Time String - Create time.
- description String
- The description of the plug-in, which cannot exceed 200 characters.
- plugin
Data String - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin
Name String - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin
Type String - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- Map<String,Object>
- The tag of the resource.
- create
Time string - Create time.
- description string
- The description of the plug-in, which cannot exceed 200 characters.
- plugin
Data string - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin
Name string - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin
Type string - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- {[key: string]: any}
- The tag of the resource.
- create_
time str - Create time.
- description str
- The description of the plug-in, which cannot exceed 200 characters.
- plugin_
data str - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin_
name str - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin_
type str - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- Mapping[str, Any]
- The tag of the resource.
- create
Time String - Create time.
- description String
- The description of the plug-in, which cannot exceed 200 characters.
- plugin
Data String - The definition statement of the plug-in. Plug-in definition statements in the JSON and YAML formats are supported.
- plugin
Name String - The name of the plug-in that you want to create. It can contain uppercase English letters, lowercase English letters, Chinese characters, numbers, and underscores (). It must be 4 to 50 characters in length and cannot start with an underscore ().
- plugin
Type String - The type of the plug-in. Valid values:
- "trafficControl"
- "ipControl"
- "backendSignature"
- "jwtAuth"
- "basicAuth"
- "cors"
- "caching"
- "routing"
- "accessControl"
- "errorMapping"
- "circuitBreaker"
- "remoteAuth"
- "logMask"
- "transformer".
- Map<Any>
- The tag of the resource.
Import
Api Gateway Plugin can be imported using the id, e.g.
$ pulumi import alicloud:apigateway/plugin:Plugin 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.