1. Packages
  2. Harness Provider
  3. API Docs
  4. PlatformApiKey
Harness v0.7.3 published on Friday, Apr 18, 2025 by Pulumi

harness.PlatformApiKey

Explore with Pulumi AI

Resource for creating and managing Harness API Keys. API Keys can be created at the account, organization, or project level.

Example Usage

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

// Create API Key at account level
const accountLevel = new harness.PlatformApiKey("account_level", {
    identifier: "test_apikey",
    name: "test_apikey",
    parentId: "parent_id",
    apikeyType: "USER",
    accountId: "account_id",
});
// Create API Key at organization level
const orgLevel = new harness.PlatformApiKey("org_level", {
    identifier: "test_apikey",
    name: "test_apikey",
    parentId: "parent_id",
    apikeyType: "USER",
    accountId: "account_id",
    orgId: "org_id",
});
// Create API Key at project level
const projectLevel = new harness.PlatformApiKey("project_level", {
    identifier: "test_apikey",
    name: "test_apikey",
    parentId: "parent_id",
    apikeyType: "USER",
    accountId: "account_id",
    orgId: "org_id",
    projectId: "project_id",
});
Copy
import pulumi
import pulumi_harness as harness

# Create API Key at account level
account_level = harness.PlatformApiKey("account_level",
    identifier="test_apikey",
    name="test_apikey",
    parent_id="parent_id",
    apikey_type="USER",
    account_id="account_id")
# Create API Key at organization level
org_level = harness.PlatformApiKey("org_level",
    identifier="test_apikey",
    name="test_apikey",
    parent_id="parent_id",
    apikey_type="USER",
    account_id="account_id",
    org_id="org_id")
# Create API Key at project level
project_level = harness.PlatformApiKey("project_level",
    identifier="test_apikey",
    name="test_apikey",
    parent_id="parent_id",
    apikey_type="USER",
    account_id="account_id",
    org_id="org_id",
    project_id="project_id")
Copy
package main

import (
	"github.com/pulumi/pulumi-harness/sdk/go/harness"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create API Key at account level
		_, err := harness.NewPlatformApiKey(ctx, "account_level", &harness.PlatformApiKeyArgs{
			Identifier: pulumi.String("test_apikey"),
			Name:       pulumi.String("test_apikey"),
			ParentId:   pulumi.String("parent_id"),
			ApikeyType: pulumi.String("USER"),
			AccountId:  pulumi.String("account_id"),
		})
		if err != nil {
			return err
		}
		// Create API Key at organization level
		_, err = harness.NewPlatformApiKey(ctx, "org_level", &harness.PlatformApiKeyArgs{
			Identifier: pulumi.String("test_apikey"),
			Name:       pulumi.String("test_apikey"),
			ParentId:   pulumi.String("parent_id"),
			ApikeyType: pulumi.String("USER"),
			AccountId:  pulumi.String("account_id"),
			OrgId:      pulumi.String("org_id"),
		})
		if err != nil {
			return err
		}
		// Create API Key at project level
		_, err = harness.NewPlatformApiKey(ctx, "project_level", &harness.PlatformApiKeyArgs{
			Identifier: pulumi.String("test_apikey"),
			Name:       pulumi.String("test_apikey"),
			ParentId:   pulumi.String("parent_id"),
			ApikeyType: pulumi.String("USER"),
			AccountId:  pulumi.String("account_id"),
			OrgId:      pulumi.String("org_id"),
			ProjectId:  pulumi.String("project_id"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Harness = Pulumi.Harness;

return await Deployment.RunAsync(() => 
{
    // Create API Key at account level
    var accountLevel = new Harness.PlatformApiKey("account_level", new()
    {
        Identifier = "test_apikey",
        Name = "test_apikey",
        ParentId = "parent_id",
        ApikeyType = "USER",
        AccountId = "account_id",
    });

    // Create API Key at organization level
    var orgLevel = new Harness.PlatformApiKey("org_level", new()
    {
        Identifier = "test_apikey",
        Name = "test_apikey",
        ParentId = "parent_id",
        ApikeyType = "USER",
        AccountId = "account_id",
        OrgId = "org_id",
    });

    // Create API Key at project level
    var projectLevel = new Harness.PlatformApiKey("project_level", new()
    {
        Identifier = "test_apikey",
        Name = "test_apikey",
        ParentId = "parent_id",
        ApikeyType = "USER",
        AccountId = "account_id",
        OrgId = "org_id",
        ProjectId = "project_id",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.harness.PlatformApiKey;
import com.pulumi.harness.PlatformApiKeyArgs;
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) {
        // Create API Key at account level
        var accountLevel = new PlatformApiKey("accountLevel", PlatformApiKeyArgs.builder()
            .identifier("test_apikey")
            .name("test_apikey")
            .parentId("parent_id")
            .apikeyType("USER")
            .accountId("account_id")
            .build());

        // Create API Key at organization level
        var orgLevel = new PlatformApiKey("orgLevel", PlatformApiKeyArgs.builder()
            .identifier("test_apikey")
            .name("test_apikey")
            .parentId("parent_id")
            .apikeyType("USER")
            .accountId("account_id")
            .orgId("org_id")
            .build());

        // Create API Key at project level
        var projectLevel = new PlatformApiKey("projectLevel", PlatformApiKeyArgs.builder()
            .identifier("test_apikey")
            .name("test_apikey")
            .parentId("parent_id")
            .apikeyType("USER")
            .accountId("account_id")
            .orgId("org_id")
            .projectId("project_id")
            .build());

    }
}
Copy
resources:
  # Create API Key at account level
  accountLevel:
    type: harness:PlatformApiKey
    name: account_level
    properties:
      identifier: test_apikey
      name: test_apikey
      parentId: parent_id
      apikeyType: USER
      accountId: account_id
  # Create API Key at organization level
  orgLevel:
    type: harness:PlatformApiKey
    name: org_level
    properties:
      identifier: test_apikey
      name: test_apikey
      parentId: parent_id
      apikeyType: USER
      accountId: account_id
      orgId: org_id
  # Create API Key at project level
  projectLevel:
    type: harness:PlatformApiKey
    name: project_level
    properties:
      identifier: test_apikey
      name: test_apikey
      parentId: parent_id
      apikeyType: USER
      accountId: account_id
      orgId: org_id
      projectId: project_id
Copy

Create PlatformApiKey Resource

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

Constructor syntax

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

@overload
def PlatformApiKey(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   account_id: Optional[str] = None,
                   apikey_type: Optional[str] = None,
                   identifier: Optional[str] = None,
                   parent_id: Optional[str] = None,
                   default_time_to_expire_token: Optional[int] = None,
                   description: Optional[str] = None,
                   name: Optional[str] = None,
                   org_id: Optional[str] = None,
                   project_id: Optional[str] = None,
                   tags: Optional[Sequence[str]] = None)
func NewPlatformApiKey(ctx *Context, name string, args PlatformApiKeyArgs, opts ...ResourceOption) (*PlatformApiKey, error)
public PlatformApiKey(string name, PlatformApiKeyArgs args, CustomResourceOptions? opts = null)
public PlatformApiKey(String name, PlatformApiKeyArgs args)
public PlatformApiKey(String name, PlatformApiKeyArgs args, CustomResourceOptions options)
type: harness:PlatformApiKey
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. PlatformApiKeyArgs
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. PlatformApiKeyArgs
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. PlatformApiKeyArgs
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. PlatformApiKeyArgs
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. PlatformApiKeyArgs
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 platformApiKeyResource = new Harness.PlatformApiKey("platformApiKeyResource", new()
{
    AccountId = "string",
    ApikeyType = "string",
    Identifier = "string",
    ParentId = "string",
    DefaultTimeToExpireToken = 0,
    Description = "string",
    Name = "string",
    OrgId = "string",
    ProjectId = "string",
    Tags = new[]
    {
        "string",
    },
});
Copy
example, err := harness.NewPlatformApiKey(ctx, "platformApiKeyResource", &harness.PlatformApiKeyArgs{
	AccountId:                pulumi.String("string"),
	ApikeyType:               pulumi.String("string"),
	Identifier:               pulumi.String("string"),
	ParentId:                 pulumi.String("string"),
	DefaultTimeToExpireToken: pulumi.Int(0),
	Description:              pulumi.String("string"),
	Name:                     pulumi.String("string"),
	OrgId:                    pulumi.String("string"),
	ProjectId:                pulumi.String("string"),
	Tags: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var platformApiKeyResource = new PlatformApiKey("platformApiKeyResource", PlatformApiKeyArgs.builder()
    .accountId("string")
    .apikeyType("string")
    .identifier("string")
    .parentId("string")
    .defaultTimeToExpireToken(0)
    .description("string")
    .name("string")
    .orgId("string")
    .projectId("string")
    .tags("string")
    .build());
Copy
platform_api_key_resource = harness.PlatformApiKey("platformApiKeyResource",
    account_id="string",
    apikey_type="string",
    identifier="string",
    parent_id="string",
    default_time_to_expire_token=0,
    description="string",
    name="string",
    org_id="string",
    project_id="string",
    tags=["string"])
Copy
const platformApiKeyResource = new harness.PlatformApiKey("platformApiKeyResource", {
    accountId: "string",
    apikeyType: "string",
    identifier: "string",
    parentId: "string",
    defaultTimeToExpireToken: 0,
    description: "string",
    name: "string",
    orgId: "string",
    projectId: "string",
    tags: ["string"],
});
Copy
type: harness:PlatformApiKey
properties:
    accountId: string
    apikeyType: string
    defaultTimeToExpireToken: 0
    description: string
    identifier: string
    name: string
    orgId: string
    parentId: string
    projectId: string
    tags:
        - string
Copy

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

AccountId This property is required. string
Account Identifier for the Entity
ApikeyType This property is required. string
Type of the API Key
Identifier
This property is required.
Changes to this property will trigger replacement.
string
Unique identifier of the resource.
ParentId This property is required. string
Parent Entity Identifier of the API Key
DefaultTimeToExpireToken int
Default expiration time of the Token within API Key
Description string
Description of the resource.
Name string
Name of the resource.
OrgId string
Unique identifier of the organization.
ProjectId string
Unique identifier of the project.
Tags List<string>
Tags to associate with the resource.
AccountId This property is required. string
Account Identifier for the Entity
ApikeyType This property is required. string
Type of the API Key
Identifier
This property is required.
Changes to this property will trigger replacement.
string
Unique identifier of the resource.
ParentId This property is required. string
Parent Entity Identifier of the API Key
DefaultTimeToExpireToken int
Default expiration time of the Token within API Key
Description string
Description of the resource.
Name string
Name of the resource.
OrgId string
Unique identifier of the organization.
ProjectId string
Unique identifier of the project.
Tags []string
Tags to associate with the resource.
accountId This property is required. String
Account Identifier for the Entity
apikeyType This property is required. String
Type of the API Key
identifier
This property is required.
Changes to this property will trigger replacement.
String
Unique identifier of the resource.
parentId This property is required. String
Parent Entity Identifier of the API Key
defaultTimeToExpireToken Integer
Default expiration time of the Token within API Key
description String
Description of the resource.
name String
Name of the resource.
orgId String
Unique identifier of the organization.
projectId String
Unique identifier of the project.
tags List<String>
Tags to associate with the resource.
accountId This property is required. string
Account Identifier for the Entity
apikeyType This property is required. string
Type of the API Key
identifier
This property is required.
Changes to this property will trigger replacement.
string
Unique identifier of the resource.
parentId This property is required. string
Parent Entity Identifier of the API Key
defaultTimeToExpireToken number
Default expiration time of the Token within API Key
description string
Description of the resource.
name string
Name of the resource.
orgId string
Unique identifier of the organization.
projectId string
Unique identifier of the project.
tags string[]
Tags to associate with the resource.
account_id This property is required. str
Account Identifier for the Entity
apikey_type This property is required. str
Type of the API Key
identifier
This property is required.
Changes to this property will trigger replacement.
str
Unique identifier of the resource.
parent_id This property is required. str
Parent Entity Identifier of the API Key
default_time_to_expire_token int
Default expiration time of the Token within API Key
description str
Description of the resource.
name str
Name of the resource.
org_id str
Unique identifier of the organization.
project_id str
Unique identifier of the project.
tags Sequence[str]
Tags to associate with the resource.
accountId This property is required. String
Account Identifier for the Entity
apikeyType This property is required. String
Type of the API Key
identifier
This property is required.
Changes to this property will trigger replacement.
String
Unique identifier of the resource.
parentId This property is required. String
Parent Entity Identifier of the API Key
defaultTimeToExpireToken Number
Default expiration time of the Token within API Key
description String
Description of the resource.
name String
Name of the resource.
orgId String
Unique identifier of the organization.
projectId String
Unique identifier of the project.
tags List<String>
Tags to associate with the resource.

Outputs

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

Get an existing PlatformApiKey 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?: PlatformApiKeyState, opts?: CustomResourceOptions): PlatformApiKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_id: Optional[str] = None,
        apikey_type: Optional[str] = None,
        default_time_to_expire_token: Optional[int] = None,
        description: Optional[str] = None,
        identifier: Optional[str] = None,
        name: Optional[str] = None,
        org_id: Optional[str] = None,
        parent_id: Optional[str] = None,
        project_id: Optional[str] = None,
        tags: Optional[Sequence[str]] = None) -> PlatformApiKey
func GetPlatformApiKey(ctx *Context, name string, id IDInput, state *PlatformApiKeyState, opts ...ResourceOption) (*PlatformApiKey, error)
public static PlatformApiKey Get(string name, Input<string> id, PlatformApiKeyState? state, CustomResourceOptions? opts = null)
public static PlatformApiKey get(String name, Output<String> id, PlatformApiKeyState state, CustomResourceOptions options)
resources:  _:    type: harness:PlatformApiKey    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:
AccountId string
Account Identifier for the Entity
ApikeyType string
Type of the API Key
DefaultTimeToExpireToken int
Default expiration time of the Token within API Key
Description string
Description of the resource.
Identifier Changes to this property will trigger replacement. string
Unique identifier of the resource.
Name string
Name of the resource.
OrgId string
Unique identifier of the organization.
ParentId string
Parent Entity Identifier of the API Key
ProjectId string
Unique identifier of the project.
Tags List<string>
Tags to associate with the resource.
AccountId string
Account Identifier for the Entity
ApikeyType string
Type of the API Key
DefaultTimeToExpireToken int
Default expiration time of the Token within API Key
Description string
Description of the resource.
Identifier Changes to this property will trigger replacement. string
Unique identifier of the resource.
Name string
Name of the resource.
OrgId string
Unique identifier of the organization.
ParentId string
Parent Entity Identifier of the API Key
ProjectId string
Unique identifier of the project.
Tags []string
Tags to associate with the resource.
accountId String
Account Identifier for the Entity
apikeyType String
Type of the API Key
defaultTimeToExpireToken Integer
Default expiration time of the Token within API Key
description String
Description of the resource.
identifier Changes to this property will trigger replacement. String
Unique identifier of the resource.
name String
Name of the resource.
orgId String
Unique identifier of the organization.
parentId String
Parent Entity Identifier of the API Key
projectId String
Unique identifier of the project.
tags List<String>
Tags to associate with the resource.
accountId string
Account Identifier for the Entity
apikeyType string
Type of the API Key
defaultTimeToExpireToken number
Default expiration time of the Token within API Key
description string
Description of the resource.
identifier Changes to this property will trigger replacement. string
Unique identifier of the resource.
name string
Name of the resource.
orgId string
Unique identifier of the organization.
parentId string
Parent Entity Identifier of the API Key
projectId string
Unique identifier of the project.
tags string[]
Tags to associate with the resource.
account_id str
Account Identifier for the Entity
apikey_type str
Type of the API Key
default_time_to_expire_token int
Default expiration time of the Token within API Key
description str
Description of the resource.
identifier Changes to this property will trigger replacement. str
Unique identifier of the resource.
name str
Name of the resource.
org_id str
Unique identifier of the organization.
parent_id str
Parent Entity Identifier of the API Key
project_id str
Unique identifier of the project.
tags Sequence[str]
Tags to associate with the resource.
accountId String
Account Identifier for the Entity
apikeyType String
Type of the API Key
defaultTimeToExpireToken Number
Default expiration time of the Token within API Key
description String
Description of the resource.
identifier Changes to this property will trigger replacement. String
Unique identifier of the resource.
name String
Name of the resource.
orgId String
Unique identifier of the organization.
parentId String
Parent Entity Identifier of the API Key
projectId String
Unique identifier of the project.
tags List<String>
Tags to associate with the resource.

Import

Import account level apikey

$ pulumi import harness:index/platformApiKey:PlatformApiKey harness_platform_apikey <parent_id>/<apikey_id>/<apikey_type>
Copy

Import org level apikey

$ pulumi import harness:index/platformApiKey:PlatformApiKey harness_platform_apikey <org_id>/<parent_id>/<apikey_id>/<apikey_type>
Copy

Import project level apikey

$ pulumi import harness:index/platformApiKey:PlatformApiKey harness_platform_apikey <org_id>/<project_id>/<parent_id>/<apikey_id>/<apikey_type>
Copy

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

Package Details

Repository
harness pulumi/pulumi-harness
License
Apache-2.0
Notes
This Pulumi package is based on the harness Terraform Provider.