-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provider/aws: Added S3 Bucket replication #10552
Conversation
66ee322
to
d3ac6a2
Compare
e6c358a
to
3026b37
Compare
a13ee5b
to
dc2e657
Compare
@Ninir hi there! Sir, keep being amazing! 🍰 ❤️ |
} | ||
|
||
log.Printf("[DEBUG] S3 Bucket: %s, read replication configuration: %v", d.Id(), replication) | ||
if r := replication.ReplicationConfiguration; r != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only comment I have here is to extract this into a flatten function - this will allow the code to be a little more concise in this area
I suggest something like this:
if replication.ReplicationConfiguration != nil {
if err := d.Set("replication_configuration", flattenAwsS3BucketReplicationConfiguration(replication.ReplicationConfiguration)); err != nil {
log.Printf("[DEBUG] Error setting replication configuration: %s", err)
return err
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Ninir
this is a great PR! I may 1 comment inline about extracting code to functions to keep the code concise in the Create / Read and Update areas
May be worth having a look at seeing what you think
It's not a huge blocker but would be a nice addition
Paul
dc2e657
to
f1ef3ea
Compare
@kwilczynski 😳 thank you good sir! @stack72 +1 for the decoupling, just updated it! thanks for the suggestion :) $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSS3Bucket_Replication'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/12/07 16:22:20 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSS3Bucket_Replication -timeout 120m
=== RUN TestAccAWSS3Bucket_Replication
--- PASS: TestAccAWSS3Bucket_Replication (122.05s)
=== RUN TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (40.16s)
PASS
ok github.com/hashicorp/terraform/builtin/providers/aws 162.244s |
Hi @Ninir Not sure what the issue is here:
Paul |
f1ef3ea
to
14419bb
Compare
14419bb
to
45ab8d8
Compare
@stack72 Ok found the issue! 😄 Thus, if you use the callee region to create the source bucket (explicitly set to us-west-2 in this case), and use a provider for the other one, then it works fine. I ran tests 3 times to be sure, all with success. I suspect an issue with providerFactories, that I will investigate later on. To sum-up: use us-west-2 as an env var for the source bucket, and eu-west-1 with a provider for the destination bucket. Here is the output: $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSS3Bucket_Replication'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/12/07 23:19:50 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSS3Bucket_Replication -timeout 120m
=== RUN TestAccAWSS3Bucket_Replication
--- PASS: TestAccAWSS3Bucket_Replication (113.14s)
=== RUN TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (37.65s)
PASS
ok github.com/hashicorp/terraform/builtin/providers/aws 150.817s |
@Ninir that's an amazing find! Good work :) This now LGTM
|
Thanks to both of you for hints and quick reviews :) |
Hello – I'm still seeing failures here in our CI:
Local runs produce similarly inconsistent results:
|
Hi @catsby Are you having success & failures or simply failures? This makes me think this is somehow related to the way provider are managed in tests. Never happened during the plan/apply phase, when doing it manually. Also, I remember seeing issues with providers issues too. 'Will investigate as soon as possible. |
The failures seem inconsistent. Sometimes it's |
Hi @catsby While playing & investigating this S3 Replication issue related on testacc, I'm still really suspecting something done here: https://github.com/hashicorp/terraform/blob/master/builtin/providers/aws/resource_aws_s3_bucket_test.go#L609-L616 I can't reproduce any issue when using the compiled binary & playing with a flat tf file manually. However, it happens a lot when using the testing framework. What are your thoughts on this? |
That block of code seems to construct a slice of Providers and feeds it into the destroy method, as a way of saying "check these provider configs for the object in order to destroy it" From I see, that block only creates a single provider, with no region specified, so I assume it's pulling that from the env of the machine running it (Either our CI, or a local machine, etc). It's kind of unclear to me what the intent is there. If we know the regions we may just want to do this manually (change regions and try again) without the factories, sort of like I do here: Please let me know if this is something you can tackle, otherwise I'll try to get to it... |
Hi @catsby I am off for 10 days :/ I'll be happy to let you handle it! Otherwise, I'll do it when i'll get back on a computer :) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Reasonning
This adds the S3 Bucket replication.
Related Issues
Closes #7490
Acceptance tests
Sometimes, tests are failing and it is said that
S3Bucket error: BucketRegionError: incorrect region, the bucket is not in 'eu-west-1' region
, whereas buckets are created. I think it is related to the providerFactories stuff, but can't tell without any investigation.However, I used this configuration (the one i added to the documentation) to check the compiled binary, and played with it (adding, removing, updating, etc etc.):