[AWS/Cloudformation]S3 Backet cheet sheet

# 1. S3 Backet

<https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html>  
User Guide (API Version 2010-05-15)

## 1.1. Property

| Reqired | Name                      | Type                                  | Memo                            |
| ------: | ------------------------- | ------------------------------------- | ------------------------------- |
|       - | AccessControl             | String                                | 事前定義されたアクセス許可      |
|       - | AccelerateConfiguration   | AccelerateConfiguration               | transfer acceleration state     |
|       - | AnalyticsConfigurations   | List of Bucket AnalyticsConfiguration | 分析フィルタの設定              |
|       - | BucketEncryption          | BucketEncryption                      | デフォルトの暗号化              |
|       - | BucketName                | String                                | 指定しないと物理 ID を生成      |
|       - | CorsConfiguration         | Bucket CorsConfiguration              | Cross-Origin Resource Sharing   |
|       - | InventoryConfigurations   | List of Bucket InventoryConfiguration | バケットのインベントリ設定      |
|       - | LifecycleConfiguration    | Bucket LifecycleConfiguration         | 存続期間中の管理方法            |
|       - | LoggingConfiguration      | Bucket LoggingConfiguration           | ログの保管場所を定義            |
|       - | MetricsConfigurations     | List of Bucket MetricsConfiguration   | メトリクス設定                  |
|       - | NotificationConfiguration | Bucket NotificationConfiguration      | バケットの通知の処理            |
|       - | ReplicationConfiguration  | Bucket ReplicationConfiguration       | レプリケーション/バージョニング |
|       - | Tags                      | List of Tag                           | 7 つに制限することをお勧め      |
|       - | VersioningConfiguration   | Bucket VersioningConfiguration        | 複数のバリアント/バージョニング |
|       - | WebsiteConfiguration      | WebsiteConfiguration                  | ウェブサイト設定                |

- Naming of bucket
  - 小文字、数字、ピリオド (.)、およびダッシュ (-) only

### 1.1.1. Configuration

#### 1.1.1.1. AccelerateConfiguration

| Reqired | Name               | Type   |
| ------: | ------------------ | ------ |
|       ! | AccelerationStatus | String |

#### 1.1.1.2. AnalyticsConfiguration

| Reqired | Name                 | Type                        |
| ------: | -------------------- | --------------------------- |
|       ! | Id                   | String                      |
|       ! | StorageClassAnalysis | Bucket StorageClassAnalysis |
|       - | TagFilters           | List of Bucket TagFilter    |
|       - | Prefix               | String                      |

#### 1.1.1.3. BucketEncryption

| Reqired | Name                              | Type                                    |
| ------: | --------------------------------- | --------------------------------------- |
|       ! | ServerSideEncryptionConfiguration | List of Bucket ServerSideEncryptionRule |

#### 1.1.1.4. CorsConfiguration

| Reqired | Name           | Type           |
| ------: | -------------- | -------------- |
|       ! | AllowedMethods | List of String |
|       ! | AllowedOrigins | List of String |
|       - | AllowedHeaders | List of String |
|       - | ExposedHeaders | List of String |
|       - | Id             | String         |
|       - | MaxAge         | Integer        |

#### 1.1.1.5. InventoryConfiguration

| Reqired | Name                   | Type               |
| ------: | ---------------------- | ------------------ |
|       ! | Destination            | Bucket Destination |
|       ! | Enabled                | Boolean            |
|       ! | Id                     | String             |
|       ! | IncludedObjectVersions | String             |
|       ! | ScheduleFrequency      | String             |
|       - | OptionalFields         | List of String     |
|       - | Prefix                 | String             |

#### 1.1.1.6. LifecycleConfiguration

| Reqired | Name  | Type                |
| ------: | ----- | ------------------- |
|       - | Rules | List of Bucket Rule |

#### 1.1.1.7. LoggingConfiguration

| Reqired | Name                  | Type   |
| ------: | --------------------- | ------ |
|       - | DestinationBucketName | String |
|       - | LogFilePrefix         | String |

#### 1.1.1.8. MetricsConfiguration

| Reqired | Name       | Type                     |
| ------: | ---------- | ------------------------ |
|       ! | Id         | String                   |
|       - | Prefix     | String                   |
|       - | TagFilters | List of Bucket TagFilter |

#### 1.1.1.9. NotificationConfiguration

| Reqired | Name                 | Type                        |
| ------: | -------------------- | --------------------------- |
|       - | LambdaConfigurations | List of LambdaConfiguration |
|       - | QueueConfigurations  | List of QueueConfiguration  |
|       - | TopicConfigurations  | List of TopicConfiguration  |

#### 1.1.1.10. PublicAccessBlockConfiguration

| Reqired | Name                  | Type    |
| ------: | --------------------- | ------- |
|       - | BlockPublicAcls       | Boolean |
|       - | BlockPublicPolicy     | Boolean |
|       - | IgnorePublicAcls      | Boolean |
|       - | RestrictPublicBuckets | Boolean |

#### 1.1.1.11. ReplicationConfiguration

| Reqired | Name  | Type                           |
| ------: | ----- | ------------------------------ |
|       ! | Role  | String                         |
|       ! | Rules | List of Bucket ReplicationRule |

#### 1.1.1.12. VersioningConfiguration

| Reqired | Name   | Type   |
| ------: | ------ | ------ |
|       ! | Status | String |

#### 1.1.1.13. Website Configuration

| Reqired | Name                  | Type                                                 |
| ------: | --------------------- | ---------------------------------------------------- |
|       ! | IndexDocument         | String                                               |
|       - | ErrorDocument         | String                                               |
|       - | RedirectAllRequestsTo | List of S3 Website Redirect All Requests To Property |
|       - | RoutingRules          | List of S3 Website Routing Rules Property            |

### 1.1.2. Rules

#### 1.1.2.1. Bucket Rule

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule.html

{
  "AbortIncompleteMultipartUpload" : AbortIncompleteMultipartUpload,
  "ExpirationDate" : String,
  "ExpirationInDays" : Integer,
  "Id" : String,
  "NoncurrentVersionExpirationInDays" : Integer,
  "NoncurrentVersionTransition (deprecated)" : NoncurrentVersionTransition,
  "NoncurrentVersionTransitions" : [ NoncurrentVersionTransition, ... ],
  "Prefix" : String,
  "Status" : String,
  "TagFilters" : [ TagFilter, ... ],
  "Transition (deprecated)" : Transition,
  "Transitions" : [ Transition, ... ]
}

#### 1.1.2.2. ServerSideEncryptionRule

| Reqired | Name           | Type   |
| ------: | -------------- | ------ |
|       ! | SSEAlgorithm   | String |
|       - | KMSMasterKeyID | String |

#### 1.1.2.3. CorsRule

| Reqired | Name      | Type                    |
| ------: | --------- | ----------------------- |
|       - | CorsRules | List of Bucket CorsRule |

#### 1.1.2.4. ReplicationRule

| Reqired | Name                    | Type                           |
| ------: | ----------------------- | ------------------------------ |
|       ! | Destination             | Bucket ReplicationDestination  |
|       ! | Prefix                  | String                         |
|       ! | Status                  | String                         |
|       - | Id                      | String                         |
|       - | SourceSelectionCriteria | Bucket SourceSelectionCriteria |

### 1.1.3. Other

#### 1.1.3.1. TagFilter

| Reqired | Name  | Type   |
| ------: | ----- | ------ |
|       ! | Key   | String |
|       ! | Value | String |

#### 1.1.3.2. StorageClassAnalysis

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-storageclassanalysis.html

#### 1.1.3.3. ServerSideEncryptionByDefault

| Reqired | Name                          | Type                                         |
| ------: | ----------------------------- | -------------------------------------------- |
|       - | ServerSideEncryptionByDefault | List of Bucket ServerSideEncryptionByDefault |

#### 1.1.3.4. Bucket Destination

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-destination.html

#### 1.1.3.5. AbortIncompleteMultipartUpload

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-abortincompletemultipartupload.html

#### 1.1.3.6. NoncurrentVersionTransition

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule-noncurrentversiontransition.html

#### 1.1.3.7. Bucket Transition

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-lifecycleconfig-rule-transition.html

## 1.2. S3 Website Configuration

### 1.2.1. Property

#### 1.2.1.1. Redirect All Requests

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules.html

#### 1.2.1.2. Routing Rules

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration-routingrules.html

## 1.3. Returns

| Name                  | Type                 | ...        |
| --------------------- | -------------------- | ---------- |
| Ref                   | logical ID           | -          |
| (Arn)                 | Amazon Resource Name | Fn::GetAtt |
| (DomainName)          | IPv4 DNS             | Fn::GetAtt |
| (DualStackDomainName) | IPv6 DNS             | Fn::GetAtt |
| (RegionalDomainName)  | regional domain name | Fn::GetAtt |
| (WebsiteURL)          | website endpoint     | Fn::GetAtt |