1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. ApiGatewayApiKeyAttachment
tencentcloud 1.81.183 published on Wednesday, Apr 16, 2025 by tencentcloudstack

tencentcloud.ApiGatewayApiKeyAttachment

Explore with Pulumi AI

Use this resource to API gateway attach access key to usage plan.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";

const key = new tencentcloud.ApiGatewayApiKey("key", {
    secretName: "my_api_key",
    status: "on",
});
const plan = new tencentcloud.ApiGatewayUsagePlan("plan", {
    usagePlanName: "my_plan",
    usagePlanDesc: "nice plan",
    maxRequestNum: 100,
    maxRequestNumPreSec: 10,
});
const attach = new tencentcloud.ApiGatewayApiKeyAttachment("attach", {
    apiKeyId: key.apiGatewayApiKeyId,
    usagePlanId: plan.apiGatewayUsagePlanId,
});
Copy
import pulumi
import pulumi_tencentcloud as tencentcloud

key = tencentcloud.ApiGatewayApiKey("key",
    secret_name="my_api_key",
    status="on")
plan = tencentcloud.ApiGatewayUsagePlan("plan",
    usage_plan_name="my_plan",
    usage_plan_desc="nice plan",
    max_request_num=100,
    max_request_num_pre_sec=10)
attach = tencentcloud.ApiGatewayApiKeyAttachment("attach",
    api_key_id=key.api_gateway_api_key_id,
    usage_plan_id=plan.api_gateway_usage_plan_id)
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		key, err := tencentcloud.NewApiGatewayApiKey(ctx, "key", &tencentcloud.ApiGatewayApiKeyArgs{
			SecretName: pulumi.String("my_api_key"),
			Status:     pulumi.String("on"),
		})
		if err != nil {
			return err
		}
		plan, err := tencentcloud.NewApiGatewayUsagePlan(ctx, "plan", &tencentcloud.ApiGatewayUsagePlanArgs{
			UsagePlanName:       pulumi.String("my_plan"),
			UsagePlanDesc:       pulumi.String("nice plan"),
			MaxRequestNum:       pulumi.Float64(100),
			MaxRequestNumPreSec: pulumi.Float64(10),
		})
		if err != nil {
			return err
		}
		_, err = tencentcloud.NewApiGatewayApiKeyAttachment(ctx, "attach", &tencentcloud.ApiGatewayApiKeyAttachmentArgs{
			ApiKeyId:    key.ApiGatewayApiKeyId,
			UsagePlanId: plan.ApiGatewayUsagePlanId,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;

return await Deployment.RunAsync(() => 
{
    var key = new Tencentcloud.ApiGatewayApiKey("key", new()
    {
        SecretName = "my_api_key",
        Status = "on",
    });

    var plan = new Tencentcloud.ApiGatewayUsagePlan("plan", new()
    {
        UsagePlanName = "my_plan",
        UsagePlanDesc = "nice plan",
        MaxRequestNum = 100,
        MaxRequestNumPreSec = 10,
    });

    var attach = new Tencentcloud.ApiGatewayApiKeyAttachment("attach", new()
    {
        ApiKeyId = key.ApiGatewayApiKeyId,
        UsagePlanId = plan.ApiGatewayUsagePlanId,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.ApiGatewayApiKey;
import com.pulumi.tencentcloud.ApiGatewayApiKeyArgs;
import com.pulumi.tencentcloud.ApiGatewayUsagePlan;
import com.pulumi.tencentcloud.ApiGatewayUsagePlanArgs;
import com.pulumi.tencentcloud.ApiGatewayApiKeyAttachment;
import com.pulumi.tencentcloud.ApiGatewayApiKeyAttachmentArgs;
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 key = new ApiGatewayApiKey("key", ApiGatewayApiKeyArgs.builder()
            .secretName("my_api_key")
            .status("on")
            .build());

        var plan = new ApiGatewayUsagePlan("plan", ApiGatewayUsagePlanArgs.builder()
            .usagePlanName("my_plan")
            .usagePlanDesc("nice plan")
            .maxRequestNum(100)
            .maxRequestNumPreSec(10)
            .build());

        var attach = new ApiGatewayApiKeyAttachment("attach", ApiGatewayApiKeyAttachmentArgs.builder()
            .apiKeyId(key.apiGatewayApiKeyId())
            .usagePlanId(plan.apiGatewayUsagePlanId())
            .build());

    }
}
Copy
resources:
  key:
    type: tencentcloud:ApiGatewayApiKey
    properties:
      secretName: my_api_key
      status: on
  plan:
    type: tencentcloud:ApiGatewayUsagePlan
    properties:
      usagePlanName: my_plan
      usagePlanDesc: nice plan
      maxRequestNum: 100
      maxRequestNumPreSec: 10
  attach:
    type: tencentcloud:ApiGatewayApiKeyAttachment
    properties:
      apiKeyId: ${key.apiGatewayApiKeyId}
      usagePlanId: ${plan.apiGatewayUsagePlanId}
Copy

Create ApiGatewayApiKeyAttachment Resource

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

Constructor syntax

new ApiGatewayApiKeyAttachment(name: string, args: ApiGatewayApiKeyAttachmentArgs, opts?: CustomResourceOptions);
@overload
def ApiGatewayApiKeyAttachment(resource_name: str,
                               args: ApiGatewayApiKeyAttachmentArgs,
                               opts: Optional[ResourceOptions] = None)

@overload
def ApiGatewayApiKeyAttachment(resource_name: str,
                               opts: Optional[ResourceOptions] = None,
                               api_key_id: Optional[str] = None,
                               usage_plan_id: Optional[str] = None,
                               api_gateway_api_key_attachment_id: Optional[str] = None)
func NewApiGatewayApiKeyAttachment(ctx *Context, name string, args ApiGatewayApiKeyAttachmentArgs, opts ...ResourceOption) (*ApiGatewayApiKeyAttachment, error)
public ApiGatewayApiKeyAttachment(string name, ApiGatewayApiKeyAttachmentArgs args, CustomResourceOptions? opts = null)
public ApiGatewayApiKeyAttachment(String name, ApiGatewayApiKeyAttachmentArgs args)
public ApiGatewayApiKeyAttachment(String name, ApiGatewayApiKeyAttachmentArgs args, CustomResourceOptions options)
type: tencentcloud:ApiGatewayApiKeyAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ApiGatewayApiKeyAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ApiGatewayApiKeyAttachmentArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ApiGatewayApiKeyAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ApiGatewayApiKeyAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ApiGatewayApiKeyAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

ApiKeyId This property is required. string
ID of API key.
UsagePlanId This property is required. string
ID of the usage plan.
ApiGatewayApiKeyAttachmentId string
ID of the resource.
ApiKeyId This property is required. string
ID of API key.
UsagePlanId This property is required. string
ID of the usage plan.
ApiGatewayApiKeyAttachmentId string
ID of the resource.
apiKeyId This property is required. String
ID of API key.
usagePlanId This property is required. String
ID of the usage plan.
apiGatewayApiKeyAttachmentId String
ID of the resource.
apiKeyId This property is required. string
ID of API key.
usagePlanId This property is required. string
ID of the usage plan.
apiGatewayApiKeyAttachmentId string
ID of the resource.
api_key_id This property is required. str
ID of API key.
usage_plan_id This property is required. str
ID of the usage plan.
api_gateway_api_key_attachment_id str
ID of the resource.
apiKeyId This property is required. String
ID of API key.
usagePlanId This property is required. String
ID of the usage plan.
apiGatewayApiKeyAttachmentId String
ID of the resource.

Outputs

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

Get an existing ApiGatewayApiKeyAttachment 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?: ApiGatewayApiKeyAttachmentState, opts?: CustomResourceOptions): ApiGatewayApiKeyAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        api_gateway_api_key_attachment_id: Optional[str] = None,
        api_key_id: Optional[str] = None,
        usage_plan_id: Optional[str] = None) -> ApiGatewayApiKeyAttachment
func GetApiGatewayApiKeyAttachment(ctx *Context, name string, id IDInput, state *ApiGatewayApiKeyAttachmentState, opts ...ResourceOption) (*ApiGatewayApiKeyAttachment, error)
public static ApiGatewayApiKeyAttachment Get(string name, Input<string> id, ApiGatewayApiKeyAttachmentState? state, CustomResourceOptions? opts = null)
public static ApiGatewayApiKeyAttachment get(String name, Output<String> id, ApiGatewayApiKeyAttachmentState state, CustomResourceOptions options)
resources:  _:    type: tencentcloud:ApiGatewayApiKeyAttachment    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
ApiGatewayApiKeyAttachmentId string
ID of the resource.
ApiKeyId string
ID of API key.
UsagePlanId string
ID of the usage plan.
ApiGatewayApiKeyAttachmentId string
ID of the resource.
ApiKeyId string
ID of API key.
UsagePlanId string
ID of the usage plan.
apiGatewayApiKeyAttachmentId String
ID of the resource.
apiKeyId String
ID of API key.
usagePlanId String
ID of the usage plan.
apiGatewayApiKeyAttachmentId string
ID of the resource.
apiKeyId string
ID of API key.
usagePlanId string
ID of the usage plan.
api_gateway_api_key_attachment_id str
ID of the resource.
api_key_id str
ID of API key.
usage_plan_id str
ID of the usage plan.
apiGatewayApiKeyAttachmentId String
ID of the resource.
apiKeyId String
ID of API key.
usagePlanId String
ID of the usage plan.

Import

API gateway attach access key can be imported using the id, e.g.

$ pulumi import tencentcloud:index/apiGatewayApiKeyAttachment:ApiGatewayApiKeyAttachment attach [your api_key_id]#usagePlan-gyeafpab
Copy

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

Package Details

Repository
tencentcloud tencentcloudstack/terraform-provider-tencentcloud
License
Notes
This Pulumi package is based on the tencentcloud Terraform Provider.