@aws-sdk/client-resource-groups-tagging-api-node
Description
Resource Groups Tagging API
This guide describes the API operations for the resource groups tagging.
A tag is a label that you assign to an AWS resource. A tag consists of a key and a value, both of which you define. For example, if you have two Amazon EC2 instances, you might assign both a tag key of "Stack." But the value of "Stack" might be "Testing" for one and "Production" for the other.
Tagging can help you organize your resources and enables you to simplify resource management, access management and cost allocation.
You can use the resource groups tagging API operations to complete the following tasks:
-
Tag and untag supported resources located in the specified region for the AWS account
-
Use tag-based filters to search for resources located in the specified region for the AWS account
-
List all existing tag keys in the specified region for the AWS account
-
List all existing values for the specified key in the specified region for the AWS account
To make full use of the resource groups tagging API operations, you might need additional IAM permissions, including permission to access the resources of individual services as well as permission to view and apply tags to those resources. For more information, see Obtaining Permissions for Resource Groups and Tag Editor.
You can use the Resource Groups Tagging API to tag resources for the following AWS services.
-
Alexa for Business (a4b)
-
API Gateway
-
AWS AppStream
-
AWS AppSync
-
Amazon Athena
-
Amazon Aurora
-
AWS Certificate Manager
-
AWS Certificate Manager Private CA
-
Amazon Cloud Directory
-
AWS CloudFormation
-
Amazon CloudFront
-
AWS CloudHSM
-
AWS CloudTrail
-
Amazon CloudWatch (alarms only)
-
Amazon CloudWatch Events
-
Amazon CloudWatch Logs
-
AWS CodeBuild
-
AWS CodeStar
-
Amazon Cognito Identity
-
Amazon Cognito User Pools
-
Amazon Comprehend
-
AWS Config
-
AWS Data Pipeline
-
AWS Database Migration Service
-
AWS Datasync
-
AWS Direct Connect
-
AWS Directory Service
-
Amazon DynamoDB
-
Amazon EBS
-
Amazon EC2
-
Amazon ECR
-
Amazon ECS
-
AWS Elastic Beanstalk
-
Amazon Elastic File System
-
Elastic Load Balancing
-
Amazon ElastiCache
-
Amazon Elasticsearch Service
-
AWS Elemental MediaLive
-
AWS Elemental MediaPackage
-
AWS Elemental MediaTailor
-
Amazon EMR
-
Amazon FSx
-
Amazon Glacier
-
AWS Glue
-
Amazon Inspector
-
AWS IoT Analytics
-
AWS IoT Core
-
AWS IoT Device Defender
-
AWS IoT Device Management
-
AWS IoT Greengrass
-
AWS Key Management Service
-
Amazon Kinesis
-
Amazon Kinesis Data Analytics
-
Amazon Kinesis Data Firehose
-
AWS Lambda
-
AWS License Manager
-
Amazon Machine Learning
-
Amazon MQ
-
Amazon MSK
-
Amazon Neptune
-
AWS OpsWorks
-
Amazon RDS
-
Amazon Redshift
-
AWS Resource Access Manager
-
AWS Resource Groups
-
AWS RoboMaker
-
Amazon Route 53
-
Amazon Route 53 Resolver
-
Amazon S3 (buckets only)
-
Amazon SageMaker
-
AWS Secrets Manager
-
AWS Service Catalog
-
Amazon Simple Notification Service (SNS)
-
Amazon Simple Queue Service (SQS)
-
AWS Simple System Manager (SSM)
-
AWS Step Functions
-
AWS Storage Gateway
-
AWS Transfer for SFTP
-
Amazon VPC
-
Amazon WorkSpaces
Installing
To install the this package using NPM, simply type the following into a terminal window:
npm install @aws-sdk/client-resource-groups-tagging-api-node
Getting Started
Import
The AWS SDK is modulized by clients and commands in CommonJS modules. To send a request, you only need to import the client(ResourceGroupsTaggingAPIClient
) and the commands you need, for example GetResourcesCommand
:
//JavaScript
const {
ResourceGroupsTaggingAPIClient
} = require("@aws-sdk/client-resource-groups-tagging-api-node/ResourceGroupsTaggingAPIClient");
const {
GetResourcesCommand
} = require("@aws-sdk/client-resource-groups-tagging-api-node/commands/GetResourcesCommand");
//TypeScript
import { ResourceGroupsTaggingAPIClient } from "@aws-sdk/client-resource-groups-tagging-api-node/ResourceGroupsTaggingAPIClient";
import { GetResourcesCommand } from "@aws-sdk/client-resource-groups-tagging-api-node/commands/GetResourcesCommand";
Usage
To send a request, you:
- Initiate client with configuration (e.g. credentials, region). For more information you can refer to the API reference.
- Initiate command with input parameters.
- Call
send
operation on client with command object as input. - If you are using a custom http handler, you may call
destroy()
to close open connections.
const resourceGroupsTaggingAPI = new ResourceGroupsTaggingAPIClient({
region: "region"
});
//clients can be shared by different commands
const params = {};
const getResourcesCommand = new GetResourcesCommand(params);
resourceGroupsTaggingAPI
.send(getResourcesCommand)
.then(data => {
// do something
})
.catch(error => {
// error handling
});
In addition to using promises, there are 2 other ways to send a request:
// async/await
try {
const data = await resourceGroupsTaggingAPI.send(getResourcesCommand);
// do something
} catch (error) {
// error handling
}
// callback
resourceGroupsTaggingAPI.send(getResourcesCommand, (err, data) => {
//do something
});
The SDK can also send requests using the simplified callback style from version 2 of the SDK.
import * as AWS from "@aws-sdk/@aws-sdk/client-resource-groups-tagging-api-node/ResourceGroupsTaggingAPI";
const resourceGroupsTaggingAPI = new AWS.ResourceGroupsTaggingAPI({
region: "region"
});
resourceGroupsTaggingAPI.getResources(params, (err, data) => {
//do something
});
Troubleshooting
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
try {
const data = await resourceGroupsTaggingAPI.send(getResourcesCommand);
// do something
} catch (error) {
const metadata = error.$metadata;
console.log(
`requestId: ${metadata.requestId}
cfId: ${metadata.cfId}
extendedRequestId: ${metadata.extendedRequestId}`
);
/*
The keys within exceptions are also parsed. You can access them by specifying exception names:
if(error.name === 'SomeServiceException') {
const value = error.specialKeyInException;
}
*/
}
Getting Help
Please use these community resources for getting help. We use the GitHub issues for tracking bugs and feature requests and have limited bandwidth to address them.
- Ask a question on StackOverflow and tag it with
aws-sdk-js
- Come join the AWS JavaScript community on gitter
- If it turns out that you may have found a bug, please open an issue
Contributing
This client code is generated automatically. Any modifications will be overwritten the next time the `@aws-sdk/@aws-sdk/client-resource-groups-tagging-api-node' package is updated. To contribute to SDK you can checkout our code generator package.
License
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.