

# Update AWS resource tags for a configuration

You update the tags on a configuration in two ways. To change individual tags, call `TagResource` with the configuration's ARN and the tag keys and values that you want to set. If you supply a key that already exists, you overwrite its value, and your other tags are left in place. To replace the entire tag set at once, set the `tags` parameter when you update the configuration with `PutStorageLensConfiguration`. You can update resource tags by using the Amazon S3 console, the AWS CLI, or the AWS SDKs.

## Using the S3 console
<a name="s3-tables-storage-lens-update-tags-console"></a>

In the Amazon S3 console, you update a configuration's tags in the **General** step of the edit wizard.

**To update a configuration's tags**

1. Sign in to the AWS Management Console and open the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).

1. In the left navigation pane, choose **Storage Lens**, and then choose the **Table buckets** tab.

1. Choose the dashboard, and then choose **Edit**.

1. In the **General** step, under **Tags - optional**, edit the keys and values of your existing tags.

1. Proceed through the remaining steps, and then on the **Review and create** step, choose **Submit**.

## Using the AWS CLI
<a name="s3-tables-storage-lens-update-tags-cli"></a>

**Example**  
To change individual tags, use the `tag-resource` command. The supplied keys are added or overwritten, and other tags are left in place. To use this example, replace the `{{user input placeholders}}` with your own information.  

```
aws s3tables tag-resource --resource-arn={{arn:aws:s3tables:us-east-1:222222222222:storage-lens/your-configuration-id}} --tags={{project=lakehouse-v2}}
```

**Example**  
To replace the entire tag set, pass the complete `tags` map to the `put-storage-lens-configuration` command. Any key that you omit is removed. To use this example, replace the `{{user input placeholders}}` with your own information.  

```
aws s3tables put-storage-lens-configuration --storage-lens-id={{your-configuration-id}} --storage-lens-configuration={{file://./config.json}} --tags={{department=analytics,project=lakehouse-v2}}
```

## Using the AWS SDK for Java
<a name="s3-tables-storage-lens-update-tags-sdk-java"></a>

The following example changes individual tags on an Amazon S3 Storage Lens for Tables configuration in SDK for Java. A key that already exists is overwritten, and other tags are unchanged. To replace the entire tag set instead, call `putStorageLensConfiguration` with the complete `tags` map. To use this example, replace the `{{user input placeholders}}` with your own information.

**Example – Update tags on an Amazon S3 Storage Lens for Tables configuration**  

```Java
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3tables.S3TablesClient;
import software.amazon.awssdk.services.s3tables.model.TagResourceRequest;

import java.util.Map;

public class UpdateStorageLensTags {

    public static void main(String[] args) {
        String resourceArn = "{{arn:aws:s3tables:us-east-1:111122223333:storage-lens/your-configuration-id}}";

        try (S3TablesClient s3TablesClient = S3TablesClient.builder()
                .region(Region.{{US_EAST_1}})
                .build()) {

            s3TablesClient.tagResource(TagResourceRequest.builder()
                    .resourceArn(resourceArn)
                    .tags(Map.of("{{key-1}}", "{{new-value-1}}"))
                    .build());
        }
    }
}
```

To replace the configuration's entire tag set instead, call `putStorageLensConfiguration` with the complete `tags` map. Any key that you omit is removed.

**Example – Replace the entire tag set on an Amazon S3 Storage Lens for Tables configuration**  

```Java
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3tables.S3TablesClient;
import software.amazon.awssdk.services.s3tables.model.PutStorageLensConfigurationRequest;
import software.amazon.awssdk.services.s3tables.model.StorageLensConfiguration;

import java.util.Map;

public class ReplaceStorageLensTags {

    public static void main(String[] args) {
        String configurationId = "{{your-configuration-id}}";

        try (S3TablesClient s3TablesClient = S3TablesClient.builder()
                .region(Region.{{US_EAST_1}})
                .build()) {

            StorageLensConfiguration configuration = StorageLensConfiguration.builder()
                    .id(configurationId)
                    .isEnabled(true)
                    // Set the remaining configuration fields for your dashboard.
                    .build();

            s3TablesClient.putStorageLensConfiguration(PutStorageLensConfigurationRequest.builder()
                    .storageLensId(configurationId)
                    .storageLensConfiguration(configuration)
                    .tags(Map.of(
                            "{{key-1}}", "{{value-1}}",
                            "{{key-2}}", "{{value-2}}"))
                    .build());
        }
    }
}
```