mongodbatlas.ProjectApiKey
Explore with Pulumi AI
Example Usage
Create And Assign PAK Together
import * as pulumi from "@pulumi/pulumi";
import * as mongodbatlas from "@pulumi/mongodbatlas";
const test = new mongodbatlas.ProjectApiKey("test", {
description: "Description of your API key",
projectAssignments: [{
projectId: "64259ee860c43338194b0f8e",
roleNames: ["GROUP_OWNER"],
}],
});
import pulumi
import pulumi_mongodbatlas as mongodbatlas
test = mongodbatlas.ProjectApiKey("test",
description="Description of your API key",
project_assignments=[{
"project_id": "64259ee860c43338194b0f8e",
"role_names": ["GROUP_OWNER"],
}])
package main
import (
"github.com/pulumi/pulumi-mongodbatlas/sdk/v3/go/mongodbatlas"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := mongodbatlas.NewProjectApiKey(ctx, "test", &mongodbatlas.ProjectApiKeyArgs{
Description: pulumi.String("Description of your API key"),
ProjectAssignments: mongodbatlas.ProjectApiKeyProjectAssignmentArray{
&mongodbatlas.ProjectApiKeyProjectAssignmentArgs{
ProjectId: pulumi.String("64259ee860c43338194b0f8e"),
RoleNames: pulumi.StringArray{
pulumi.String("GROUP_OWNER"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mongodbatlas = Pulumi.Mongodbatlas;
return await Deployment.RunAsync(() =>
{
var test = new Mongodbatlas.ProjectApiKey("test", new()
{
Description = "Description of your API key",
ProjectAssignments = new[]
{
new Mongodbatlas.Inputs.ProjectApiKeyProjectAssignmentArgs
{
ProjectId = "64259ee860c43338194b0f8e",
RoleNames = new[]
{
"GROUP_OWNER",
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mongodbatlas.ProjectApiKey;
import com.pulumi.mongodbatlas.ProjectApiKeyArgs;
import com.pulumi.mongodbatlas.inputs.ProjectApiKeyProjectAssignmentArgs;
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 test = new ProjectApiKey("test", ProjectApiKeyArgs.builder()
.description("Description of your API key")
.projectAssignments(ProjectApiKeyProjectAssignmentArgs.builder()
.projectId("64259ee860c43338194b0f8e")
.roleNames("GROUP_OWNER")
.build())
.build());
}
}
resources:
test:
type: mongodbatlas:ProjectApiKey
properties:
description: Description of your API key
projectAssignments:
- projectId: 64259ee860c43338194b0f8e
roleNames:
- GROUP_OWNER
Create And Assign PAK To Multiple Projects
import * as pulumi from "@pulumi/pulumi";
import * as mongodbatlas from "@pulumi/mongodbatlas";
const test = new mongodbatlas.ProjectApiKey("test", {
description: "Description of your API key",
projectAssignments: [
{
projectId: "64259ee860c43338194b0f8e",
roleNames: [
"GROUP_READ_ONLY",
"GROUP_OWNER",
],
},
{
projectId: "74259ee860c43338194b0f8e",
roleNames: ["GROUP_READ_ONLY"],
},
],
});
import pulumi
import pulumi_mongodbatlas as mongodbatlas
test = mongodbatlas.ProjectApiKey("test",
description="Description of your API key",
project_assignments=[
{
"project_id": "64259ee860c43338194b0f8e",
"role_names": [
"GROUP_READ_ONLY",
"GROUP_OWNER",
],
},
{
"project_id": "74259ee860c43338194b0f8e",
"role_names": ["GROUP_READ_ONLY"],
},
])
package main
import (
"github.com/pulumi/pulumi-mongodbatlas/sdk/v3/go/mongodbatlas"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := mongodbatlas.NewProjectApiKey(ctx, "test", &mongodbatlas.ProjectApiKeyArgs{
Description: pulumi.String("Description of your API key"),
ProjectAssignments: mongodbatlas.ProjectApiKeyProjectAssignmentArray{
&mongodbatlas.ProjectApiKeyProjectAssignmentArgs{
ProjectId: pulumi.String("64259ee860c43338194b0f8e"),
RoleNames: pulumi.StringArray{
pulumi.String("GROUP_READ_ONLY"),
pulumi.String("GROUP_OWNER"),
},
},
&mongodbatlas.ProjectApiKeyProjectAssignmentArgs{
ProjectId: pulumi.String("74259ee860c43338194b0f8e"),
RoleNames: pulumi.StringArray{
pulumi.String("GROUP_READ_ONLY"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mongodbatlas = Pulumi.Mongodbatlas;
return await Deployment.RunAsync(() =>
{
var test = new Mongodbatlas.ProjectApiKey("test", new()
{
Description = "Description of your API key",
ProjectAssignments = new[]
{
new Mongodbatlas.Inputs.ProjectApiKeyProjectAssignmentArgs
{
ProjectId = "64259ee860c43338194b0f8e",
RoleNames = new[]
{
"GROUP_READ_ONLY",
"GROUP_OWNER",
},
},
new Mongodbatlas.Inputs.ProjectApiKeyProjectAssignmentArgs
{
ProjectId = "74259ee860c43338194b0f8e",
RoleNames = new[]
{
"GROUP_READ_ONLY",
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mongodbatlas.ProjectApiKey;
import com.pulumi.mongodbatlas.ProjectApiKeyArgs;
import com.pulumi.mongodbatlas.inputs.ProjectApiKeyProjectAssignmentArgs;
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 test = new ProjectApiKey("test", ProjectApiKeyArgs.builder()
.description("Description of your API key")
.projectAssignments(
ProjectApiKeyProjectAssignmentArgs.builder()
.projectId("64259ee860c43338194b0f8e")
.roleNames(
"GROUP_READ_ONLY",
"GROUP_OWNER")
.build(),
ProjectApiKeyProjectAssignmentArgs.builder()
.projectId("74259ee860c43338194b0f8e")
.roleNames("GROUP_READ_ONLY")
.build())
.build());
}
}
resources:
test:
type: mongodbatlas:ProjectApiKey
properties:
description: Description of your API key
projectAssignments:
- projectId: 64259ee860c43338194b0f8e
roleNames:
- GROUP_READ_ONLY
- GROUP_OWNER
- projectId: 74259ee860c43338194b0f8e
roleNames:
- GROUP_READ_ONLY
Create ProjectApiKey Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ProjectApiKey(name: string, args: ProjectApiKeyArgs, opts?: CustomResourceOptions);
@overload
def ProjectApiKey(resource_name: str,
args: ProjectApiKeyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ProjectApiKey(resource_name: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
project_assignments: Optional[Sequence[ProjectApiKeyProjectAssignmentArgs]] = None)
func NewProjectApiKey(ctx *Context, name string, args ProjectApiKeyArgs, opts ...ResourceOption) (*ProjectApiKey, error)
public ProjectApiKey(string name, ProjectApiKeyArgs args, CustomResourceOptions? opts = null)
public ProjectApiKey(String name, ProjectApiKeyArgs args)
public ProjectApiKey(String name, ProjectApiKeyArgs args, CustomResourceOptions options)
type: mongodbatlas:ProjectApiKey
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 ProjectApiKeyArgs
- 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 ProjectApiKeyArgs
- 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 ProjectApiKeyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ProjectApiKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ProjectApiKeyArgs
- 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 projectApiKeyResource = new Mongodbatlas.ProjectApiKey("projectApiKeyResource", new()
{
Description = "string",
ProjectAssignments = new[]
{
new Mongodbatlas.Inputs.ProjectApiKeyProjectAssignmentArgs
{
ProjectId = "string",
RoleNames = new[]
{
"string",
},
},
},
});
example, err := mongodbatlas.NewProjectApiKey(ctx, "projectApiKeyResource", &mongodbatlas.ProjectApiKeyArgs{
Description: pulumi.String("string"),
ProjectAssignments: mongodbatlas.ProjectApiKeyProjectAssignmentArray{
&mongodbatlas.ProjectApiKeyProjectAssignmentArgs{
ProjectId: pulumi.String("string"),
RoleNames: pulumi.StringArray{
pulumi.String("string"),
},
},
},
})
var projectApiKeyResource = new ProjectApiKey("projectApiKeyResource", ProjectApiKeyArgs.builder()
.description("string")
.projectAssignments(ProjectApiKeyProjectAssignmentArgs.builder()
.projectId("string")
.roleNames("string")
.build())
.build());
project_api_key_resource = mongodbatlas.ProjectApiKey("projectApiKeyResource",
description="string",
project_assignments=[{
"project_id": "string",
"role_names": ["string"],
}])
const projectApiKeyResource = new mongodbatlas.ProjectApiKey("projectApiKeyResource", {
description: "string",
projectAssignments: [{
projectId: "string",
roleNames: ["string"],
}],
});
type: mongodbatlas:ProjectApiKey
properties:
description: string
projectAssignments:
- projectId: string
roleNames:
- string
ProjectApiKey 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 ProjectApiKey resource accepts the following input properties:
- Description string
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- Project
Assignments List<ProjectApi Key Project Assignment>
- Description string
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- Project
Assignments []ProjectApi Key Project Assignment Args
- description String
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- project
Assignments List<ProjectApi Key Project Assignment>
- description string
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- project
Assignments ProjectApi Key Project Assignment[]
- description str
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- project_
assignments Sequence[ProjectApi Key Project Assignment Args]
- description String
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- project
Assignments List<Property Map>
Outputs
All input properties are implicitly available as output properties. Additionally, the ProjectApiKey resource produces the following output properties:
- Api
Key stringId - Unique identifier for this Project API key.
- Id string
- The provider-assigned unique ID for this managed resource.
- Private
Key string - Public
Key string
- Api
Key stringId - Unique identifier for this Project API key.
- Id string
- The provider-assigned unique ID for this managed resource.
- Private
Key string - Public
Key string
- api
Key StringId - Unique identifier for this Project API key.
- id String
- The provider-assigned unique ID for this managed resource.
- private
Key String - public
Key String
- api
Key stringId - Unique identifier for this Project API key.
- id string
- The provider-assigned unique ID for this managed resource.
- private
Key string - public
Key string
- api_
key_ strid - Unique identifier for this Project API key.
- id str
- The provider-assigned unique ID for this managed resource.
- private_
key str - public_
key str
- api
Key StringId - Unique identifier for this Project API key.
- id String
- The provider-assigned unique ID for this managed resource.
- private
Key String - public
Key String
Look up Existing ProjectApiKey Resource
Get an existing ProjectApiKey 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?: ProjectApiKeyState, opts?: CustomResourceOptions): ProjectApiKey
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
api_key_id: Optional[str] = None,
description: Optional[str] = None,
private_key: Optional[str] = None,
project_assignments: Optional[Sequence[ProjectApiKeyProjectAssignmentArgs]] = None,
public_key: Optional[str] = None) -> ProjectApiKey
func GetProjectApiKey(ctx *Context, name string, id IDInput, state *ProjectApiKeyState, opts ...ResourceOption) (*ProjectApiKey, error)
public static ProjectApiKey Get(string name, Input<string> id, ProjectApiKeyState? state, CustomResourceOptions? opts = null)
public static ProjectApiKey get(String name, Output<String> id, ProjectApiKeyState 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
Key stringId - Unique identifier for this Project API key.
- Description string
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- Private
Key string - Project
Assignments List<ProjectApi Key Project Assignment> - Public
Key string
- Api
Key stringId - Unique identifier for this Project API key.
- Description string
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- Private
Key string - Project
Assignments []ProjectApi Key Project Assignment Args - Public
Key string
- api
Key StringId - Unique identifier for this Project API key.
- description String
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- private
Key String - project
Assignments List<ProjectApi Key Project Assignment> - public
Key String
- api
Key stringId - Unique identifier for this Project API key.
- description string
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- private
Key string - project
Assignments ProjectApi Key Project Assignment[] - public
Key string
- api_
key_ strid - Unique identifier for this Project API key.
- description str
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- private_
key str - project_
assignments Sequence[ProjectApi Key Project Assignment Args] - public_
key str
- api
Key StringId - Unique identifier for this Project API key.
- description String
Description of this Project API key.
NOTE: Project created by API Keys must belong to an existing organization.
- private
Key String - project
Assignments List<Property Map> - public
Key String
Supporting Types
ProjectApiKeyProjectAssignment, ProjectApiKeyProjectAssignmentArgs
- Project
Id string - Project ID to assign to Access Key
- Role
Names List<string> - List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The MongoDB Documentation describes the valid roles that can be assigned.
- Project
Id string - Project ID to assign to Access Key
- Role
Names []string - List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The MongoDB Documentation describes the valid roles that can be assigned.
- project
Id String - Project ID to assign to Access Key
- role
Names List<String> - List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The MongoDB Documentation describes the valid roles that can be assigned.
- project
Id string - Project ID to assign to Access Key
- role
Names string[] - List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The MongoDB Documentation describes the valid roles that can be assigned.
- project_
id str - Project ID to assign to Access Key
- role_
names Sequence[str] - List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The MongoDB Documentation describes the valid roles that can be assigned.
- project
Id String - Project ID to assign to Access Key
- role
Names List<String> - List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The MongoDB Documentation describes the valid roles that can be assigned.
Import
API Keys must be imported using project ID, API Key ID e.g.
$ pulumi import mongodbatlas:index/projectApiKey:ProjectApiKey test 5d09d6a59ccf6445652a444a-6576974933969669
See MongoDB Atlas API - API Key - Documentation for more information.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- MongoDB Atlas pulumi/pulumi-mongodbatlas
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
mongodbatlas
Terraform Provider.