

# Amazon S3 ストレージレンズを使用するためのヘルパーファイル
<a name="S3LensHelperFilesCLI"></a>

次の JSON ファイルとキー入力を例として使用します。

## JSON の S3 Storage Lens 例の設定
<a name="S3LensHelperFilesSampleConfigurationCLI"></a>

**Example `config.json`**  
`config.json` ファイルには、S3 ストレージレンズの組織レベルの*高度なメトリクスとレコメンデーション*に関する設定の詳細が含まれています。次の例を使用するには、`{{user input placeholders}}` をユーザー自身の情報に置き換えます。  
高度なメトリクスとレコメンデーションには追加料金が適用されます。詳細については、「[高度なメトリクスとレコメンデーション事項](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage_lens_basics_metrics_recommendations.html#storage_lens_basics_metrics_selection)」を参照してください。

```
{
  "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:::{{{{amzn-s3-demo-source-bucket}}}}"
    ]
  },
  "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:::{{
{{amzn-s3-demo-destination-bucket}}}}", // 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}}
    }
  }
}
```

## JSON の Storage Lens グループを使用した S3 Storage Lens の設定例
<a name="StorageLensGroupsHelperFilesCLI"></a>

**Example `config.json`**  

`config.json` ファイルには、Storage Lens グループを使用する際に Storage Lens 設定に適用する詳細が含まれています。例を使用するには、`{{user input placeholders}}` をユーザー自身の情報に置き換えます。

すべての Storage Lens グループをダッシュボードにアタッチするには、Storage Lens 設定を以下の構文で更新します。

```
{
  "Id": "ExampleS3StorageLensConfiguration",
  "AccountLevel": {
    "ActivityMetrics": {
      "IsEnabled":{{true}}
    },
    "AdvancedCostOptimizationMetrics": {
      "IsEnabled":{{true}}
    },
    "AdvancedDataProtectionMetrics": {
      "IsEnabled":true
    },
    "BucketLevel": {
      "ActivityMetrics": {
      "IsEnabled":{{true}}
      },
    "StorageLensGroupLevel": {},
  "IsEnabled": {{true}}
}
```

Storage Lens ダッシュボード設定に 2 つの Storage Lens グループ ({{slg-1}} と {{slg-2}}) のみを含めるには、次の構文を使用します。

```
{
  "Id": "{{ExampleS3StorageLensConfiguration}}",
  "AccountLevel": {
    "ActivityMetrics": {
      "IsEnabled":{{true}}
    },
    "AdvancedCostOptimizationMetrics": {
      "IsEnabled":{{true}}
    },
    "AdvancedDataProtectionMetrics": {
      "IsEnabled":{{true}}
    },
    "BucketLevel": {
      "ActivityMetrics": {
      "IsEnabled":{{true}}
      },
   "StorageLensGroupLevel": {
        "SelectionCriteria": {
            "Include": [
                "arn:aws:s3:{{us-east-1}}:{{111122223333}}:storage-lens-group/{{slg-1}}",
                "arn:aws:s3:{{us-east-1}}:{{444455556666}}:storage-lens-group/{{slg-2}}"
            ]
    },
  "IsEnabled": {{true}}
}
```

特定の Storage Lens グループのみがダッシュボード設定にアタッチされないようにするには、次の構文を使用します。

```
{
  "Id": "{{ExampleS3StorageLensConfiguration}}",
  "AccountLevel": {
    "ActivityMetrics": {
      "IsEnabled":{{true}}
    },
    "AdvancedCostOptimizationMetrics": {
      "IsEnabled":{{true}}
    },
    "AdvancedDataProtectionMetrics": {
      "IsEnabled":{{true}}
    },
    "BucketLevel": {
      "ActivityMetrics": {
      "IsEnabled":{{true}}
      },
   "StorageLensGroupLevel": {
        "SelectionCriteria": {
            "Exclude": [
                "arn:aws:s3:{{us-east-1}}:{{111122223333}}:storage-lens-group/{{slg-1}}",
                "arn:aws:s3:{{us-east-1}}:{{444455556666}}:storage-lens-group/{{slg-2}}"
            ]
    },
  "IsEnabled": {{true}}
}
```

## JSON の S3 Storage Lens タグ例の設定
<a name="S3LensHelperFilesSampleConfigurationTagsCLI"></a>

**Example `tags.json`**  
`tags.json` ファイルには、S3 ストレージレンズ設定に適用するためのタグが含まれています。この例を実行するには、`{{user input placeholders}}` をユーザー自身の情報に置き換えます。  

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

## S3 Storage Lens での IAM アクセス許可の設定例
<a name="S3LensHelperFilesSampleConfigurationIAMPermissionsCLI"></a>

**Example `permissions.json` — 特定のダッシュボード名**  
このポリシー例は、特定のダッシュボード名が指定されている S3 ストレージレンズ IAM アクセス許可を示しています。{{`value1`}}、`{{us-east-1}}`、`{{your-dashboard-name}}`、`{{example-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}}:{{111122223333}}:storage-lens/{{your-dashboard-name}}"
        }
    ]
}
```

**Example `permissions.json` — 特定のダッシュボード名がない場合**  
このポリシー例は、特定のダッシュボード名が指定されていない S3 ストレージレンズ IAM アクセス許可を示しています。{{`value1`}}、`{{us-east-1}}`、`{{example-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}}:{{111122223333}}:storage-lens/*"
        }
    ]
}
```