ibm 1.78.0 published on Wednesday, Apr 30, 2025 by ibm-cloud
ibm.getResourceTag
Explore with Pulumi AI
Retreive information about an existing resource or access tags as a read-only data source. For more information, about resource tags, see controlling access to resources by using tags.
Example Usage
Sample to attach resource tags
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const location = ibm.getSatelliteLocation({
location: _var.location,
});
const readTag = location.then(location => ibm.getResourceTag({
resourceId: location.crn,
}));
import pulumi
import pulumi_ibm as ibm
location = ibm.get_satellite_location(location=var["location"])
read_tag = ibm.get_resource_tag(resource_id=location.crn)
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 {
location, err := ibm.LookupSatelliteLocation(ctx, &ibm.LookupSatelliteLocationArgs{
Location: _var.Location,
}, nil)
if err != nil {
return err
}
_, err = ibm.LookupResourceTag(ctx, &ibm.LookupResourceTagArgs{
ResourceId: pulumi.StringRef(location.Crn),
}, 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 location = Ibm.GetSatelliteLocation.Invoke(new()
{
Location = @var.Location,
});
var readTag = Ibm.GetResourceTag.Invoke(new()
{
ResourceId = location.Apply(getSatelliteLocationResult => getSatelliteLocationResult.Crn),
});
});
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.GetSatelliteLocationArgs;
import com.pulumi.ibm.inputs.GetResourceTagArgs;
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 location = IbmFunctions.getSatelliteLocation(GetSatelliteLocationArgs.builder()
.location(var_.location())
.build());
final var readTag = IbmFunctions.getResourceTag(GetResourceTagArgs.builder()
.resourceId(location.applyValue(getSatelliteLocationResult -> getSatelliteLocationResult.crn()))
.build());
}
}
variables:
location:
fn::invoke:
function: ibm:getSatelliteLocation
arguments:
location: ${var.location}
readTag:
fn::invoke:
function: ibm:getResourceTag
arguments:
resourceId: ${location.crn}
Retrieve access tags
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const accessTags = ibm.getResourceTag({
tagType: "access",
});
import pulumi
import pulumi_ibm as ibm
access_tags = ibm.get_resource_tag(tag_type="access")
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.LookupResourceTag(ctx, &ibm.LookupResourceTagArgs{
TagType: pulumi.StringRef("access"),
}, 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 accessTags = Ibm.GetResourceTag.Invoke(new()
{
TagType = "access",
});
});
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.GetResourceTagArgs;
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 accessTags = IbmFunctions.getResourceTag(GetResourceTagArgs.builder()
.tagType("access")
.build());
}
}
variables:
accessTags:
fn::invoke:
function: ibm:getResourceTag
arguments:
tagType: access
Retrieve user tags
import * as pulumi from "@pulumi/pulumi";
import * as ibm from "@pulumi/ibm";
const userTags = ibm.getResourceTag({});
import pulumi
import pulumi_ibm as ibm
user_tags = ibm.get_resource_tag()
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.LookupResourceTag(ctx, &ibm.LookupResourceTagArgs{}, 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 userTags = Ibm.GetResourceTag.Invoke();
});
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.GetResourceTagArgs;
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 userTags = IbmFunctions.getResourceTag();
}
}
variables:
userTags:
fn::invoke:
function: ibm:getResourceTag
arguments: {}
Attributes reference
In addition to all argument reference list, you can access the following attribute references after your data source is created.
id
- (String) The unique identifier of the resource tag.tags
- (String) List of tags associated with resource instance.
Using getResourceTag
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 getResourceTag(args: GetResourceTagArgs, opts?: InvokeOptions): Promise<GetResourceTagResult>
function getResourceTagOutput(args: GetResourceTagOutputArgs, opts?: InvokeOptions): Output<GetResourceTagResult>
def get_resource_tag(id: Optional[str] = None,
resource_id: Optional[str] = None,
resource_type: Optional[str] = None,
tag_type: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetResourceTagResult
def get_resource_tag_output(id: Optional[pulumi.Input[str]] = None,
resource_id: Optional[pulumi.Input[str]] = None,
resource_type: Optional[pulumi.Input[str]] = None,
tag_type: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetResourceTagResult]
func LookupResourceTag(ctx *Context, args *LookupResourceTagArgs, opts ...InvokeOption) (*LookupResourceTagResult, error)
func LookupResourceTagOutput(ctx *Context, args *LookupResourceTagOutputArgs, opts ...InvokeOption) LookupResourceTagResultOutput
> Note: This function is named LookupResourceTag
in the Go SDK.
public static class GetResourceTag
{
public static Task<GetResourceTagResult> InvokeAsync(GetResourceTagArgs args, InvokeOptions? opts = null)
public static Output<GetResourceTagResult> Invoke(GetResourceTagInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetResourceTagResult> getResourceTag(GetResourceTagArgs args, InvokeOptions options)
public static Output<GetResourceTagResult> getResourceTag(GetResourceTagArgs args, InvokeOptions options)
fn::invoke:
function: ibm:index/getResourceTag:getResourceTag
arguments:
# arguments dictionary
The following arguments are supported:
- Id string
- Resource
Id string - The CRN of the resource on which the tags should be attached.
- Resource
Type string - The resource type on which the tags to be attached.
- Tag
Type string - Type of the tag. Supported values are:
user
,service
, oraccess
. Default:user
- Id string
- Resource
Id string - The CRN of the resource on which the tags should be attached.
- Resource
Type string - The resource type on which the tags to be attached.
- Tag
Type string - Type of the tag. Supported values are:
user
,service
, oraccess
. Default:user
- id String
- resource
Id String - The CRN of the resource on which the tags should be attached.
- resource
Type String - The resource type on which the tags to be attached.
- tag
Type String - Type of the tag. Supported values are:
user
,service
, oraccess
. Default:user
- id string
- resource
Id string - The CRN of the resource on which the tags should be attached.
- resource
Type string - The resource type on which the tags to be attached.
- tag
Type string - Type of the tag. Supported values are:
user
,service
, oraccess
. Default:user
- id str
- resource_
id str - The CRN of the resource on which the tags should be attached.
- resource_
type str - The resource type on which the tags to be attached.
- tag_
type str - Type of the tag. Supported values are:
user
,service
, oraccess
. Default:user
- id String
- resource
Id String - The CRN of the resource on which the tags should be attached.
- resource
Type String - The resource type on which the tags to be attached.
- tag
Type String - Type of the tag. Supported values are:
user
,service
, oraccess
. Default:user
getResourceTag Result
The following output properties are available:
- Id string
- List<string>
- Resource
Id string - Resource
Type string - Tag
Type string
- Id string
- []string
- Resource
Id string - Resource
Type string - Tag
Type string
- id String
- List<String>
- resource
Id String - resource
Type String - tag
Type String
- id string
- string[]
- resource
Id string - resource
Type string - tag
Type string
- id str
- Sequence[str]
- resource_
id str - resource_
type str - tag_
type str
- id String
- List<String>
- resource
Id String - resource
Type String - tag
Type String
Package Details
- Repository
- ibm ibm-cloud/terraform-provider-ibm
- License
- Notes
- This Pulumi package is based on the
ibm
Terraform Provider.