Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi
alicloud.apigateway.PluginAttachment
Explore with Pulumi AI
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 example = new alicloud.apigateway.Group("example", {
name: name,
description: name,
});
const exampleApi = new alicloud.apigateway.Api("example", {
groupId: example.id,
name: name,
description: name,
authType: "APP",
forceNonceCheck: false,
requestConfig: {
protocol: "HTTP",
method: "GET",
path: "/example/path",
mode: "MAPPING",
},
serviceType: "HTTP",
httpServiceConfig: {
address: "http://apigateway-backend.alicloudapi.com:8080",
method: "GET",
path: "/web/cloudapi",
timeout: 12,
aoneName: "cloudapi-openapi",
},
requestParameters: [{
name: "example",
type: "STRING",
required: "OPTIONAL",
"in": "QUERY",
inService: "QUERY",
nameService: "exampleservice",
}],
stageNames: [
"RELEASE",
"TEST",
],
});
const examplePlugin = new alicloud.apigateway.Plugin("example", {
description: "tf_example",
pluginName: "tf_example",
pluginData: JSON.stringify({
allowOrigins: "api.foo.com",
allowMethods: "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH",
allowHeaders: "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid",
exposeHeaders: "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message",
maxAge: 172800,
allowCredentials: true,
}),
pluginType: "cors",
});
const examplePluginAttachment = new alicloud.apigateway.PluginAttachment("example", {
apiId: exampleApi.apiId,
groupId: example.id,
pluginId: examplePlugin.id,
stageName: "RELEASE",
});
import pulumi
import json
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform_example"
example = alicloud.apigateway.Group("example",
name=name,
description=name)
example_api = alicloud.apigateway.Api("example",
group_id=example.id,
name=name,
description=name,
auth_type="APP",
force_nonce_check=False,
request_config={
"protocol": "HTTP",
"method": "GET",
"path": "/example/path",
"mode": "MAPPING",
},
service_type="HTTP",
http_service_config={
"address": "http://apigateway-backend.alicloudapi.com:8080",
"method": "GET",
"path": "/web/cloudapi",
"timeout": 12,
"aone_name": "cloudapi-openapi",
},
request_parameters=[{
"name": "example",
"type": "STRING",
"required": "OPTIONAL",
"in_": "QUERY",
"in_service": "QUERY",
"name_service": "exampleservice",
}],
stage_names=[
"RELEASE",
"TEST",
])
example_plugin = alicloud.apigateway.Plugin("example",
description="tf_example",
plugin_name="tf_example",
plugin_data=json.dumps({
"allowOrigins": "api.foo.com",
"allowMethods": "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH",
"allowHeaders": "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid",
"exposeHeaders": "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message",
"maxAge": 172800,
"allowCredentials": True,
}),
plugin_type="cors")
example_plugin_attachment = alicloud.apigateway.PluginAttachment("example",
api_id=example_api.api_id,
group_id=example.id,
plugin_id=example_plugin.id,
stage_name="RELEASE")
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
}
example, err := apigateway.NewGroup(ctx, "example", &apigateway.GroupArgs{
Name: pulumi.String(name),
Description: pulumi.String(name),
})
if err != nil {
return err
}
exampleApi, err := apigateway.NewApi(ctx, "example", &apigateway.ApiArgs{
GroupId: example.ID(),
Name: pulumi.String(name),
Description: pulumi.String(name),
AuthType: pulumi.String("APP"),
ForceNonceCheck: pulumi.Bool(false),
RequestConfig: &apigateway.ApiRequestConfigArgs{
Protocol: pulumi.String("HTTP"),
Method: pulumi.String("GET"),
Path: pulumi.String("/example/path"),
Mode: pulumi.String("MAPPING"),
},
ServiceType: pulumi.String("HTTP"),
HttpServiceConfig: &apigateway.ApiHttpServiceConfigArgs{
Address: pulumi.String("http://apigateway-backend.alicloudapi.com:8080"),
Method: pulumi.String("GET"),
Path: pulumi.String("/web/cloudapi"),
Timeout: pulumi.Int(12),
AoneName: pulumi.String("cloudapi-openapi"),
},
RequestParameters: apigateway.ApiRequestParameterArray{
&apigateway.ApiRequestParameterArgs{
Name: pulumi.String("example"),
Type: pulumi.String("STRING"),
Required: pulumi.String("OPTIONAL"),
In: pulumi.String("QUERY"),
InService: pulumi.String("QUERY"),
NameService: pulumi.String("exampleservice"),
},
},
StageNames: pulumi.StringArray{
pulumi.String("RELEASE"),
pulumi.String("TEST"),
},
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"allowOrigins": "api.foo.com",
"allowMethods": "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH",
"allowHeaders": "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid",
"exposeHeaders": "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message",
"maxAge": 172800,
"allowCredentials": true,
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
examplePlugin, err := apigateway.NewPlugin(ctx, "example", &apigateway.PluginArgs{
Description: pulumi.String("tf_example"),
PluginName: pulumi.String("tf_example"),
PluginData: pulumi.String(json0),
PluginType: pulumi.String("cors"),
})
if err != nil {
return err
}
_, err = apigateway.NewPluginAttachment(ctx, "example", &apigateway.PluginAttachmentArgs{
ApiId: exampleApi.ApiId,
GroupId: example.ID(),
PluginId: examplePlugin.ID(),
StageName: pulumi.String("RELEASE"),
})
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 example = new AliCloud.ApiGateway.Group("example", new()
{
Name = name,
Description = name,
});
var exampleApi = new AliCloud.ApiGateway.Api("example", new()
{
GroupId = example.Id,
Name = name,
Description = name,
AuthType = "APP",
ForceNonceCheck = false,
RequestConfig = new AliCloud.ApiGateway.Inputs.ApiRequestConfigArgs
{
Protocol = "HTTP",
Method = "GET",
Path = "/example/path",
Mode = "MAPPING",
},
ServiceType = "HTTP",
HttpServiceConfig = new AliCloud.ApiGateway.Inputs.ApiHttpServiceConfigArgs
{
Address = "http://apigateway-backend.alicloudapi.com:8080",
Method = "GET",
Path = "/web/cloudapi",
Timeout = 12,
AoneName = "cloudapi-openapi",
},
RequestParameters = new[]
{
new AliCloud.ApiGateway.Inputs.ApiRequestParameterArgs
{
Name = "example",
Type = "STRING",
Required = "OPTIONAL",
In = "QUERY",
InService = "QUERY",
NameService = "exampleservice",
},
},
StageNames = new[]
{
"RELEASE",
"TEST",
},
});
var examplePlugin = new AliCloud.ApiGateway.Plugin("example", new()
{
Description = "tf_example",
PluginName = "tf_example",
PluginData = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["allowOrigins"] = "api.foo.com",
["allowMethods"] = "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH",
["allowHeaders"] = "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid",
["exposeHeaders"] = "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message",
["maxAge"] = 172800,
["allowCredentials"] = true,
}),
PluginType = "cors",
});
var examplePluginAttachment = new AliCloud.ApiGateway.PluginAttachment("example", new()
{
ApiId = exampleApi.ApiId,
GroupId = example.Id,
PluginId = examplePlugin.Id,
StageName = "RELEASE",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.apigateway.Group;
import com.pulumi.alicloud.apigateway.GroupArgs;
import com.pulumi.alicloud.apigateway.Api;
import com.pulumi.alicloud.apigateway.ApiArgs;
import com.pulumi.alicloud.apigateway.inputs.ApiRequestConfigArgs;
import com.pulumi.alicloud.apigateway.inputs.ApiHttpServiceConfigArgs;
import com.pulumi.alicloud.apigateway.inputs.ApiRequestParameterArgs;
import com.pulumi.alicloud.apigateway.Plugin;
import com.pulumi.alicloud.apigateway.PluginArgs;
import com.pulumi.alicloud.apigateway.PluginAttachment;
import com.pulumi.alicloud.apigateway.PluginAttachmentArgs;
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 example = new Group("example", GroupArgs.builder()
.name(name)
.description(name)
.build());
var exampleApi = new Api("exampleApi", ApiArgs.builder()
.groupId(example.id())
.name(name)
.description(name)
.authType("APP")
.forceNonceCheck(false)
.requestConfig(ApiRequestConfigArgs.builder()
.protocol("HTTP")
.method("GET")
.path("/example/path")
.mode("MAPPING")
.build())
.serviceType("HTTP")
.httpServiceConfig(ApiHttpServiceConfigArgs.builder()
.address("http://apigateway-backend.alicloudapi.com:8080")
.method("GET")
.path("/web/cloudapi")
.timeout(12)
.aoneName("cloudapi-openapi")
.build())
.requestParameters(ApiRequestParameterArgs.builder()
.name("example")
.type("STRING")
.required("OPTIONAL")
.in("QUERY")
.inService("QUERY")
.nameService("exampleservice")
.build())
.stageNames(
"RELEASE",
"TEST")
.build());
var examplePlugin = new Plugin("examplePlugin", PluginArgs.builder()
.description("tf_example")
.pluginName("tf_example")
.pluginData(serializeJson(
jsonObject(
jsonProperty("allowOrigins", "api.foo.com"),
jsonProperty("allowMethods", "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH"),
jsonProperty("allowHeaders", "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid"),
jsonProperty("exposeHeaders", "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message"),
jsonProperty("maxAge", 172800),
jsonProperty("allowCredentials", true)
)))
.pluginType("cors")
.build());
var examplePluginAttachment = new PluginAttachment("examplePluginAttachment", PluginAttachmentArgs.builder()
.apiId(exampleApi.apiId())
.groupId(example.id())
.pluginId(examplePlugin.id())
.stageName("RELEASE")
.build());
}
}
configuration:
name:
type: string
default: terraform_example
resources:
example:
type: alicloud:apigateway:Group
properties:
name: ${name}
description: ${name}
exampleApi:
type: alicloud:apigateway:Api
name: example
properties:
groupId: ${example.id}
name: ${name}
description: ${name}
authType: APP
forceNonceCheck: false
requestConfig:
protocol: HTTP
method: GET
path: /example/path
mode: MAPPING
serviceType: HTTP
httpServiceConfig:
address: http://apigateway-backend.alicloudapi.com:8080
method: GET
path: /web/cloudapi
timeout: 12
aoneName: cloudapi-openapi
requestParameters:
- name: example
type: STRING
required: OPTIONAL
in: QUERY
inService: QUERY
nameService: exampleservice
stageNames:
- RELEASE
- TEST
examplePlugin:
type: alicloud:apigateway:Plugin
name: example
properties:
description: tf_example
pluginName: tf_example
pluginData:
fn::toJSON:
allowOrigins: api.foo.com
allowMethods: GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH
allowHeaders: Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid
exposeHeaders: Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message
maxAge: 172800
allowCredentials: true
pluginType: cors
examplePluginAttachment:
type: alicloud:apigateway:PluginAttachment
name: example
properties:
apiId: ${exampleApi.apiId}
groupId: ${example.id}
pluginId: ${examplePlugin.id}
stageName: RELEASE
Create PluginAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new PluginAttachment(name: string, args: PluginAttachmentArgs, opts?: CustomResourceOptions);
@overload
def PluginAttachment(resource_name: str,
args: PluginAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def PluginAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
api_id: Optional[str] = None,
group_id: Optional[str] = None,
plugin_id: Optional[str] = None,
stage_name: Optional[str] = None)
func NewPluginAttachment(ctx *Context, name string, args PluginAttachmentArgs, opts ...ResourceOption) (*PluginAttachment, error)
public PluginAttachment(string name, PluginAttachmentArgs args, CustomResourceOptions? opts = null)
public PluginAttachment(String name, PluginAttachmentArgs args)
public PluginAttachment(String name, PluginAttachmentArgs args, CustomResourceOptions options)
type: alicloud:apigateway:PluginAttachment
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 PluginAttachmentArgs
- 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 PluginAttachmentArgs
- 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 PluginAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PluginAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args PluginAttachmentArgs
- 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 pluginAttachmentResource = new AliCloud.ApiGateway.PluginAttachment("pluginAttachmentResource", new()
{
ApiId = "string",
GroupId = "string",
PluginId = "string",
StageName = "string",
});
example, err := apigateway.NewPluginAttachment(ctx, "pluginAttachmentResource", &apigateway.PluginAttachmentArgs{
ApiId: pulumi.String("string"),
GroupId: pulumi.String("string"),
PluginId: pulumi.String("string"),
StageName: pulumi.String("string"),
})
var pluginAttachmentResource = new PluginAttachment("pluginAttachmentResource", PluginAttachmentArgs.builder()
.apiId("string")
.groupId("string")
.pluginId("string")
.stageName("string")
.build());
plugin_attachment_resource = alicloud.apigateway.PluginAttachment("pluginAttachmentResource",
api_id="string",
group_id="string",
plugin_id="string",
stage_name="string")
const pluginAttachmentResource = new alicloud.apigateway.PluginAttachment("pluginAttachmentResource", {
apiId: "string",
groupId: "string",
pluginId: "string",
stageName: "string",
});
type: alicloud:apigateway:PluginAttachment
properties:
apiId: string
groupId: string
pluginId: string
stageName: string
PluginAttachment 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 PluginAttachment resource accepts the following input properties:
- api_
id str - The api_id that plugin attaches to.
- group_
id str - The group that the api belongs to.
- plugin_
id str - The plugin that attaches to the api.
- stage_
name str - Stage that the plugin attaches to.
Outputs
All input properties are implicitly available as output properties. Additionally, the PluginAttachment 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 PluginAttachment Resource
Get an existing PluginAttachment 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?: PluginAttachmentState, opts?: CustomResourceOptions): PluginAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
api_id: Optional[str] = None,
group_id: Optional[str] = None,
plugin_id: Optional[str] = None,
stage_name: Optional[str] = None) -> PluginAttachment
func GetPluginAttachment(ctx *Context, name string, id IDInput, state *PluginAttachmentState, opts ...ResourceOption) (*PluginAttachment, error)
public static PluginAttachment Get(string name, Input<string> id, PluginAttachmentState? state, CustomResourceOptions? opts = null)
public static PluginAttachment get(String name, Output<String> id, PluginAttachmentState 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.
- api_
id str - The api_id that plugin attaches to.
- group_
id str - The group that the api belongs to.
- plugin_
id str - The plugin that attaches to the api.
- stage_
name str - Stage that the plugin attaches to.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.