mongodbatlas.ApiKeyProjectAssignment
Explore with Pulumi AI
# Resource: mongodbatlas.ApiKeyProjectAssignment
mongodbatlas.ApiKeyProjectAssignment
provides an API Key Project Assignment resource. The resource lets you create, edit, and delete Organization API keys assignments to projects.
Example Usage
S
import * as pulumi from "@pulumi/pulumi";
import * as mongodbatlas from "@pulumi/mongodbatlas";
const _this = new mongodbatlas.ApiKey("this", {
orgId: orgId,
description: "Test API Key",
roleNames: ["ORG_READ_ONLY"],
});
const firstProject = new mongodbatlas.Project("first_project", {
name: "First Project",
orgId: orgId,
});
const secondProject = new mongodbatlas.Project("second_project", {
name: "Second Project",
orgId: orgId,
});
const firstAssignment = new mongodbatlas.ApiKeyProjectAssignment("first_assignment", {
projectId: firstProject.id,
apiKeyId: _this.apiKeyId,
roles: ["GROUP_OWNER"],
});
const secondAssignment = new mongodbatlas.ApiKeyProjectAssignment("second_assignment", {
projectId: secondProject.id,
apiKeyId: _this.apiKeyId,
roles: ["GROUP_OWNER"],
});
// Add IP Access List Entry to Programmatic API Key
const thisAccessListApiKey = new mongodbatlas.AccessListApiKey("this", {
orgId: orgId,
cidrBlock: "0.0.0.0/1",
apiKeyId: _this.apiKeyId,
});
import pulumi
import pulumi_mongodbatlas as mongodbatlas
this = mongodbatlas.ApiKey("this",
org_id=org_id,
description="Test API Key",
role_names=["ORG_READ_ONLY"])
first_project = mongodbatlas.Project("first_project",
name="First Project",
org_id=org_id)
second_project = mongodbatlas.Project("second_project",
name="Second Project",
org_id=org_id)
first_assignment = mongodbatlas.ApiKeyProjectAssignment("first_assignment",
project_id=first_project.id,
api_key_id=this.api_key_id,
roles=["GROUP_OWNER"])
second_assignment = mongodbatlas.ApiKeyProjectAssignment("second_assignment",
project_id=second_project.id,
api_key_id=this.api_key_id,
roles=["GROUP_OWNER"])
# Add IP Access List Entry to Programmatic API Key
this_access_list_api_key = mongodbatlas.AccessListApiKey("this",
org_id=org_id,
cidr_block="0.0.0.0/1",
api_key_id=this.api_key_id)
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 {
this, err := mongodbatlas.NewApiKey(ctx, "this", &mongodbatlas.ApiKeyArgs{
OrgId: pulumi.Any(orgId),
Description: pulumi.String("Test API Key"),
RoleNames: pulumi.StringArray{
pulumi.String("ORG_READ_ONLY"),
},
})
if err != nil {
return err
}
firstProject, err := mongodbatlas.NewProject(ctx, "first_project", &mongodbatlas.ProjectArgs{
Name: pulumi.String("First Project"),
OrgId: pulumi.Any(orgId),
})
if err != nil {
return err
}
secondProject, err := mongodbatlas.NewProject(ctx, "second_project", &mongodbatlas.ProjectArgs{
Name: pulumi.String("Second Project"),
OrgId: pulumi.Any(orgId),
})
if err != nil {
return err
}
_, err = mongodbatlas.NewApiKeyProjectAssignment(ctx, "first_assignment", &mongodbatlas.ApiKeyProjectAssignmentArgs{
ProjectId: firstProject.ID(),
ApiKeyId: this.ApiKeyId,
Roles: pulumi.StringArray{
pulumi.String("GROUP_OWNER"),
},
})
if err != nil {
return err
}
_, err = mongodbatlas.NewApiKeyProjectAssignment(ctx, "second_assignment", &mongodbatlas.ApiKeyProjectAssignmentArgs{
ProjectId: secondProject.ID(),
ApiKeyId: this.ApiKeyId,
Roles: pulumi.StringArray{
pulumi.String("GROUP_OWNER"),
},
})
if err != nil {
return err
}
// Add IP Access List Entry to Programmatic API Key
_, err = mongodbatlas.NewAccessListApiKey(ctx, "this", &mongodbatlas.AccessListApiKeyArgs{
OrgId: pulumi.Any(orgId),
CidrBlock: pulumi.String("0.0.0.0/1"),
ApiKeyId: this.ApiKeyId,
})
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 @this = new Mongodbatlas.ApiKey("this", new()
{
OrgId = orgId,
Description = "Test API Key",
RoleNames = new[]
{
"ORG_READ_ONLY",
},
});
var firstProject = new Mongodbatlas.Project("first_project", new()
{
Name = "First Project",
OrgId = orgId,
});
var secondProject = new Mongodbatlas.Project("second_project", new()
{
Name = "Second Project",
OrgId = orgId,
});
var firstAssignment = new Mongodbatlas.ApiKeyProjectAssignment("first_assignment", new()
{
ProjectId = firstProject.Id,
ApiKeyId = @this.ApiKeyId,
Roles = new[]
{
"GROUP_OWNER",
},
});
var secondAssignment = new Mongodbatlas.ApiKeyProjectAssignment("second_assignment", new()
{
ProjectId = secondProject.Id,
ApiKeyId = @this.ApiKeyId,
Roles = new[]
{
"GROUP_OWNER",
},
});
// Add IP Access List Entry to Programmatic API Key
var thisAccessListApiKey = new Mongodbatlas.AccessListApiKey("this", new()
{
OrgId = orgId,
CidrBlock = "0.0.0.0/1",
ApiKeyId = @this.ApiKeyId,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mongodbatlas.ApiKey;
import com.pulumi.mongodbatlas.ApiKeyArgs;
import com.pulumi.mongodbatlas.Project;
import com.pulumi.mongodbatlas.ProjectArgs;
import com.pulumi.mongodbatlas.ApiKeyProjectAssignment;
import com.pulumi.mongodbatlas.ApiKeyProjectAssignmentArgs;
import com.pulumi.mongodbatlas.AccessListApiKey;
import com.pulumi.mongodbatlas.AccessListApiKeyArgs;
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 this_ = new ApiKey("this", ApiKeyArgs.builder()
.orgId(orgId)
.description("Test API Key")
.roleNames("ORG_READ_ONLY")
.build());
var firstProject = new Project("firstProject", ProjectArgs.builder()
.name("First Project")
.orgId(orgId)
.build());
var secondProject = new Project("secondProject", ProjectArgs.builder()
.name("Second Project")
.orgId(orgId)
.build());
var firstAssignment = new ApiKeyProjectAssignment("firstAssignment", ApiKeyProjectAssignmentArgs.builder()
.projectId(firstProject.id())
.apiKeyId(this_.apiKeyId())
.roles("GROUP_OWNER")
.build());
var secondAssignment = new ApiKeyProjectAssignment("secondAssignment", ApiKeyProjectAssignmentArgs.builder()
.projectId(secondProject.id())
.apiKeyId(this_.apiKeyId())
.roles("GROUP_OWNER")
.build());
// Add IP Access List Entry to Programmatic API Key
var thisAccessListApiKey = new AccessListApiKey("thisAccessListApiKey", AccessListApiKeyArgs.builder()
.orgId(orgId)
.cidrBlock("0.0.0.0/1")
.apiKeyId(this_.apiKeyId())
.build());
}
}
resources:
this:
type: mongodbatlas:ApiKey
properties:
orgId: ${orgId}
description: Test API Key
roleNames:
- ORG_READ_ONLY
firstProject:
type: mongodbatlas:Project
name: first_project
properties:
name: First Project
orgId: ${orgId}
secondProject:
type: mongodbatlas:Project
name: second_project
properties:
name: Second Project
orgId: ${orgId}
firstAssignment:
type: mongodbatlas:ApiKeyProjectAssignment
name: first_assignment
properties:
projectId: ${firstProject.id}
apiKeyId: ${this.apiKeyId}
roles:
- GROUP_OWNER
secondAssignment:
type: mongodbatlas:ApiKeyProjectAssignment
name: second_assignment
properties:
projectId: ${secondProject.id}
apiKeyId: ${this.apiKeyId}
roles:
- GROUP_OWNER
# Add IP Access List Entry to Programmatic API Key
thisAccessListApiKey:
type: mongodbatlas:AccessListApiKey
name: this
properties:
orgId: ${orgId}
cidrBlock: 0.0.0.0/1
apiKeyId: ${this.apiKeyId}
Create ApiKeyProjectAssignment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ApiKeyProjectAssignment(name: string, args: ApiKeyProjectAssignmentArgs, opts?: CustomResourceOptions);
@overload
def ApiKeyProjectAssignment(resource_name: str,
args: ApiKeyProjectAssignmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ApiKeyProjectAssignment(resource_name: str,
opts: Optional[ResourceOptions] = None,
api_key_id: Optional[str] = None,
project_id: Optional[str] = None,
roles: Optional[Sequence[str]] = None)
func NewApiKeyProjectAssignment(ctx *Context, name string, args ApiKeyProjectAssignmentArgs, opts ...ResourceOption) (*ApiKeyProjectAssignment, error)
public ApiKeyProjectAssignment(string name, ApiKeyProjectAssignmentArgs args, CustomResourceOptions? opts = null)
public ApiKeyProjectAssignment(String name, ApiKeyProjectAssignmentArgs args)
public ApiKeyProjectAssignment(String name, ApiKeyProjectAssignmentArgs args, CustomResourceOptions options)
type: mongodbatlas:ApiKeyProjectAssignment
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 ApiKeyProjectAssignmentArgs
- 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 ApiKeyProjectAssignmentArgs
- 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 ApiKeyProjectAssignmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ApiKeyProjectAssignmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ApiKeyProjectAssignmentArgs
- 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 apiKeyProjectAssignmentResource = new Mongodbatlas.ApiKeyProjectAssignment("apiKeyProjectAssignmentResource", new()
{
ApiKeyId = "string",
ProjectId = "string",
Roles = new[]
{
"string",
},
});
example, err := mongodbatlas.NewApiKeyProjectAssignment(ctx, "apiKeyProjectAssignmentResource", &mongodbatlas.ApiKeyProjectAssignmentArgs{
ApiKeyId: pulumi.String("string"),
ProjectId: pulumi.String("string"),
Roles: pulumi.StringArray{
pulumi.String("string"),
},
})
var apiKeyProjectAssignmentResource = new ApiKeyProjectAssignment("apiKeyProjectAssignmentResource", ApiKeyProjectAssignmentArgs.builder()
.apiKeyId("string")
.projectId("string")
.roles("string")
.build());
api_key_project_assignment_resource = mongodbatlas.ApiKeyProjectAssignment("apiKeyProjectAssignmentResource",
api_key_id="string",
project_id="string",
roles=["string"])
const apiKeyProjectAssignmentResource = new mongodbatlas.ApiKeyProjectAssignment("apiKeyProjectAssignmentResource", {
apiKeyId: "string",
projectId: "string",
roles: ["string"],
});
type: mongodbatlas:ApiKeyProjectAssignment
properties:
apiKeyId: string
projectId: string
roles:
- string
ApiKeyProjectAssignment 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 ApiKeyProjectAssignment resource accepts the following input properties:
- Api
Key stringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- Project
Id string - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- Roles List<string>
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- Api
Key stringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- Project
Id string - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- Roles []string
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api
Key StringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project
Id String - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles List<String>
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api
Key stringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project
Id string - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles string[]
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api_
key_ strid - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project_
id str - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles Sequence[str]
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api
Key StringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project
Id String - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles List<String>
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
Outputs
All input properties are implicitly available as output properties. Additionally, the ApiKeyProjectAssignment 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 ApiKeyProjectAssignment Resource
Get an existing ApiKeyProjectAssignment 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?: ApiKeyProjectAssignmentState, opts?: CustomResourceOptions): ApiKeyProjectAssignment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
api_key_id: Optional[str] = None,
project_id: Optional[str] = None,
roles: Optional[Sequence[str]] = None) -> ApiKeyProjectAssignment
func GetApiKeyProjectAssignment(ctx *Context, name string, id IDInput, state *ApiKeyProjectAssignmentState, opts ...ResourceOption) (*ApiKeyProjectAssignment, error)
public static ApiKeyProjectAssignment Get(string name, Input<string> id, ApiKeyProjectAssignmentState? state, CustomResourceOptions? opts = null)
public static ApiKeyProjectAssignment get(String name, Output<String> id, ApiKeyProjectAssignmentState state, CustomResourceOptions options)
resources: _: type: mongodbatlas:ApiKeyProjectAssignment get: 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.
- Api
Key stringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- Project
Id string - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- Roles List<string>
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- Api
Key stringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- Project
Id string - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- Roles []string
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api
Key StringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project
Id String - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles List<String>
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api
Key stringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project
Id string - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles string[]
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api_
key_ strid - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project_
id str - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles Sequence[str]
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
- api
Key StringId - Unique 24-hexadecimal digit string that identifies this organization API key that you want to assign to one project.
- project
Id String - Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.
- roles List<String>
- Human-readable label that identifies the collection of privileges that MongoDB Cloud grants a specific API key, MongoDB Cloud user, or MongoDB Cloud team. These roles include only the specific project-level roles.
Import
API Key Project Assignment resource can be imported using the project ID and API key ID, in the format {PROJECT_ID}/{API_KEY_ID}
, e.g.
terraform import mongodbatlas_api_key_project_assignment.test 65def6ce0f722a1507105aa5/66f1c018dba9c04e7dcfaf36
For more information see: MongoDB Atlas API - Programmatic API Keys Project Assignment Documentation.
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.