ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud
ibm.getResourceKey
Explore with Pulumi AI
Retrieve information about an existing IBM resource key from IBM Cloud as a read-only data source. For more information, about resource key, see ibmcloud resource service-keys.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const resourceKeydata = ibm.getResourceKey({
name: "myobjectKey",
resourceInstanceId: ibm_resource_instance.resource.id,
});
import pulumi
import pulumi_ibm as ibm
resource_keydata = ibm.get_resource_key(name="myobjectKey",
resource_instance_id=ibm_resource_instance["resource"]["id"])
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ibm.LookupResourceKey(ctx, &ibm.LookupResourceKeyArgs{
Name: "myobjectKey",
ResourceInstanceId: pulumi.StringRef(ibm_resource_instance.Resource.Id),
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ibm = Pulumi.Ibm;
return await Deployment.RunAsync(() =>
{
var resourceKeydata = Ibm.GetResourceKey.Invoke(new()
{
Name = "myobjectKey",
ResourceInstanceId = ibm_resource_instance.Resource.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ibm.IbmFunctions;
import com.pulumi.ibm.inputs.GetResourceKeyArgs;
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) {
final var resourceKeydata = IbmFunctions.getResourceKey(GetResourceKeyArgs.builder()
.name("myobjectKey")
.resourceInstanceId(ibm_resource_instance.resource().id())
.build());
}
}
variables:
resourceKeydata:
fn::invoke:
function: ibm:getResourceKey
arguments:
name: myobjectKey
resourceInstanceId: ${ibm_resource_instance.resource.id}
Example to access resource credentials using credentials attribute:
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const key = ibm.getResourceKey({
name: "myobjectKey",
resourceInstanceId: ibm_resource_instance.resource.id,
});
export const accessKeyId = key.then(key => key.credentials?.["cos_hmac_keys.access_key_id"]);
export const secretAccessKey = key.then(key => key.credentials?.["cos_hmac_keys.secret_access_key"]);
import pulumi
import pulumi_ibm as ibm
key = ibm.get_resource_key(name="myobjectKey",
resource_instance_id=ibm_resource_instance["resource"]["id"])
pulumi.export("accessKeyId", key.credentials["cos_hmac_keys.access_key_id"])
pulumi.export("secretAccessKey", key.credentials["cos_hmac_keys.secret_access_key"])
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/ibm/ibm"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
key, err := ibm.LookupResourceKey(ctx, &ibm.LookupResourceKeyArgs{
Name: "myobjectKey",
ResourceInstanceId: pulumi.StringRef(ibm_resource_instance.Resource.Id),
}, nil)
if err != nil {
return err
}
ctx.Export("accessKeyId", key.Credentials.Cos_hmac_keys.access_key_id)
ctx.Export("secretAccessKey", key.Credentials.Cos_hmac_keys.secret_access_key)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Ibm = Pulumi.Ibm;
return await Deployment.RunAsync(() =>
{
var key = Ibm.GetResourceKey.Invoke(new()
{
Name = "myobjectKey",
ResourceInstanceId = ibm_resource_instance.Resource.Id,
});
return new Dictionary<string, object?>
{
["accessKeyId"] = key.Apply(getResourceKeyResult => getResourceKeyResult.Credentials?.Cos_hmac_keys_access_key_id),
["secretAccessKey"] = key.Apply(getResourceKeyResult => getResourceKeyResult.Credentials?.Cos_hmac_keys_secret_access_key),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ibm.IbmFunctions;
import com.pulumi.ibm.inputs.GetResourceKeyArgs;
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) {
final var key = IbmFunctions.getResourceKey(GetResourceKeyArgs.builder()
.name("myobjectKey")
.resourceInstanceId(ibm_resource_instance.resource().id())
.build());
ctx.export("accessKeyId", key.applyValue(getResourceKeyResult -> getResourceKeyResult.credentials().cos_hmac_keys.access_key_id()));
ctx.export("secretAccessKey", key.applyValue(getResourceKeyResult -> getResourceKeyResult.credentials().cos_hmac_keys.secret_access_key()));
}
}
variables:
key:
fn::invoke:
function: ibm:getResourceKey
arguments:
name: myobjectKey
resourceInstanceId: ${ibm_resource_instance.resource.id}
outputs:
accessKeyId: ${key.credentials"cos_hmac_keys.access_key_id"[%!s(MISSING)]}
secretAccessKey: ${key.credentials"cos_hmac_keys.secret_access_key"[%!s(MISSING)]}
Using getResourceKey
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 getResourceKey(args: GetResourceKeyArgs, opts?: InvokeOptions): Promise<GetResourceKeyResult>
function getResourceKeyOutput(args: GetResourceKeyOutputArgs, opts?: InvokeOptions): Output<GetResourceKeyResult>
def get_resource_key(id: Optional[str] = None,
most_recent: Optional[bool] = None,
name: Optional[str] = None,
resource_alias_id: Optional[str] = None,
resource_instance_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetResourceKeyResult
def get_resource_key_output(id: Optional[pulumi.Input[str]] = None,
most_recent: Optional[pulumi.Input[bool]] = None,
name: Optional[pulumi.Input[str]] = None,
resource_alias_id: Optional[pulumi.Input[str]] = None,
resource_instance_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetResourceKeyResult]
func LookupResourceKey(ctx *Context, args *LookupResourceKeyArgs, opts ...InvokeOption) (*LookupResourceKeyResult, error)
func LookupResourceKeyOutput(ctx *Context, args *LookupResourceKeyOutputArgs, opts ...InvokeOption) LookupResourceKeyResultOutput
> Note: This function is named LookupResourceKey
in the Go SDK.
public static class GetResourceKey
{
public static Task<GetResourceKeyResult> InvokeAsync(GetResourceKeyArgs args, InvokeOptions? opts = null)
public static Output<GetResourceKeyResult> Invoke(GetResourceKeyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetResourceKeyResult> getResourceKey(GetResourceKeyArgs args, InvokeOptions options)
public static Output<GetResourceKeyResult> getResourceKey(GetResourceKeyArgs args, InvokeOptions options)
fn::invoke:
function: ibm:index/getResourceKey:getResourceKey
arguments:
# arguments dictionary
The following arguments are supported:
- Name string
- The name of the resource key. You can retrieve the value by executing the
ibmcloud resource service-keys
command in the IBM Cloud CLI. - Id string
- (String) The unique identifier of the resource key.
- Most
Recent bool - If there are multiple resource keys, you can set this argument to
true
to import only the most recently created key. - Resource
Alias stringId - The ID of the resource alias that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-alias
command in the IBM Cloud CLI. Note Conflicts withresource_instance_id
. - Resource
Instance stringId - The ID of the resource instance that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-instances
command in the IBM Cloud CLI. Note: Conflicts withresource_alias_id
.
- Name string
- The name of the resource key. You can retrieve the value by executing the
ibmcloud resource service-keys
command in the IBM Cloud CLI. - Id string
- (String) The unique identifier of the resource key.
- Most
Recent bool - If there are multiple resource keys, you can set this argument to
true
to import only the most recently created key. - Resource
Alias stringId - The ID of the resource alias that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-alias
command in the IBM Cloud CLI. Note Conflicts withresource_instance_id
. - Resource
Instance stringId - The ID of the resource instance that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-instances
command in the IBM Cloud CLI. Note: Conflicts withresource_alias_id
.
- name String
- The name of the resource key. You can retrieve the value by executing the
ibmcloud resource service-keys
command in the IBM Cloud CLI. - id String
- (String) The unique identifier of the resource key.
- most
Recent Boolean - If there are multiple resource keys, you can set this argument to
true
to import only the most recently created key. - resource
Alias StringId - The ID of the resource alias that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-alias
command in the IBM Cloud CLI. Note Conflicts withresource_instance_id
. - resource
Instance StringId - The ID of the resource instance that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-instances
command in the IBM Cloud CLI. Note: Conflicts withresource_alias_id
.
- name string
- The name of the resource key. You can retrieve the value by executing the
ibmcloud resource service-keys
command in the IBM Cloud CLI. - id string
- (String) The unique identifier of the resource key.
- most
Recent boolean - If there are multiple resource keys, you can set this argument to
true
to import only the most recently created key. - resource
Alias stringId - The ID of the resource alias that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-alias
command in the IBM Cloud CLI. Note Conflicts withresource_instance_id
. - resource
Instance stringId - The ID of the resource instance that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-instances
command in the IBM Cloud CLI. Note: Conflicts withresource_alias_id
.
- name str
- The name of the resource key. You can retrieve the value by executing the
ibmcloud resource service-keys
command in the IBM Cloud CLI. - id str
- (String) The unique identifier of the resource key.
- most_
recent bool - If there are multiple resource keys, you can set this argument to
true
to import only the most recently created key. - resource_
alias_ strid - The ID of the resource alias that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-alias
command in the IBM Cloud CLI. Note Conflicts withresource_instance_id
. - resource_
instance_ strid - The ID of the resource instance that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-instances
command in the IBM Cloud CLI. Note: Conflicts withresource_alias_id
.
- name String
- The name of the resource key. You can retrieve the value by executing the
ibmcloud resource service-keys
command in the IBM Cloud CLI. - id String
- (String) The unique identifier of the resource key.
- most
Recent Boolean - If there are multiple resource keys, you can set this argument to
true
to import only the most recently created key. - resource
Alias StringId - The ID of the resource alias that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-alias
command in the IBM Cloud CLI. Note Conflicts withresource_instance_id
. - resource
Instance StringId - The ID of the resource instance that the resource key is associated with. You can retrieve the value by executing the
ibmcloud resource service-instances
command in the IBM Cloud CLI. Note: Conflicts withresource_alias_id
.
getResourceKey Result
The following output properties are available:
- Credentials Dictionary<string, string>
- (Map) The credentials associated with the key.
- Credentials
Json string - (String) The credentials associated with the key in json format.
- Crn string
- (String) CRN of resource key.
- Id string
- (String) The unique identifier of the resource key.
- Name string
- Onetime
Credentials bool - (Bool) A boolean that dictates if the onetime_credentials is true or false.
- Role string
- (String) The user role.
- Status string
- (String) The status of the resource key.
- Most
Recent bool - Resource
Alias stringId - Resource
Instance stringId
- Credentials map[string]string
- (Map) The credentials associated with the key.
- Credentials
Json string - (String) The credentials associated with the key in json format.
- Crn string
- (String) CRN of resource key.
- Id string
- (String) The unique identifier of the resource key.
- Name string
- Onetime
Credentials bool - (Bool) A boolean that dictates if the onetime_credentials is true or false.
- Role string
- (String) The user role.
- Status string
- (String) The status of the resource key.
- Most
Recent bool - Resource
Alias stringId - Resource
Instance stringId
- credentials Map<String,String>
- (Map) The credentials associated with the key.
- credentials
Json String - (String) The credentials associated with the key in json format.
- crn String
- (String) CRN of resource key.
- id String
- (String) The unique identifier of the resource key.
- name String
- onetime
Credentials Boolean - (Bool) A boolean that dictates if the onetime_credentials is true or false.
- role String
- (String) The user role.
- status String
- (String) The status of the resource key.
- most
Recent Boolean - resource
Alias StringId - resource
Instance StringId
- credentials {[key: string]: string}
- (Map) The credentials associated with the key.
- credentials
Json string - (String) The credentials associated with the key in json format.
- crn string
- (String) CRN of resource key.
- id string
- (String) The unique identifier of the resource key.
- name string
- onetime
Credentials boolean - (Bool) A boolean that dictates if the onetime_credentials is true or false.
- role string
- (String) The user role.
- status string
- (String) The status of the resource key.
- most
Recent boolean - resource
Alias stringId - resource
Instance stringId
- credentials Mapping[str, str]
- (Map) The credentials associated with the key.
- credentials_
json str - (String) The credentials associated with the key in json format.
- crn str
- (String) CRN of resource key.
- id str
- (String) The unique identifier of the resource key.
- name str
- onetime_
credentials bool - (Bool) A boolean that dictates if the onetime_credentials is true or false.
- role str
- (String) The user role.
- status str
- (String) The status of the resource key.
- most_
recent bool - resource_
alias_ strid - resource_
instance_ strid
- credentials Map<String>
- (Map) The credentials associated with the key.
- credentials
Json String - (String) The credentials associated with the key in json format.
- crn String
- (String) CRN of resource key.
- id String
- (String) The unique identifier of the resource key.
- name String
- onetime
Credentials Boolean - (Bool) A boolean that dictates if the onetime_credentials is true or false.
- role String
- (String) The user role.
- status String
- (String) The status of the resource key.
- most
Recent Boolean - resource
Alias StringId - resource
Instance StringId
Package Details
- Repository
- ibm ibm-cloud/terraform-provider-ibm
- License
- Notes
- This Pulumi package is based on the
ibm
Terraform Provider.