Adding or Removing Tags

You can add tags to your existing resources to identify and categorize them. Tags enable you to make an inventory of your resources.

A tag is a combination of a key and a value. If a tag with the same key already exists for the specified resource, no new tag is created. Instead, the value of the existing tag is updated.

You can also add tags to virtual machines (VMs) when creating them, and to snapshots when creating them. For more information, see Creating VMs and Creating a Snapshot of a Volume.

To add tags to your load balancers, see Adding or Removing Tags to Your Load Balancers.

Adding or Removing Tags Using Cockpit v2

  1. Click inside the dashboard of the resource whose tags you want to edit to make checkboxes appear.

  2. Check the box of the resource whose tags you want to edit.
    The resource is selected and an action menu appears.

  3. Click IconTag Edit Tags.
    The EDIT TAGS dialog box appears.

  4. (optional) To add a tag to the resource, click IconAddFull Add New Tag and type a key and a value.

    The tag value is optional. You can add a tag by specifying a key only.

    The tag value must contain 255 characters maximum. However, there is no maximum length for the tag key.

  5. (optional) To remove a tag, click IconTerminate.

  6. Click Update Tags.
    The tags are added to or removed from the selected resource.

    You can also update the key or value of existing tags at any time in the EDIT TAGS dialog box.

Adding or Removing Tags Using OSC CLI

Adding Tags

The CreateTags command adds one or more tags to the specified resources.
If a tag with the same key already exists for the resource, the tag value is replaced.
You can tag the following resources using their IDs:

  • Virtual machines (VMs) (i-xxxxxxxx)

  • OMIs (ami-xxxxxxxx)

  • Volumes (vol-xxxxxxxx)

  • Snapshots (snap-xxxxxxxx)

  • Public IPs (eipalloc-xxxxxxxx)

  • Security groups (sg-xxxxxxxx)

  • Route tables (rtb-xxxxxxxx)

  • Network interface cards (NIC) (eni-xxxxxxxx)

  • Nets (vpc-xxxxxxxx)

  • Subnets (subnet-xxxxxxxx)

  • Net peerings (vpcx-xxxxxxxx)

  • Net endpoints (vpce-xxxxxxxx)

  • NAT services (nat-xxxxxxxx)

  • Internet services (igw-xxxxxxxx)

  • Client gateways (cgw-xxxxxxxx)

  • Virtual gateways (vgw-xxxxxxxx)

  • VPN connections (vpn-xxxxxxxx)

  • DHCP options (dopt-xxxxxxxx)

  • OMI export tasks (image-export-xxxxxxxx)

  • Snapshot export tasks (snap-export-xxxxxxxx)

For more information, see About Tags.

Request sample
$ osc-cli api CreateTags --profile "default" \
    --ResourceIds '["i-12345678"]' \
    --Tags '[
        {
          "Key": "key1",
          "Value": "value1",
        },
      ]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • ResourceIds: One or more resource IDs.

  • Tags: One or more tags to add to the specified resources.

The CreateTags command returns the following elements:

  • ResponseContext: Information about the context of the response.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Removing Tags

The DeleteTags command deletes one or more tags from the specified resources.

Request sample
$ osc-cli api DeleteTags --profile "default" \
    --ResourceIds '["i-12345678"]' \
    --Tags '[
        {
          "Key": "key1",
          "Value": "value1",
        },
      ]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • ResourceIds: One or more resource IDs.

  • Tags: One or more tags to delete (if you set a tag value, only the tags matching exactly this value are deleted).

The DeleteTags command returns the following elements:

  • ResponseContext: Information about the context of the response.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Adding or Removing Tags Using AWS CLI

Adding Tags

To add one or more tags, use the create-tags command following this syntax:

Request sample
$ aws ec2 create-tags \
    --profile YOUR_PROFILE \
    --resources sg-12345678 i-12345678\
    --tags Key=Name,Value=SG1 Key=Name2,Value=I1 \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • `resources: `The ID of one or more resources to which you want to add the tag. For more information, see About Tags > Resource Types.

    If you specify several resources, each tag is added to each one of them.

  • tags: The tags you want to add to the specified resources. This attribute contains the following elements that you need to specify for each tag:

    • key: The key of the tag.

    • value: The value of the tag.

      If you want to specify a key only, you can set the value element to an empty string.

      The tag value must contain 255 characters maximum. However, there is no maximum length for the tag key.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The specified tags are added to the specified resources.

Removing Tags

To remove one or more tags, use the delete-tags command following this syntax:

Request sample
$ aws ec2 delete-tags \
    --profile YOUR_PROFILE \
    --resources sg-12345678 i-12345678 \
    --tags Key=Name,Value=SG1 Key=Name2,Value=I1 \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • resources: The ID of one or more resources from which you want to remove the specified tags.

    If you specify several resources, the tags are removed from all of them.

  • tags: The tags you want to delete from the specified resources. This attribute contains the following elements that you need to specify for each tag:

    • key: The key of the tag.

    • (optional) value: The value of the tag.

      • If you do not specify any value, all tags with the same key are removed from the specified resource.

      • If you set the value as an empty string, the tag is removed only if its value is set to an empty string.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The specified tags are removed from the specified resources.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.