通过api/cli启用和禁用S3复制规则 [英] Enabling and Disabling a S3 Replication Rule through api/cli
问题描述
我在S3存储桶上设置了复制规则,以填充预生产存储桶以进行测试.这意味着我将希望能够轻松地打开和关闭复制,并可能在必要时转储并刷新复制存储桶.我正在为此创建脚本,但是很难找到一种在使用AWS控制台之外轻松打开和关闭复制规则的方法.
I have set up a replication rule on my S3 bucket to populate a preprod bucket for testing purposes. This means I will want to be able to turn the replication on and off easily, and likely dump and refresh the replication bucket as necessary. I'm creating a script for this but am having a hard time finding a way to easily turn the replication rule on and off outside of using the AWS Console.
除了存储桶复制功能之外,还有其他选择吗?可以,但是基本上每次都会重新复制整个复制配置,而不仅仅是启用或禁用现有复制配置.
Is there an option beyond put-bucket-replication? That works but is basically restating the whole replication config each time, instead of just enabling or disabling the existing one.
推荐答案
看起来唯一的解决方案是传递状态为禁用或启用的不同put-bucket复制.以下使用python和boto3禁用的示例:
It looks like the only solution is to pass different put-bucket-replications with the Status as disabled or enabled. Example of disabled below using python and boto3:
import boto3
client = boto3.client('s3')
##Enable
client.put_bucket_replication(Bucket='yoursourcebucketname', ReplicationConfiguration={
"Role": "arn:aws:iam::999999999:role/service-role/yourrolename",
"Rules": [
{
"Status": "Disabled",
"Priority": 1,
"DeleteMarkerReplication": { "Status": "Disabled" },
"Filter" : { "Prefix": ""},
"Destination": {
"Bucket": "arn:aws:s3:::yourlandingbucket",
"Account": "838382828"
}
}
]
}
)
这篇关于通过api/cli启用和禁用S3复制规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!