Skip to content

Commit 97dcb09

Browse files
committed
feat: openai_project_api_key resource
1 parent 608a1a8 commit 97dcb09

File tree

9 files changed

+2188
-112
lines changed

9 files changed

+2188
-112
lines changed

docs/resources/project_api_key.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "openai_project_api_key Resource - terraform-provider-openai"
4+
subcategory: ""
5+
description: |-
6+
Project API key resource.
7+
---
8+
9+
# openai_project_api_key (Resource)
10+
11+
Project API key resource.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Create an API key for the default project
17+
resource "openai_project_api_key" "example" {
18+
organization_id = "org-000000000000000000000000"
19+
service_account_id = "my-service-account"
20+
}
21+
22+
# Create an API key for a specific project
23+
resource "openai_project_api_key" "example" {
24+
organization_id = "org-000000000000000000000000"
25+
project_id = "proj_000000000000000000000000"
26+
service_account_id = "my-service-account"
27+
}
28+
```
29+
30+
<!-- schema generated by tfplugindocs -->
31+
## Schema
32+
33+
### Required
34+
35+
- `organization_id` (String) The ID of the organization to which the project belongs.
36+
- `service_account_id` (String) The ID of the service account to which the API key belongs. IDs can include letters, numbers, and hyphens.
37+
38+
### Optional
39+
40+
- `name` (String) The name of the API key.
41+
- `project_id` (String) The ID of the project. If not set, the default project will be used.
42+
- `scopes` (Set of String) The scopes of the API key. If not set, all scopes will be used.
43+
44+
### Read-Only
45+
46+
- `created` (Number) The timestamp when the API key was created.
47+
- `id` (String, Sensitive) The API key.
48+
- `redacted_key` (String, Sensitive) The redacted API key.
49+
50+
## Import
51+
52+
Import is supported using the following syntax:
53+
54+
```shell
55+
# Import an existing API key for the default project
56+
terraform import openai_project_api_key.example organisation-id/secret-key
57+
58+
# Example
59+
terraform import openai_project_api_key.example org-000000000000000000000000/sk-my-secret-key-xxxxx
60+
61+
# Import an existing API key for a specific project
62+
terraform import openai_project_api_key.example organisation-id/project-id/secret-key
63+
64+
# Example
65+
terraform import openai_project_api_key.example org-000000000000000000000000/proj_000000000000000000000000/sk-my-secret-key-xxxxx
66+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Import an existing API key for the default project
2+
terraform import openai_project_api_key.example organisation-id/secret-key
3+
4+
# Example
5+
terraform import openai_project_api_key.example org-000000000000000000000000/sk-my-secret-key-xxxxx
6+
7+
# Import an existing API key for a specific project
8+
terraform import openai_project_api_key.example organisation-id/project-id/secret-key
9+
10+
# Example
11+
terraform import openai_project_api_key.example org-000000000000000000000000/proj_000000000000000000000000/sk-my-secret-key-xxxxx
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Create an API key for the default project
2+
resource "openai_project_api_key" "example" {
3+
organization_id = "org-000000000000000000000000"
4+
service_account_id = "my-service-account"
5+
}
6+
7+
# Create an API key for a specific project
8+
resource "openai_project_api_key" "example" {
9+
organization_id = "org-000000000000000000000000"
10+
project_id = "proj_000000000000000000000000"
11+
service_account_id = "my-service-account"
12+
}

0 commit comments

Comments
 (0)