Storage Lens 대시보드에 AWS 리소스 태그 추가

Storage Lens 대시보드에 AWS 리소스 태그 추가

다음 예제는 S3 Storage Lens 대시보드에 AWS 리소스 태그를 추가하는 방법을 보여줘요. Amazon S3 콘솔, AWS Command Line Interface(AWS CLI), AWS SDK for Java로 리소스 태그를 추가할 수 있어요.

출처: Add AWS resource tags to a Storage Lens dashboard

본문

Storage Lens 대시보드에 AWS 리소스 태그 추가

  1. AWS Management Console에 로그인하고 Amazon S3 콘솔(https://console.aws.amazon.com/s3/)을 엽니다.
  2. 왼쪽 탐색 패널에서 Storage Lens 로 이동합니다.
  3. 대시보드(Dashboards) 를 선택합니다.
  4. 업데이트할 Storage Lens 대시보드의 라디오 버튼을 선택합니다. 그런 다음 편집(Edit) 을 선택합니다.
  5. 일반(General) 아래에서 태그 추가(Add tag) 를 선택합니다.
  6. 태그 추가(Add tag) 페이지에서 새 키-값 쌍을 추가합니다.

기존 태그와 같은 키를 가진 새 태그를 추가하면 이전 태그 값이 덮어써져요.

  1. (선택) 새 태그를 두 개 이상 추가하려면 태그 추가(Add tag) 를 다시 선택해 새 항목을 계속 추가합니다. Storage Lens 대시보드에 최대 50개의 AWS 리소스 태그를 추가할 수 있어요.
  2. (선택) 방금 추가한 항목을 제거하려면 제거할 태그 옆의 제거(Remove) 를 선택합니다.
  3. 변경 사항 저장(Save changes) 을 선택합니다.

예제

다음 예제 명령은 S3 Storage Lens 대시보드 구성에 태그를 추가해요. 이 예제를 사용하려면 사용자 입력 자리 표시자를 자신의 정보로 교체하세요.

aws s3control put-storage-lens-configuration-tagging --account-id= 222222222222 --region= us-east-1 --config-id= your-configuration-id --tags= file://./tags.json

다음 예제는 SDK for Java에서 Amazon S3 Storage Lens 구성에 태그를 추가해요. 이 예제를 사용하려면 사용자 입력 자리 표시자를 자신의 정보로 교체하세요.

예제: S3 Storage Lens 구성에 태그 추가

package aws.example.s3control;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.s3control.AWSS3Control;
import com.amazonaws.services.s3control.AWSS3ControlClient;
import com.amazonaws.services.s3control.model.PutStorageLensConfigurationTaggingRequest;
import com.amazonaws.services.s3control.model.StorageLensTag;

import java.util.Arrays;
import java.util.List;

import static com.amazonaws.regions.Regions. US_WEST_2 ;

public class PutDashboardTagging {
    public static void main(String[] args) {
        String configurationId = " ConfigurationId ";
        String sourceAccountId = " 111122223333 ";

        try {
            List<StorageLensTag> tags = Arrays.asList(
                    new StorageLensTag().withKey(" key-1 ").withValue(" value-1 "),
                    new StorageLensTag().withKey(" key-2 ").withValue(" value-2 ")
            );

            AWSS3Control s3ControlClient = AWSS3ControlClient.builder()
                    .withCredentials(new ProfileCredentialsProvider())
                    .withRegion( US_WEST_2 )
                    .build();

            s3ControlClient.putStorageLensConfigurationTagging(new PutStorageLensConfigurationTaggingRequest()
                    .withAccountId(sourceAccountId)
                    .withConfigId(configurationId)
                    .withTags(tags)
            );
        } catch (AmazonServiceException e) {
            // The call was transmitted successfully, but Amazon S3 couldn't process
            // it and returned an error response.
            e.printStackTrace();
        } catch (SdkClientException e) {
            // Amazon S3 couldn't be contacted for a response, or the client
            // couldn't parse the response from Amazon S3.
            e.printStackTrace();
        }
    }
}

더 알아보기