本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/s3.S3.DeleteBucketReplication方法的典型用法代码示例。如果您正苦于以下问题:Golang S3.DeleteBucketReplication方法的具体用法?Golang S3.DeleteBucketReplication怎么用?Golang S3.DeleteBucketReplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/s3.S3
的用法示例。
在下文中一共展示了S3.DeleteBucketReplication方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resourceAwsS3BucketReplicationConfigurationUpdate
func resourceAwsS3BucketReplicationConfigurationUpdate(s3conn *s3.S3, d *schema.ResourceData) error {
bucket := d.Get("bucket").(string)
replicationConfiguration := d.Get("replication_configuration").([]interface{})
if len(replicationConfiguration) == 0 {
i := &s3.DeleteBucketReplicationInput{
Bucket: aws.String(bucket),
}
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
if _, err := s3conn.DeleteBucketReplication(i); err != nil {
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return fmt.Errorf("Error removing S3 bucket replication: %s", err)
}
return nil
}
hasVersioning := false
// Validate that bucket versioning is enabled
if versioning, ok := d.GetOk("versioning"); ok {
v := versioning.([]interface{})
if v[0].(map[string]interface{})["enabled"].(bool) {
hasVersioning = true
}
}
if !hasVersioning {
return fmt.Errorf("versioning must be enabled to allow S3 bucket replication")
}
c := replicationConfiguration[0].(map[string]interface{})
rc := &s3.ReplicationConfiguration{}
if val, ok := c["role"]; ok {
rc.Role = aws.String(val.(string))
}
rcRules := c["rules"].(*schema.Set).List()
rules := []*s3.ReplicationRule{}
for _, v := range rcRules {
rr := v.(map[string]interface{})
rcRule := &s3.ReplicationRule{
Prefix: aws.String(rr["prefix"].(string)),
Status: aws.String(rr["status"].(string)),
}
if rrid, ok := rr["id"]; ok {
rcRule.ID = aws.String(rrid.(string))
}
ruleDestination := &s3.Destination{}
if destination, ok := rr["destination"]; ok {
dest := destination.(*schema.Set).List()
bd := dest[0].(map[string]interface{})
ruleDestination.Bucket = aws.String(bd["bucket"].(string))
if storageClass, ok := bd["storage_class"]; ok {
ruleDestination.StorageClass = aws.String(storageClass.(string))
}
}
rcRule.Destination = ruleDestination
rules = append(rules, rcRule)
}
rc.Rules = rules
i := &s3.PutBucketReplicationInput{
Bucket: aws.String(bucket),
ReplicationConfiguration: rc,
}
log.Printf("[DEBUG] S3 put bucket replication configuration: %#v", i)
_, err := s3conn.PutBucketReplication(i)
if err != nil {
return fmt.Errorf("Error putting S3 replication configuration: %s", err)
}
return nil
}