There are more AWS SDK examples available in the AWS Doc SDK Examples
Use UntagResources
with a CLI
The following code examples show how to use UntagResources
.
- CLI
-
- AWS CLI
-
To remove a tag from a resource
The following
untag-resources
example removes the specified tag keys and any associated values from the specified resource.aws resourcegroupstaggingapi untag-resources \ --resource-arn-list
arn:aws:s3:::awsexamplebucket
\ --tag-keysEnvironment
CostCenter
Output:
{ "FailedResourcesMap": {} }
For more information, see UntagResources in the Resource Groups Tagging API Reference.
-
For API details, see UntagResources
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell
-
Example 1: Removes the tag keys "stage" and "version", and the associated values, from an Amazon S3 bucket and an Amazon DynamoDB table. A single call is made to the service to remove the tags. Before the tags are removed the cmdlet will prompt for confirmation. To bypass confirmation add the -Force parameter.
$arn1 = "arn:aws:s3:::amzn-s3-demo-bucket" $arn2 = "arn:aws:dynamodb:us-west-2:123456789012:table/mytable" Remove-RGTResourceTag -ResourceARNList $arn1,$arn2 -TagKey "stage","version"
Example 2: Removes the tag keys "stage" and "version", and the associated values, from an Amazon S3 bucket and an Amazon DynamoDB table. Two calls are made to the service, one for each resource ARN piped into the cmdlet. Before each call the cmdlet will prompt for confirmation. To bypass confirmation add the -Force parameter.
$arn1 = "arn:aws:s3:::amzn-s3-demo-bucket" $arn2 = "arn:aws:dynamodb:us-west-2:123456789012:table/mytable" $arn1,$arn2 | Remove-RGTResourceTag -TagKey "stage","version"
-
For API details, see UntagResources in AWS Tools for PowerShell Cmdlet Reference.
-