1. Packages
  2. MongoDB Atlas
  3. API Docs
  4. getProjectApiKey
MongoDB Atlas v3.16.2 published on Friday, Jun 21, 2024 by Pulumi

mongodbatlas.getProjectApiKey

Explore with Pulumi AI

mongodbatlas logo
MongoDB Atlas v3.16.2 published on Friday, Jun 21, 2024 by Pulumi

    Example Usage

    Using project_id and api_key_id attribute to query

    import * as pulumi from "@pulumi/pulumi";
    import * as mongodbatlas from "@pulumi/mongodbatlas";
    
    const testProjectApiKey = new mongodbatlas.ProjectApiKey("test", {
        description: "Description of your API key",
        projectAssignments: [{
            projectId: "64259ee860c43338194b0f8e",
            roleNames: ["GROUP_READ_ONLY"],
        }],
    });
    const test = mongodbatlas.getProjectApiKey({
        projectId: "64259ee860c43338194b0f8e",
        apiKeyId: testMongodbatlasApiKey.apiKeyId,
    });
    
    import pulumi
    import pulumi_mongodbatlas as mongodbatlas
    
    test_project_api_key = mongodbatlas.ProjectApiKey("test",
        description="Description of your API key",
        project_assignments=[mongodbatlas.ProjectApiKeyProjectAssignmentArgs(
            project_id="64259ee860c43338194b0f8e",
            role_names=["GROUP_READ_ONLY"],
        )])
    test = mongodbatlas.get_project_api_key(project_id="64259ee860c43338194b0f8e",
        api_key_id=test_mongodbatlas_api_key["apiKeyId"])
    
    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"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = mongodbatlas.LookupProjectApiKey(ctx, &mongodbatlas.LookupProjectApiKeyArgs{
    			ProjectId: "64259ee860c43338194b0f8e",
    			ApiKeyId:  testMongodbatlasApiKey.ApiKeyId,
    		}, nil)
    		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 testProjectApiKey = new Mongodbatlas.ProjectApiKey("test", new()
        {
            Description = "Description of your API key",
            ProjectAssignments = new[]
            {
                new Mongodbatlas.Inputs.ProjectApiKeyProjectAssignmentArgs
                {
                    ProjectId = "64259ee860c43338194b0f8e",
                    RoleNames = new[]
                    {
                        "GROUP_READ_ONLY",
                    },
                },
            },
        });
    
        var test = Mongodbatlas.GetProjectApiKey.Invoke(new()
        {
            ProjectId = "64259ee860c43338194b0f8e",
            ApiKeyId = testMongodbatlasApiKey.ApiKeyId,
        });
    
    });
    
    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 com.pulumi.mongodbatlas.MongodbatlasFunctions;
    import com.pulumi.mongodbatlas.inputs.GetProjectApiKeyArgs;
    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 testProjectApiKey = new ProjectApiKey("testProjectApiKey", ProjectApiKeyArgs.builder()
                .description("Description of your API key")
                .projectAssignments(ProjectApiKeyProjectAssignmentArgs.builder()
                    .projectId("64259ee860c43338194b0f8e")
                    .roleNames("GROUP_READ_ONLY")
                    .build())
                .build());
    
            final var test = MongodbatlasFunctions.getProjectApiKey(GetProjectApiKeyArgs.builder()
                .projectId("64259ee860c43338194b0f8e")
                .apiKeyId(testMongodbatlasApiKey.apiKeyId())
                .build());
    
        }
    }
    
    resources:
      testProjectApiKey:
        type: mongodbatlas:ProjectApiKey
        name: test
        properties:
          description: Description of your API key
          projectAssignments:
            - projectId: 64259ee860c43338194b0f8e
              roleNames:
                - GROUP_READ_ONLY
    variables:
      test:
        fn::invoke:
          Function: mongodbatlas:getProjectApiKey
          Arguments:
            projectId: 64259ee860c43338194b0f8e
            apiKeyId: ${testMongodbatlasApiKey.apiKeyId}
    

    Using getProjectApiKey

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getProjectApiKey(args: GetProjectApiKeyArgs, opts?: InvokeOptions): Promise<GetProjectApiKeyResult>
    function getProjectApiKeyOutput(args: GetProjectApiKeyOutputArgs, opts?: InvokeOptions): Output<GetProjectApiKeyResult>
    def get_project_api_key(api_key_id: Optional[str] = None,
                            project_id: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetProjectApiKeyResult
    def get_project_api_key_output(api_key_id: Optional[pulumi.Input[str]] = None,
                            project_id: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetProjectApiKeyResult]
    func LookupProjectApiKey(ctx *Context, args *LookupProjectApiKeyArgs, opts ...InvokeOption) (*LookupProjectApiKeyResult, error)
    func LookupProjectApiKeyOutput(ctx *Context, args *LookupProjectApiKeyOutputArgs, opts ...InvokeOption) LookupProjectApiKeyResultOutput

    > Note: This function is named LookupProjectApiKey in the Go SDK.

    public static class GetProjectApiKey 
    {
        public static Task<GetProjectApiKeyResult> InvokeAsync(GetProjectApiKeyArgs args, InvokeOptions? opts = null)
        public static Output<GetProjectApiKeyResult> Invoke(GetProjectApiKeyInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetProjectApiKeyResult> getProjectApiKey(GetProjectApiKeyArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: mongodbatlas:index/getProjectApiKey:getProjectApiKey
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ApiKeyId string
    Unique identifier for this Project API key.
    ProjectId string
    The unique ID for the project.
    ApiKeyId string
    Unique identifier for this Project API key.
    ProjectId string
    The unique ID for the project.
    apiKeyId String
    Unique identifier for this Project API key.
    projectId String
    The unique ID for the project.
    apiKeyId string
    Unique identifier for this Project API key.
    projectId string
    The unique ID for the project.
    api_key_id str
    Unique identifier for this Project API key.
    project_id str
    The unique ID for the project.
    apiKeyId String
    Unique identifier for this Project API key.
    projectId String
    The unique ID for the project.

    getProjectApiKey Result

    The following output properties are available:

    ApiKeyId string
    Description string
    Description of this Project API key.
    Id string
    The provider-assigned unique ID for this managed resource.
    PrivateKey string
    Private key for this Organization API key.
    ProjectAssignments List<GetProjectApiKeyProjectAssignment>
    ProjectId string
    Project ID to assign to Access Key
    PublicKey string
    Public key for this Organization API key.
    ApiKeyId string
    Description string
    Description of this Project API key.
    Id string
    The provider-assigned unique ID for this managed resource.
    PrivateKey string
    Private key for this Organization API key.
    ProjectAssignments []GetProjectApiKeyProjectAssignment
    ProjectId string
    Project ID to assign to Access Key
    PublicKey string
    Public key for this Organization API key.
    apiKeyId String
    description String
    Description of this Project API key.
    id String
    The provider-assigned unique ID for this managed resource.
    privateKey String
    Private key for this Organization API key.
    projectAssignments List<GetProjectApiKeyProjectAssignment>
    projectId String
    Project ID to assign to Access Key
    publicKey String
    Public key for this Organization API key.
    apiKeyId string
    description string
    Description of this Project API key.
    id string
    The provider-assigned unique ID for this managed resource.
    privateKey string
    Private key for this Organization API key.
    projectAssignments GetProjectApiKeyProjectAssignment[]
    projectId string
    Project ID to assign to Access Key
    publicKey string
    Public key for this Organization API key.
    api_key_id str
    description str
    Description of this Project API key.
    id str
    The provider-assigned unique ID for this managed resource.
    private_key str
    Private key for this Organization API key.
    project_assignments Sequence[GetProjectApiKeyProjectAssignment]
    project_id str
    Project ID to assign to Access Key
    public_key str
    Public key for this Organization API key.
    apiKeyId String
    description String
    Description of this Project API key.
    id String
    The provider-assigned unique ID for this managed resource.
    privateKey String
    Private key for this Organization API key.
    projectAssignments List<Property Map>
    projectId String
    Project ID to assign to Access Key
    publicKey String
    Public key for this Organization API key.

    Supporting Types

    GetProjectApiKeyProjectAssignment

    ProjectId string
    The unique ID for the project.
    RoleNames 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.
    ProjectId string
    The unique ID for the project.
    RoleNames []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.
    projectId String
    The unique ID for the project.
    roleNames 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.
    projectId string
    The unique ID for the project.
    roleNames 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
    The unique ID for the project.
    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.
    projectId String
    The unique ID for the project.
    roleNames 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.

    Package Details

    Repository
    MongoDB Atlas pulumi/pulumi-mongodbatlas
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the mongodbatlas Terraform Provider.
    mongodbatlas logo
    MongoDB Atlas v3.16.2 published on Friday, Jun 21, 2024 by Pulumi