Working with Tags by Using the Amazon AppStream 2.0 API, an AWS SDK, or AWS CLI
If you're using the AppStream 2.0 API, an AWS SDK, or the AWS Command Line Interface (AWS
CLI), you can use the following AppStream 2.0 operations with the tags
parameter
to add tags when you create new resources.
Note
You can use spaces in tag keys and values. To indicate a space when you use the AWS CLI, use "\s" (without the quotation marks).
Task | AWS CLI | API Operation |
---|---|---|
Add one or more tags for a new fleet | create-fleet | |
Add one or more tags for a new image builder | create-imagebuilder | |
Add one or more tags for a new stack |
You can use the following AppStream 2.0 operations to add, edit, remove, or list tags for existing resources:
Task | AWS CLI | API Operation |
---|---|---|
Add or overwrite one or more tags for a resource | tag-resource | |
Remove one or more tags for a resource | untag-resource | |
List one or more tags for a resource |
When you use the AppStream 2.0 API, an AWS SDK, or AWS CLI actions to add, edit, remove, or list tags for an existing AppStream 2.0 resource, specify the resource by using its Amazon Resource Name (ARN). An ARN uniquely identifies an AWS resource and uses the following general syntax.
arn:aws:appstream:region
:account
:resourceType
/resourceName
region
-
The AWS Region in which the resource was created (for example,
us-east-1
). account
-
The AWS account ID, with no hyphens (for example,
123456789012
). resourceType
-
The type of resource. You can tag the following AppStream 2.0 resource types:
image-builder
,image
,fleet
, andstack
. resourceName
-
The name of the resource.
For example, you can obtain the ARN for an AppStream 2.0 fleet by using the AWS CLI describe-fleets command. Copy the following command.
aws appstream describe-fleets
For an environment that contains a single fleet named TestFleet
, the ARN
for this resource would appear in the JSON output similar to the following.
"Arn": "arn:aws:appstream:us-east-1:123456789012:fleet/TestFleet"
After you obtain the ARN for this resource, you can add two tags by using the tag-resource command:
aws appstream tag-resource --resource arn:awsappstream:us-east-1:123456789012:fleet/TestFleet --tags Environment=Test,Department=IT
The first tag, Environment=Test
, indicates that the fleet is in a test
environment. The second tag, Department=IT
, indicates that the fleet is in
the IT department.
You can use the following command to list the two tags that you added to the fleet.
aws appstream list-tags-for-resource --resource arn:aws:appstream:us-east-1:123456789012:fleet/TestFleet
For this example, the JSON output appears as follows:
{
"Tags": {
"Environment" : "Test",
"Department" : "IT"
}
}