1. Registry
  2. Packages
  3. Alibaba Cloud Provider
  4. API Docs
  5. gpdb
  6. ApiKey
Viewing docs for Alibaba Cloud v3.106.0
published on Monday, Aug 24, 2026 by Pulumi
alicloud logo alicloud logo
Viewing docs for Alibaba Cloud v3.106.0
published on Monday, Aug 24, 2026 by Pulumi

    Provides a AnalyticDB for PostgreSQL (GPDB) Api Key resource.

    The API key under a GPDB SaaS workspace.

    For information about AnalyticDB for PostgreSQL (GPDB) Api Key and how to use it, see What is Api Key.

    NOTE: Available since v1.286.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 workspaceId = config.get("workspaceId") || "ws-xxxxxxx";
    const _default = new alicloud.gpdb.ApiKey("default", {
        workspaceId: workspaceId,
        keyName: name,
        description: "terraform example",
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    workspace_id = config.get("workspaceId")
    if workspace_id is None:
        workspace_id = "ws-xxxxxxx"
    default = alicloud.gpdb.ApiKey("default",
        workspace_id=workspace_id,
        key_name=name,
        description="terraform example")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/gpdb"
    	"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
    		}
    		workspaceId := "ws-xxxxxxx"
    		if param := cfg.Get("workspaceId"); param != "" {
    			workspaceId = param
    		}
    		_, err := gpdb.NewApiKey(ctx, "default", &gpdb.ApiKeyArgs{
    			WorkspaceId: pulumi.String(workspaceId),
    			KeyName:     pulumi.String(name),
    			Description: pulumi.String("terraform example"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var workspaceId = config.Get("workspaceId") ?? "ws-xxxxxxx";
        var @default = new AliCloud.Gpdb.ApiKey("default", new()
        {
            WorkspaceId = workspaceId,
            KeyName = name,
            Description = "terraform example",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.gpdb.ApiKey;
    import com.pulumi.alicloud.gpdb.ApiKeyArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 workspaceId = config.get("workspaceId").orElse("ws-xxxxxxx");
            var default_ = new ApiKey("default", ApiKeyArgs.builder()
                .workspaceId(workspaceId)
                .keyName(name)
                .description("terraform example")
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
      workspaceId:
        type: string
        default: ws-xxxxxxx
    resources:
      default:
        type: alicloud:gpdb:ApiKey
        properties:
          workspaceId: ${workspaceId}
          keyName: ${name}
          description: terraform example
    
    pulumi {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    resource "alicloud_gpdb_apikey" "default" {
      workspace_id = var.workspaceId
      key_name     = var.name
      description  = "terraform example"
    }
    variable "name" {
      type    = string
      default = "terraform-example"
    }
    variable "workspaceId" {
      type    = string
      default = "ws-xxxxxxx"
    }
    

    📚 Need more examples? VIEW MORE EXAMPLES

    Create ApiKey Resource

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

    Constructor syntax

    new ApiKey(name: string, args: ApiKeyArgs, opts?: CustomResourceOptions);
    @overload
    def ApiKey(resource_name: str,
               args: ApiKeyArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def ApiKey(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               key_name: Optional[str] = None,
               workspace_id: Optional[str] = None,
               description: Optional[str] = None,
               service_ids: Optional[Sequence[str]] = None)
    func NewApiKey(ctx *Context, name string, args ApiKeyArgs, opts ...ResourceOption) (*ApiKey, error)
    public ApiKey(string name, ApiKeyArgs args, CustomResourceOptions? opts = null)
    public ApiKey(String name, ApiKeyArgs args)
    public ApiKey(String name, ApiKeyArgs args, CustomResourceOptions options)
    
    type: alicloud:gpdb:ApiKey
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "alicloud_gpdb_api_key" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args ApiKeyArgs
    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 ApiKeyArgs
    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 ApiKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ApiKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ApiKeyArgs
    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 apiKeyResource = new AliCloud.Gpdb.ApiKey("apiKeyResource", new()
    {
        KeyName = "string",
        WorkspaceId = "string",
        Description = "string",
        ServiceIds = new[]
        {
            "string",
        },
    });
    
    example, err := gpdb.NewApiKey(ctx, "apiKeyResource", &gpdb.ApiKeyArgs{
    	KeyName:     pulumi.String("string"),
    	WorkspaceId: pulumi.String("string"),
    	Description: pulumi.String("string"),
    	ServiceIds: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    resource "alicloud_gpdb_api_key" "apiKeyResource" {
      lifecycle {
        create_before_destroy = true
      }
      key_name     = "string"
      workspace_id = "string"
      description  = "string"
      service_ids  = ["string"]
    }
    
    var apiKeyResource = new ApiKey("apiKeyResource", ApiKeyArgs.builder()
        .keyName("string")
        .workspaceId("string")
        .description("string")
        .serviceIds("string")
        .build());
    
    api_key_resource = alicloud.gpdb.ApiKey("apiKeyResource",
        key_name="string",
        workspace_id="string",
        description="string",
        service_ids=["string"])
    
    const apiKeyResource = new alicloud.gpdb.ApiKey("apiKeyResource", {
        keyName: "string",
        workspaceId: "string",
        description: "string",
        serviceIds: ["string"],
    });
    
    type: alicloud:gpdb:ApiKey
    properties:
        description: string
        keyName: string
        serviceIds:
            - string
        workspaceId: string
    

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

    KeyName string
    The name of the API key.
    WorkspaceId string
    The ID of the workspace.
    Description string
    The description of the API key.
    ServiceIds List<string>
    The list of SaaS service IDs that the API key is authorized to access.
    KeyName string
    The name of the API key.
    WorkspaceId string
    The ID of the workspace.
    Description string
    The description of the API key.
    ServiceIds []string
    The list of SaaS service IDs that the API key is authorized to access.
    key_name string
    The name of the API key.
    workspace_id string
    The ID of the workspace.
    description string
    The description of the API key.
    service_ids list(string)
    The list of SaaS service IDs that the API key is authorized to access.
    keyName String
    The name of the API key.
    workspaceId String
    The ID of the workspace.
    description String
    The description of the API key.
    serviceIds List<String>
    The list of SaaS service IDs that the API key is authorized to access.
    keyName string
    The name of the API key.
    workspaceId string
    The ID of the workspace.
    description string
    The description of the API key.
    serviceIds string[]
    The list of SaaS service IDs that the API key is authorized to access.
    key_name str
    The name of the API key.
    workspace_id str
    The ID of the workspace.
    description str
    The description of the API key.
    service_ids Sequence[str]
    The list of SaaS service IDs that the API key is authorized to access.
    keyName String
    The name of the API key.
    workspaceId String
    The ID of the workspace.
    description String
    The description of the API key.
    serviceIds List<String>
    The list of SaaS service IDs that the API key is authorized to access.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ApiKey resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    KeyId string
    The ID of the API key.
    Id string
    The provider-assigned unique ID for this managed resource.
    KeyId string
    The ID of the API key.
    id string
    The provider-assigned unique ID for this managed resource.
    key_id string
    The ID of the API key.
    id String
    The provider-assigned unique ID for this managed resource.
    keyId String
    The ID of the API key.
    id string
    The provider-assigned unique ID for this managed resource.
    keyId string
    The ID of the API key.
    id str
    The provider-assigned unique ID for this managed resource.
    key_id str
    The ID of the API key.
    id String
    The provider-assigned unique ID for this managed resource.
    keyId String
    The ID of the API key.

    Look up Existing ApiKey Resource

    Get an existing ApiKey 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?: ApiKeyState, opts?: CustomResourceOptions): ApiKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            key_id: Optional[str] = None,
            key_name: Optional[str] = None,
            service_ids: Optional[Sequence[str]] = None,
            workspace_id: Optional[str] = None) -> ApiKey
    func GetApiKey(ctx *Context, name string, id IDInput, state *ApiKeyState, opts ...ResourceOption) (*ApiKey, error)
    public static ApiKey Get(string name, Input<string> id, ApiKeyState? state, CustomResourceOptions? opts = null)
    public static ApiKey get(String name, Output<String> id, ApiKeyState state, CustomResourceOptions options)
    resources:  _:    type: alicloud:gpdb:ApiKey    get:      id: ${id}
    import {
      to = alicloud_gpdb_api_key.example
      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
    The description of the API key.
    KeyId string
    The ID of the API key.
    KeyName string
    The name of the API key.
    ServiceIds List<string>
    The list of SaaS service IDs that the API key is authorized to access.
    WorkspaceId string
    The ID of the workspace.
    Description string
    The description of the API key.
    KeyId string
    The ID of the API key.
    KeyName string
    The name of the API key.
    ServiceIds []string
    The list of SaaS service IDs that the API key is authorized to access.
    WorkspaceId string
    The ID of the workspace.
    description string
    The description of the API key.
    key_id string
    The ID of the API key.
    key_name string
    The name of the API key.
    service_ids list(string)
    The list of SaaS service IDs that the API key is authorized to access.
    workspace_id string
    The ID of the workspace.
    description String
    The description of the API key.
    keyId String
    The ID of the API key.
    keyName String
    The name of the API key.
    serviceIds List<String>
    The list of SaaS service IDs that the API key is authorized to access.
    workspaceId String
    The ID of the workspace.
    description string
    The description of the API key.
    keyId string
    The ID of the API key.
    keyName string
    The name of the API key.
    serviceIds string[]
    The list of SaaS service IDs that the API key is authorized to access.
    workspaceId string
    The ID of the workspace.
    description str
    The description of the API key.
    key_id str
    The ID of the API key.
    key_name str
    The name of the API key.
    service_ids Sequence[str]
    The list of SaaS service IDs that the API key is authorized to access.
    workspace_id str
    The ID of the workspace.
    description String
    The description of the API key.
    keyId String
    The ID of the API key.
    keyName String
    The name of the API key.
    serviceIds List<String>
    The list of SaaS service IDs that the API key is authorized to access.
    workspaceId String
    The ID of the workspace.

    Import

    AnalyticDB for PostgreSQL (GPDB) Api Key can be imported using the id, e.g.

    $ pulumi import alicloud:gpdb/apiKey:ApiKey example <workspace_id>:<key_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 alicloud logo
    Viewing docs for Alibaba Cloud v3.106.0
    published on Monday, Aug 24, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial