AWS CLI를 사용한 Amazon S3 스토리지 렌즈 예시 - Amazon Simple Storage Service

AWS CLI를 사용한 Amazon S3 스토리지 렌즈 예시

S3 스토리지 렌즈는 지표를 집계하고 Amazon S3 콘솔 버킷 페이지의 계정 스냅샷 섹션에 이 정보를 표시합니다. S3 스토리지 렌즈는 또한 인사이트와 추세를 시각화하고, 이상치에 플래그를 지정하고, 스토리지 비용 최적화와 데이터 보호 모범 사례 적용을 위한 권장 사항을 수신하는 데 사용할 수 있는 대화형 대시보드를 제공합니다. 대시보드에 있는 드릴다운 옵션을 통해 조직, 계정, 버킷, 객체 또는 접두사 수준에서 인사이트를 생성할 수 있습니다. 또한 하루에 한 번 지표를 CSV 또는 Parquet 형식으로 내보내서 S3 버킷으로 전송할 수 있습니다. 자세한 내용은 Amazon S3 Storage Lens를 사용한 스토리지 활동 및 사용량 평가를 참조하세요.

다음 예시에서는 AWS Command Line Interface를 통해 S3 스토리지 렌즈를 사용하는 방법을 보여줍니다.

Amazon S3 Storage Lens 사용을 위한 도우미 파일

예제의 키 입력에 다음 JSON 파일을 사용하세요.

S3 Storage Lens 샘플 구성 JSON

config.json

config.json 파일에는 S3 스토리지 렌즈 조직 수준의 고급 지표 및 권장 사항 구성에 대한 세부 정보가 들어 있습니다. 다음 예시를 사용하려면 user input placeholders를 실제 정보로 대체하세요.

참고

고급 지표 및 권장 사항에 대해서는 추가 요금이 부과됩니다. 자세한 내용은 고급 지표 및 권장 사항을 참조하세요.

{ "Id": "SampleS3StorageLensConfiguration", //Use this property to identify your S3 Storage Lens configuration. "AwsOrg": { //Use this property when enabling S3 Storage Lens for AWS Organizations. "Arn": "arn:aws:organizations::123456789012:organization/o-abcdefgh" }, "AccountLevel": { "ActivityMetrics": { "IsEnabled":true }, "AdvancedCostOptimizationMetrics": { "IsEnabled":true }, "AdvancedDataProtectionMetrics": { "IsEnabled":true }, "DetailedStatusCodesMetrics": { "IsEnabled":true }, "BucketLevel": { "ActivityMetrics": { "IsEnabled":true }, "AdvancedDataProtectionMetrics": { "IsEnabled":true }, "AdvancedCostOptimizationMetrics": { "IsEnabled":true }, "DetailedStatusCodesMetrics": { "IsEnabled":true }, "PrefixLevel":{ "StorageMetrics":{ "IsEnabled":true, "SelectionCriteria":{ "MaxDepth":5, "MinStorageBytesPercentage":1.25, "Delimiter":"/" } } } } }, "Exclude": { //Replace with "Include" if you prefer to include Regions. "Regions": [ "eu-west-1" ], "Buckets": [ //This attribute is not supported for AWS Organizations-level configurations. "arn:aws:s3:::source_bucket1" ] }, "IsEnabled": true, //Whether the configuration is enabled "DataExport": { //Details about the metrics export "S3BucketDestination": { "OutputSchemaVersion": "V_1", "Format": "CSV", //You can add "Parquet" if you prefer. "AccountId": "111122223333", "Arn": "arn:aws:s3:::destination-bucket-name", // The destination bucket for your metrics export must be in the same Region as your S3 Storage Lens configuration. "Prefix": "prefix-for-your-export-destination", "Encryption": { "SSES3": {} } }, "CloudWatchMetrics": { "IsEnabled": true } } }

S3 Storage Lens 샘플 구성 태그 JSON

tags.json

tags.json 파일에는 S3 스토리지 렌즈 구성에 적용하려는 태그가 들어 있습니다. 이 예제를 사용하려면 user input placeholders를 사용자의 정보로 대체합니다.

[ { "Key": "key1", "Value": "value1" }, { "Key": "key2", "Value": "value2" } ]

S3 Storage Lens 샘플 구성 IAM 권한

permissions.json - 특정 대시보드 이름

이 정책 예시에서는 대시보드 이름이 지정된 S3 스토리지 렌즈 IAM permissions.json 파일을 보여줍니다. value1, us-east-1, your-dashboard-nameexample-account-id를 실제 값으로 바꾸세요.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetStorageLensConfiguration", "s3:DeleteStorageLensConfiguration", "s3:PutStorageLensConfiguration" ], "Condition": { "StringEquals": { "aws:ResourceTag/key1": "value1" } }, "Resource": "arn:aws:s3:us-east-1:example-account-id:storage-lens/your-dashboard-name" } ] }
permissions.json - 특정 대시보드 이름 없음

이 정책 예시에서는 대시보드 이름이 지정되지 않은 S3 스토리지 렌즈 IAM permissions.json 파일을 보여줍니다. value1, us-east-1example-account-id를 사용자의 값으로 바꿉니다.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetStorageLensConfiguration", "s3:DeleteStorageLensConfiguration", "s3:PutStorageLensConfiguration" ], "Condition": { "StringEquals": { "aws:ResourceTag/key1": "value1" } }, "Resource": "arn:aws:s3:us-east-1:example-account-id:storage-lens/*" } ] }

AWS CLI로 Amazon S3 스토리지 렌즈 구성 사용

AWS CLI를 사용하여 S3 스토리지 렌즈 구성을 나열, 생성, 삭제, 가져오기, 태그 지정 및 업데이트할 수 있습니다. 다음 예에서는 키 입력에 도우미 JSON 파일을 사용합니다. 이러한 예시를 사용하려면 user input placeholders를 실제 정보로 대체하세요.

S3 스토리지 렌즈 구성 생성

예 S3 스토리지 렌즈 구성 생성
aws s3control put-storage-lens-configuration --account-id=222222222222 --config-id=your-configuration-id --region=us-east-1 --storage-lens-configuration=file://./config.json --tags=file://./tags.json

태그 없이 S3 스토리지 렌즈 구성 생성

예 태그 없이 S3 스토리지 렌즈 구성 생성
aws s3control put-storage-lens-configuration --account-id=222222222222 --config-id=your-configuration-id --region=us-east-1 --storage-lens-configuration=file://./config.json

S3 Storage Lens 구성 가져오기

예 S3 Storage Lens 구성 가져오기
aws s3control get-storage-lens-configuration --account-id=222222222222 --config-id=your-configuration-id --region=us-east-1

다음 토큰이 없는 S3 스토리지 렌즈 구성 나열

예 다음 토큰이 없는 S3 스토리지 렌즈 구성 나열
aws s3control list-storage-lens-configurations --account-id=222222222222 --region=us-east-1

S3 Storage Lens 구성 나열

예 S3 Storage Lens 구성 나열
aws s3control list-storage-lens-configurations --account-id=222222222222 --region=us-east-1 --next-token=abcdefghij1234

S3 Storage Lens 구성 삭제

예 S3 Storage Lens 구성 삭제
aws s3control delete-storage-lens-configuration --account-id=222222222222 --region=us-east-1 --config-id=your-configuration-id

S3 스토리지 렌즈 구성에 태그 추가

예 S3 스토리지 렌즈 구성에 태그 추가
aws s3control put-storage-lens-configuration-tagging --account-id=222222222222 --region=us-east-1 --config-id=your-configuration-id --tags=file://./tags.json

S3 Storage Lens 구성에 대한 태그 가져오기

예 S3 Storage Lens 구성에 대한 태그 가져오기
aws s3control get-storage-lens-configuration-tagging --account-id=222222222222 --region=us-east-1 --config-id=your-configuration-id

S3 Storage Lens 구성에 대한 태그 삭제

예 S3 Storage Lens 구성에 대한 태그 삭제
aws s3control delete-storage-lens-configuration-tagging --account-id=222222222222 --region=us-east-1 --config-id=your-configuration-id

AWS CLI를 사용하여 AWS Organizations로 Amazon S3 스토리지 렌즈 사용 예시

Amazon S3 Storage Lens를 사용하여 AWS Organizations 계층 구조의 일부인 계정 모두에 대한 스토리지 지표와 사용량 데이터를 수집합니다. 자세한 내용은 AWS Organizations에서 Amazon S3 Storage Lens 사용을 참조하세요.

S3 Storage Lens에 대한 조직의 트러스트된 액세스 사용 설정

예 S3 Storage Lens에 대한 조직의 트러스트된 액세스 사용 설정
aws organizations enable-aws-service-access --service-principal storage-lens.s3.amazonaws.com

S3 Storage Lens에 대한 조직의 트러스트된 액세스 사용 중지

예 S3 Storage Lens에 대한 조직의 트러스트된 액세스 사용 중지
aws organizations disable-aws-service-access --service-principal storage-lens.s3.amazonaws.com

S3 Storage Lens에 대한 조직의 위임된 관리자 등록

예 S3 Storage Lens에 대한 조직의 위임된 관리자 등록

이 예시를 사용하려면 111122223333을 적절한 AWS 계정 ID로 바꾸세요.

aws organizations register-delegated-administrator --service-principal storage-lens.s3.amazonaws.com --account-id 111122223333

S3 Storage Lens에 대한 Organizations 위임 관리자 등록 취소

예 S3 Storage Lens에 대한 Organizations 위임 관리자 등록 취소

이 예시를 사용하려면 111122223333을 적절한 AWS 계정 ID로 바꾸세요.

aws organizations deregister-delegated-administrator --service-principal storage-lens.s3.amazonaws.com --account-id 111122223333