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

Allow s3 backends to contain more then 1000 workspaces #22963

Merged
merged 1 commit into from
Dec 10, 2019

Conversation

rekahsoft
Copy link
Contributor

This resolves #15968

  • backend/remote-state/s3/backend_state.go: Prior to this commit, the terraform s3 backend did
    not paginate calls to s3 when finding workspaces, which resulted in workspaces 'disappearing'
    once they are switched away from, even though the state file still exists. This is due to the
    ListBucket operation defaulting MaxItems to 1000, so terraform s3 backends that contained
    more then 1000 workspaces did not function as expected. This rectifies this situation by
    paginating calls to s3 when finding workspaces.

Signed-off-by: Collin J. Doering [email protected]

* backend/remote-state/s3/backend_state.go: Prior to this commit, the terraform s3 backend did
  not paginate calls to s3 when finding workspaces, which resulted in workspaces 'disappearing'
  once they are switched away from, even though the state file still exists. This is due to the
  ListBucket operation defaulting MaxItems to 1000, so terraform s3 backends that contained
  more then 1000 workspaces did not function as expected. This rectifies this situation by
  paginating calls to s3 when finding workspaces.

Signed-off-by: Collin J. Doering <[email protected]>
@hashicorp-cla
Copy link

hashicorp-cla commented Oct 1, 2019

CLA assistant check
All committers have signed the CLA.

@hashibot hashibot added backend/s3 bug v0.12 Issues (primarily bugs) reported against v0.12 releases labels Oct 4, 2019
@rekahsoft
Copy link
Contributor Author

This is actively affecting us. Would it be possible to fit this into the next minor release @apparentlymart?

Also for those affected by this, you can work around it by setting workspace_key_prefix to something unique and not used. Again, all workspaces under a given workspace_key_prefix can only contain < 1000 workspaces.

@pselle pselle self-assigned this Dec 9, 2019
@pselle
Copy link
Contributor

pselle commented Dec 10, 2019

I ran the acceptance tests on this (on top of #23631) and they've passed, and I tested the fix through (i.e., make 1000+ workspaces, validated that this fixed the issue).

Test results:

$ TF_ACC=true go test -v .
=== RUN   TestBackend_impl
--- PASS: TestBackend_impl (0.00s)
=== RUN   TestBackendConfig
2019/12/10 12:57:36 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:57:37 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:57:37 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:57:37 [DEBUG] Trying to get account information via sts:GetCallerIdentity
--- PASS: TestBackendConfig (1.06s)
    backend_test.go:45: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("tf-test"), "dynamodb_table":cty.StringVal("dynamoTable"), "encrypt":cty.True, "key":cty.StringVal("state"), "region":cty.StringVal("us-west-1")}}
=== RUN   TestBackendConfig_invalidKey
--- PASS: TestBackendConfig_invalidKey (0.00s)
=== RUN   TestBackendConfig_invalidSSECustomerKeyLength
--- PASS: TestBackendConfig_invalidSSECustomerKeyLength (0.00s)
=== RUN   TestBackendConfig_invalidSSECustomerKeyEncoding
--- PASS: TestBackendConfig_invalidSSECustomerKeyEncoding (0.00s)
=== RUN   TestBackendConfig_conflictingEncryptionSchema
--- PASS: TestBackendConfig_conflictingEncryptionSchema (0.00s)
=== RUN   TestBackend
2019/12/10 12:57:37 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:57:38 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:57:38 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:57:38 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:57:41 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004e06c0),
  Bucket: "terraform-remote-s3-test-5defdc91",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/foo/testState",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:57:44 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc00028a060),
  Bucket: "terraform-remote-s3-test-5defdc91",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/bar/testState",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:57:45 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004dd590),
  Bucket: "terraform-remote-s3-test-5defdc91",
  ContentLength: 388,
  ContentType: "application/json",
  Key: "env:/bar/testState",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:57:49 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0005968d0),
  Bucket: "terraform-remote-s3-test-5defdc91",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/foo/testState",
  ServerSideEncryption: "AES256"
}
--- PASS: TestBackend (15.33s)
    backend_test.go:143: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdc91"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdc91 in us-west-2
=== RUN   TestBackendLocked
2019/12/10 12:57:52 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:57:53 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:57:53 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:57:53 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:57:53 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:57:53 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:57:53 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:57:53 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:01 [WARN] failed to fetch state md5: invalid md5
2019/12/10 12:58:02 [WARN] failed to fetch state md5: invalid md5
2019/12/10 12:58:06 [WARN] failed to fetch state md5: invalid md5
2019/12/10 12:58:08 [WARN] failed to fetch state md5: invalid md5
--- PASS: TestBackendLocked (21.75s)
    backend_test.go:161: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdca0"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-5defdca0"), "encrypt":cty.True, "key":cty.StringVal("test/state")}}
    backend_test.go:168: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdca0"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-5defdca0"), "encrypt":cty.True, "key":cty.StringVal("test/state")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdca0 in us-west-2
    backend_test.go:180: TestBackend: testing state locking for *s3.Backend
    backend_test.go:181: TestBackend: testing state locking for *s3.Backend
=== RUN   TestBackendSSECustomerKey
2019/12/10 12:58:14 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:58:15 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:58:15 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:58:15 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:18 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000604c00),
  Bucket: "terraform-remote-s3-test-5defdcb6",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/foo/test-SSE-C",
  SSECustomerAlgorithm: "AES256",
  SSECustomerKey: "\xe09\xb5\x9f\x8a\xe9\x86\xe1`k\fn͏\xdb\x11\xfb\xcb\u007f\xaa\xd8+H\b\x8d\xf6\x83H\xb9_\\\xd9",
  SSECustomerKeyMD5: "kMCssl5T9ZkzvRauhmVxAw=="
}
2019/12/10 12:58:20 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004e0960),
  Bucket: "terraform-remote-s3-test-5defdcb6",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/bar/test-SSE-C",
  SSECustomerAlgorithm: "AES256",
  SSECustomerKey: "\xe09\xb5\x9f\x8a\xe9\x86\xe1`k\fn͏\xdb\x11\xfb\xcb\u007f\xaa\xd8+H\b\x8d\xf6\x83H\xb9_\\\xd9",
  SSECustomerKeyMD5: "kMCssl5T9ZkzvRauhmVxAw=="
}
2019/12/10 12:58:21 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000596750),
  Bucket: "terraform-remote-s3-test-5defdcb6",
  ContentLength: 388,
  ContentType: "application/json",
  Key: "env:/bar/test-SSE-C",
  SSECustomerAlgorithm: "AES256",
  SSECustomerKey: "\xe09\xb5\x9f\x8a\xe9\x86\xe1`k\fn͏\xdb\x11\xfb\xcb\u007f\xaa\xd8+H\b\x8d\xf6\x83H\xb9_\\\xd9",
  SSECustomerKeyMD5: "kMCssl5T9ZkzvRauhmVxAw=="
}
2019/12/10 12:58:26 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000604cc0),
  Bucket: "terraform-remote-s3-test-5defdcb6",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/foo/test-SSE-C",
  SSECustomerAlgorithm: "AES256",
  SSECustomerKey: "\xe09\xb5\x9f\x8a\xe9\x86\xe1`k\fn͏\xdb\x11\xfb\xcb\u007f\xaa\xd8+H\b\x8d\xf6\x83H\xb9_\\\xd9",
  SSECustomerKeyMD5: "kMCssl5T9ZkzvRauhmVxAw=="
}
--- PASS: TestBackendSSECustomerKey (14.80s)
    backend_test.go:188: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdcb6"), "encrypt":cty.True, "key":cty.StringVal("test-SSE-C"), "sse_customer_key":cty.StringVal("4Dm1n4rphuFgawxuzY/bEfvLf6rYK0gIjfaDSLlfXNk=")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdcb6 in us-west-2
=== RUN   TestBackendExtraPaths
2019/12/10 12:58:29 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:58:29 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:58:29 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:58:29 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:31 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000596ba0),
  Bucket: "terraform-remote-s3-test-5defdcc5",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/s1/test/state/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:58:32 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000597950),
  Bucket: "terraform-remote-s3-test-5defdcc5",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/s2/test/state/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:58:36 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc00028b860),
  Bucket: "terraform-remote-s3-test-5defdcc5",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/s2/test/state/tfstate",
  ServerSideEncryption: "AES256"
}
--- PASS: TestBackendExtraPaths (11.07s)
    backend_test.go:207: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdcc5"), "encrypt":cty.True, "key":cty.StringVal("test/state/tfstate")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdcc5 in us-west-2
=== RUN   TestBackendPrefixInWorkspace
2019/12/10 12:58:40 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:58:41 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:58:41 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:58:41 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:43 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0006cbe00),
  Bucket: "terraform-remote-s3-test-5defdcd0",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env/env-1/test-env.tfstate"
}
--- PASS: TestBackendPrefixInWorkspace (6.25s)
    backend_test.go:335: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdcd0"), "key":cty.StringVal("test-env.tfstate"), "workspace_key_prefix":cty.StringVal("env")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdcd0 in us-west-2
=== RUN   TestKeyEnv
2019/12/10 12:58:46 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:58:47 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:58:47 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:58:47 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:48 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:58:48 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:58:48 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:58:48 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:49 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:58:50 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:58:50 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:58:50 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:58:53 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000597740),
  Bucket: "terraform-remote-s3-test-5defdcd6-0",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "foo/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:58:55 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004c4cf0),
  Bucket: "terraform-remote-s3-test-5defdcd6-0",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "bar/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:58:56 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0006cae70),
  Bucket: "terraform-remote-s3-test-5defdcd6-0",
  ContentLength: 388,
  ContentType: "application/json",
  Key: "bar/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:02 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc00036dec0),
  Bucket: "terraform-remote-s3-test-5defdcd6-0",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "foo/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:06 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0006cab70),
  Bucket: "terraform-remote-s3-test-5defdcd8-1",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "project/env:/foo/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:08 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000596d80),
  Bucket: "terraform-remote-s3-test-5defdcd8-1",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "project/env:/bar/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:09 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000604750),
  Bucket: "terraform-remote-s3-test-5defdcd8-1",
  ContentLength: 388,
  ContentType: "application/json",
  Key: "project/env:/bar/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:14 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc00036df50),
  Bucket: "terraform-remote-s3-test-5defdcd8-1",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "project/env:/foo/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:18 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004dc3c0),
  Bucket: "terraform-remote-s3-test-5defdcd9-2",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/foo/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:20 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004c58c0),
  Bucket: "terraform-remote-s3-test-5defdcd9-2",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/bar/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:21 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000604c30),
  Bucket: "terraform-remote-s3-test-5defdcd9-2",
  ContentLength: 388,
  ContentType: "application/json",
  Key: "env:/bar/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
2019/12/10 12:59:26 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0001c3aa0),
  Bucket: "terraform-remote-s3-test-5defdcd9-2",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/foo/some/paths/tfstate",
  ServerSideEncryption: "AES256"
}
--- PASS: TestKeyEnv (45.48s)
    backend_test.go:363: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdcd6-0"), "encrypt":cty.True, "key":cty.StringVal("some/paths/tfstate"), "workspace_key_prefix":cty.StringVal("")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdcd6-0 in us-west-2
    backend_test.go:374: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdcd8-1"), "encrypt":cty.True, "key":cty.StringVal("some/paths/tfstate"), "workspace_key_prefix":cty.StringVal("project/env:")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdcd8-1 in us-west-2
    backend_test.go:385: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdcd9-2"), "encrypt":cty.True, "key":cty.StringVal("some/paths/tfstate")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdcd9-2 in us-west-2
=== RUN   TestRemoteClient_impl
--- PASS: TestRemoteClient_impl (0.00s)
=== RUN   TestRemoteClient
2019/12/10 12:59:32 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:59:33 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:59:33 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:59:33 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:59:34 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0006cb050),
  Bucket: "terraform-remote-s3-test-5defdd04",
  ContentLength: 336,
  ContentType: "application/json",
  Key: "testState",
  ServerSideEncryption: "AES256"
}
--- PASS: TestRemoteClient (5.19s)
    client_test.go:27: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdd04"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdd04 in us-west-2
=== RUN   TestRemoteClientLocks
2019/12/10 12:59:37 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:59:37 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:59:37 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:59:37 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:59:37 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:59:38 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:59:38 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:59:38 [DEBUG] Trying to get account information via sts:GetCallerIdentity
--- PASS: TestRemoteClientLocks (12.26s)
    client_test.go:49: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdd09"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-5defdd09"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    client_test.go:56: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdd09"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-5defdd09"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdd09 in us-west-2
=== RUN   TestForceUnlock
2019/12/10 12:59:49 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:59:50 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:59:50 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:59:50 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 12:59:50 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 12:59:50 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 12:59:50 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 12:59:50 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 13:00:00 [WARN] failed to fetch state md5: invalid md5
2019/12/10 13:00:01 [WARN] failed to fetch state md5: invalid md5
2019/12/10 13:00:01 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004e1aa0),
  Bucket: "terraform-remote-s3-test-force-5defdd15",
  ContentLength: 157,
  ContentType: "application/json",
  Key: "env:/test/testState",
  ServerSideEncryption: "AES256"
}
--- PASS: TestForceUnlock (16.59s)
    client_test.go:87: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-force-5defdd15"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-force-5defdd15"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    client_test.go:94: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-force-5defdd15"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-force-5defdd15"), "encrypt":cty.True, "key":cty.StringVal("testState")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-force-5defdd15 in us-west-2
=== RUN   TestRemoteClient_clientMD5
2019/12/10 13:00:06 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 13:00:06 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 13:00:06 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 13:00:06 [DEBUG] Trying to get account information via sts:GetCallerIdentity
--- PASS: TestRemoteClient_clientMD5 (10.74s)
    client_test.go:164: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdd26"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-5defdd26"), "key":cty.StringVal("testState")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdd26 in us-west-2
=== RUN   TestRemoteClient_stateChecksum
2019/12/10 13:00:17 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 13:00:17 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 13:00:17 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 13:00:17 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 13:00:24 [INFO] Setting AWS metadata API timeout to 100ms
2019/12/10 13:00:24 [INFO] Ignoring AWS metadata API endpoint at default location as it doesn't return any instance-id
2019/12/10 13:00:24 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2019/12/10 13:00:24 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2019/12/10 13:00:24 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004c5320),
  Bucket: "terraform-remote-s3-test-5defdd31",
  ContentLength: 324,
  ContentType: "application/json",
  Key: "testState"
}
2019/12/10 13:00:26 [WARN] failed to fetch state md5: invalid md5
2019/12/10 13:00:26 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000596000),
  Bucket: "terraform-remote-s3-test-5defdd31",
  ContentLength: 324,
  ContentType: "application/json",
  Key: "testState"
}
2019/12/10 13:00:26 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004c5680),
  Bucket: "terraform-remote-s3-test-5defdd31",
  ContentLength: 0,
  ContentType: "application/json",
  Key: "testState"
}
2019/12/10 13:00:27 [WARN] state md5 mismatch: expected '882993921e087828402640450d933167', got ''
2019/12/10 13:00:27 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc0004e1dd0),
  Bucket: "terraform-remote-s3-test-5defdd31",
  ContentLength: 324,
  ContentType: "application/json",
  Key: "testState"
}
2019/12/10 13:00:29 [WARN] state md5 mismatch: expected '882993921e087828402640450d933167', got ''
2019/12/10 13:00:30 [WARN] state md5 mismatch: expected '882993921e087828402640450d933167', got ''
2019/12/10 13:00:30 [DEBUG] Uploading remote state to S3: {
  Body: buffer(0xc000596120),
  Bucket: "terraform-remote-s3-test-5defdd31",
  ContentLength: 324,
  ContentType: "application/json",
  Key: "testState"
}
2019/12/10 13:00:30 [INFO] retrying S3 RemoteClient.Get...
--- PASS: TestRemoteClient_stateChecksum (16.21s)
    client_test.go:212: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdd31"), "dynamodb_table":cty.StringVal("terraform-remote-s3-test-5defdd31"), "key":cty.StringVal("testState")}}
    backend_test.go:445: creating S3 bucket terraform-remote-s3-test-5defdd31 in us-west-2
    client_test.go:244: TestBackendConfig on *s3.Backend with configs.synthBody{Filename:"<TestWrapConfig>", Values:map[string]cty.Value{"bucket":cty.StringVal("terraform-remote-s3-test-5defdd31"), "key":cty.StringVal("testState")}}
PASS
ok  	github.com/hashicorp/terraform/backend/remote-state/s3	177.998s

@pselle pselle merged commit d45a4d3 into hashicorp:master Dec 10, 2019
@pselle
Copy link
Contributor

pselle commented Dec 10, 2019

Thank you for this PR!

@ghost
Copy link

ghost commented Mar 28, 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 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.

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
@rekahsoft rekahsoft deleted the s3-backend-pagination branch July 6, 2020 18:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend/s3 bug v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limited to 1000 state files with workspaces and S3 backend
4 participants