Skip to content
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

Unable to create S3 buckets on local mocks since 3.0.0 #14427

Closed
ballwood opened this issue Jul 31, 2020 · 11 comments · Fixed by #14481
Closed

Unable to create S3 buckets on local mocks since 3.0.0 #14427

ballwood opened this issue Jul 31, 2020 · 11 comments · Fixed by #14481
Assignees
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Milestone

Comments

@ballwood
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

  • aws_s3_bucket

Terraform Configuration Files

provider "aws" {
  region = "eu-west-1"

  access_key = "fakeKey"
  secret_key = "fakeKey"

  skip_credentials_validation = true
  skip_metadata_api_check = true
  s3_force_path_style = true
  skip_requesting_account_id = true

  endpoints {
    s3 = "http://localhost:9090"
  }
}

resource "aws_s3_bucket" "test" {
  bucket = "test-bucket"
}

Debug Output

Panic Output

Expected Behavior

Bucket should have been created on s3 mock

Actual Behavior

Error: error getting S3 Bucket location: RequestError: send request failed caused by: dial tcp: lookup test-bucket.localhost on 192.168.1.1:53: no such host

Steps to Reproduce

  1. docker run -p 9090:9090 -t adobe/s3mock
  2. terraform apply

Important Factoids

References

@ghost ghost added the service/s3 Issues and PRs that pertain to the s3 service. label Jul 31, 2020
@ballwood ballwood changed the title Unable to create S3 buckets using mocks since 3.0 Unable to create S3 buckets using mocks since 3.0.0 Jul 31, 2020
@ballwood ballwood changed the title Unable to create S3 buckets using mocks since 3.0.0 Unable to create S3 buckets on local mocks since 3.0.0 Jul 31, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 31, 2020
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 31, 2020
@bflad bflad added this to the v3.1.0 milestone Jul 31, 2020
@bflad bflad self-assigned this Jul 31, 2020
@bflad
Copy link
Contributor

bflad commented Jul 31, 2020

Hi @ballwood 👋 Thank you for reporting this and sorry for the trouble. At the moment we don't regularly test against non-AWS implementations, so apologies this was missed, but we certainly would like to provide best effort support for this functionality. Your suggestion about threading through the provider s3_force_path_style configuration seems to make the most sense. Would you like to submit the fix?

@artamonovkirill
Copy link

Here's an example of a test with Localstack: source, CI, Gradle Build.

I'd like to convert it to a go test on s3 resource, but:

  • my go knowledge is rather limited, so it might take a while and might not be of the best quality.
  • I'm not sure where it belongs to (since it required Docker) - tests? acceptance test?

bflad added a commit that referenced this issue Aug 5, 2020
…r s3manager.GetBucketRegion calls

Reference: #14427

Previously on or after 3.0.0:

```terraform
terraform {
  required_providers {
    aws = "3.0.0"
  }

  required_version = "0.12.29"
}

provider "aws" {
  region = "eu-west-1"

  access_key = "fakeKey"
  secret_key = "fakeKey"

  s3_force_path_style         = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    s3 = "http://localhost:9090"
  }
}

resource "aws_s3_bucket" "test" {
  bucket = "test-bucket"
}
```

```console
$ docker run -p 9090:9090 -t adobe/s3mock
$ terraform apply
...
aws_s3_bucket.test: Creating...
aws_s3_bucket.test: Still creating... [10s elapsed]
aws_s3_bucket.test: Still creating... [20s elapsed]

Error: error getting S3 Bucket location: RequestError: send request failed
caused by: dial tcp: lookup test-bucket.localhost on 192.168.1.1:53: no such host

  on main.tf line 25, in resource "aws_s3_bucket" "test":
  25: resource "aws_s3_bucket" "test" {
```

Now:

```console
$ terraform apply
...
aws_s3_bucket.test: Creating...
aws_s3_bucket.test: Creation complete after 0s [id=test-bucket]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
```

Output from acceptance testing:

```
--- PASS: TestAccAWSS3Bucket_acceleration (53.30s)
--- PASS: TestAccAWSS3Bucket_AclToGrant (51.07s)
--- PASS: TestAccAWSS3Bucket_basic (31.56s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (31.65s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (25.97s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (33.67s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (55.10s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (56.01s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (31.69s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (38.29s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (32.49s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (29.00s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (31.61s)
--- PASS: TestAccAWSS3Bucket_generatedName (30.69s)
--- PASS: TestAccAWSS3Bucket_GrantToAcl (48.35s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (79.24s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (52.70s)
--- PASS: TestAccAWSS3Bucket_LifecycleRule_Expiration_EmptyConfigurationBlock (25.59s)
--- PASS: TestAccAWSS3Bucket_Logging (50.13s)
--- PASS: TestAccAWSS3Bucket_namePrefix (30.79s)
--- PASS: TestAccAWSS3Bucket_objectLock (54.26s)
--- PASS: TestAccAWSS3Bucket_Policy (73.69s)
--- PASS: TestAccAWSS3Bucket_Replication (111.61s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (66.43s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AddAccessControlTranslation (64.58s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (19.21s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (114.21s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (38.67s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (39.78s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (56.71s)
--- PASS: TestAccAWSS3Bucket_SameRegionReplicationSchemaV2 (51.20s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (12.38s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (99.87s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (148.81s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (50.58s)
--- PASS: TestAccAWSS3Bucket_UpdateGrant (80.43s)
--- PASS: TestAccAWSS3Bucket_Versioning (77.33s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (79.51s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (79.03s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (55.56s)

--- PASS: TestAccDataSourceS3Bucket_basic (28.96s)
--- PASS: TestAccDataSourceS3Bucket_website (29.28s)
```
@bflad
Copy link
Contributor

bflad commented Aug 5, 2020

@artamonovkirill you are not missing anything at the moment. 😅 Our acceptance testing framework expects that endpoints are running before testing begins and that configurations can be provided via environment variables, so we do not typically run our acceptance test against non-production AWS endpoints, such as Localstack, s3mock, etc. at the moment. We still list non-AWS implementations as best effort support due to maintainer team size and I'm not sure we have the bandwidth to change that position for now, even if submissions were made to enable that type of testing via Makefile targets and customized test configurations, etc.

Since we would like to fix this regression shortly though, please note that the fix has been submitted to passthrough the provider s3_force_path_style configuration (defaulting to false if not set) instead of hardcoding the value ( #14481) which was verified locally using the provided reproduction configuration and steps.

bflad added a commit that referenced this issue Aug 6, 2020
…r s3manager.GetBucketRegion calls (#14481)

Reference: #14427

Previously on or after 3.0.0:

```terraform
terraform {
  required_providers {
    aws = "3.0.0"
  }

  required_version = "0.12.29"
}

provider "aws" {
  region = "eu-west-1"

  access_key = "fakeKey"
  secret_key = "fakeKey"

  s3_force_path_style         = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    s3 = "http://localhost:9090"
  }
}

resource "aws_s3_bucket" "test" {
  bucket = "test-bucket"
}
```

```console
$ docker run -p 9090:9090 -t adobe/s3mock
$ terraform apply
...
aws_s3_bucket.test: Creating...
aws_s3_bucket.test: Still creating... [10s elapsed]
aws_s3_bucket.test: Still creating... [20s elapsed]

Error: error getting S3 Bucket location: RequestError: send request failed
caused by: dial tcp: lookup test-bucket.localhost on 192.168.1.1:53: no such host

  on main.tf line 25, in resource "aws_s3_bucket" "test":
  25: resource "aws_s3_bucket" "test" {
```

Now:

```console
$ terraform apply
...
aws_s3_bucket.test: Creating...
aws_s3_bucket.test: Creation complete after 0s [id=test-bucket]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
```

Output from acceptance testing:

```
--- PASS: TestAccAWSS3Bucket_acceleration (53.30s)
--- PASS: TestAccAWSS3Bucket_AclToGrant (51.07s)
--- PASS: TestAccAWSS3Bucket_basic (31.56s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (31.65s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (25.97s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (33.67s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (55.10s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (56.01s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (31.69s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (38.29s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (32.49s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (29.00s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (31.61s)
--- PASS: TestAccAWSS3Bucket_generatedName (30.69s)
--- PASS: TestAccAWSS3Bucket_GrantToAcl (48.35s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (79.24s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (52.70s)
--- PASS: TestAccAWSS3Bucket_LifecycleRule_Expiration_EmptyConfigurationBlock (25.59s)
--- PASS: TestAccAWSS3Bucket_Logging (50.13s)
--- PASS: TestAccAWSS3Bucket_namePrefix (30.79s)
--- PASS: TestAccAWSS3Bucket_objectLock (54.26s)
--- PASS: TestAccAWSS3Bucket_Policy (73.69s)
--- PASS: TestAccAWSS3Bucket_Replication (111.61s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (66.43s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AddAccessControlTranslation (64.58s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (19.21s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (114.21s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (38.67s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (39.78s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (56.71s)
--- PASS: TestAccAWSS3Bucket_SameRegionReplicationSchemaV2 (51.20s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (12.38s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (99.87s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (148.81s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (50.58s)
--- PASS: TestAccAWSS3Bucket_UpdateGrant (80.43s)
--- PASS: TestAccAWSS3Bucket_Versioning (77.33s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (79.51s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (79.03s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (55.56s)

--- PASS: TestAccDataSourceS3Bucket_basic (28.96s)
--- PASS: TestAccDataSourceS3Bucket_website (29.28s)
```
@bflad
Copy link
Contributor

bflad commented Aug 6, 2020

The fix for this (passing through the provider s3_force_path_style configuration) has been merged and will release with version 3.1.0 of the Terraform AWS Provider, likely later today. 👍

@artamonovkirill
Copy link

@bflad , thanks! 👍

@ballwood
Copy link
Author

ballwood commented Aug 7, 2020

@bflad thanks for sorting this so promptly, appreciate it

@ghost
Copy link

ghost commented Aug 7, 2020

This has been released in version 3.1.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@artamonovkirill
Copy link

@bflad , I'm still getting an error with 3.1.0 - a different one, though:
https://scans.gradle.com/s/5qmfxlaedn32c/tests/:test/AwsProviderSpec/creates%20an%20S3%20bucket%20with%203.1.0%20AWS%20provider#1

Are there other occurrences in the code where s3_force_path_style flag is ignored?

@bflad
Copy link
Contributor

bflad commented Aug 10, 2020

@artamonovkirill I think filing a separate bug report with the relevant details (e.g. what service/tooling you are using) is the most appropriate action in that case. Please do note here that the maintainers cannot guarantee full compatibility with all non-AWS tooling if they do not implement the S3 APIs correctly.

@artamonovkirill
Copy link

@bflad, thanks for the support.
I've double-checked, and the problem is indeed on the LocalStack side (localstack/localstack#2832, not related to API implementation per se though).

@ghost
Copy link

ghost commented Sep 5, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/s3 Issues and PRs that pertain to the s3 service.
Projects
None yet
3 participants