- Implementing Cloud Design Patterns for AWS(Second Edition)
- Sean Keery Clive Harber Marcus Young
- 244字
- 2021-06-24 15:11:59
Hierarchical storage management
S3 can be configured to use global or local buckets. Investigate your latency requirements before choosing the global option. You can use replication to synchronize your objects across regions if eventual consistency is acceptable—the following code sample shows how this might be achieved, but should not be used verbatim:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:GetReplicationConfiguration",
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"${aws_s3_bucket.bucket.arn}"
]
},
-----------------------------------------------------------------------
resource "aws_iam_policy_attachment" "replication" {
name = "tf-iam-role-attachment-replication-12345"
roles = ["${aws_iam_role.replication.name}"]
policy_arn = "${aws_iam_policy.replication.arn}"
}
resource "aws_s3_bucket" "destination" {
bucket = "tf-test-bucket-destination-12345"
region = "us-west-1"
versioning {
enabled = true
}
}
-----------------------------------------------------------------------
replication_configuration {
role = "${aws_iam_role.replication.arn}"
rules {
id = "foobar"
prefix = "foo"
status = "Enabled"
destination {
bucket = "${aws_s3_bucket.destination.arn}"
storage_class = "STANDARD"
}
}
}
}
The complete version of the preceding code block can be found in the GitHub page: https://github.com/PacktPublishing/Implementing-Cloud-Design-Patterns-for-AWS-Second-Edition/tree/master/Chapter03.
Storage life cycle policies can also be attached to your buckets, which will move infrequently accessed object to less available and more inexpensive storage:
resource "aws_s3_bucket" "versioning_bucket" {
bucket = "my-versioning-bucket"
acl = "private"
versioning {
enabled = true
}
lifecycle_rule {
prefix = "config/"
enabled = true
noncurrent_version_transition {
days = 30
storage_class = "STANDARD_IA"
}
noncurrent_version_transition {
days = 60
storage_class = "GLACIER"
}
noncurrent_version_expiration {
days = 90
}
}
}
Remember that, even though read speeds and bandwidth decrease with lower storage classes, object durability remains very high (such as ten nines).
推薦閱讀
- Mobile-first Bootstrap
- Arch Linux Environment Setup How-to
- 嵌入式應(yīng)用程序設(shè)計(jì)綜合教程(微課版)
- Installing and Configuring Windows 10:70-698 Exam Guide
- Instant Optimizing Embedded Systems using Busybox
- macOS效率手冊
- Mastering Reactive JavaScript
- Windows Server 2012網(wǎng)絡(luò)操作系統(tǒng)項(xiàng)目教程(第4版)
- OpenSolaris設(shè)備驅(qū)動(dòng)原理與開發(fā)
- Cassandra 3.x High Availability(Second Edition)
- Windows 7使用詳解(修訂版)
- Heroku Cloud Application Development
- Windows Vista終極技巧金典
- iOS 10 開發(fā)指南
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)踐教程(Windows 7+MS Office 2010)