Terraform Remote state s3

I am trying to use the remote state s3 .I am encountering below issue when ever i run terraform init.

$ terraform init -backend-config=“access_key=xxxxxxxxxxx” -backend-config=“secret_key=xxxxxxxxxxxxx”
Initializing modules…

  • redis_cache in modules\redis

Initializing the backend…

Successfully configured the backend “s3”! Terraform will automatically
use this backend unless the backend configuration changes.
Error refreshing state: AccessDenied: Access Denied
status code: 403, request id: 9B9829ECB717527B, host id: qKEU7VRtXgAI/N5iTq2eOdz7YBRvRuNyulKl6nJofnoUnociQ1hjA0Cr02YWGxCfC+9yEGA3Eos=

That looks like the sort of error you’d see if the AWS access key doesn’t have permission to access the S3 bucket. Have you tried using those same credentials with the AWS S3 client to make sure you can access the files?

I know for certain you have to declare both for the backend and for the provider in this case they are the same… however you still need to declare both. Keys can be the same. Hope this helps.

This did it for me: https://stackoverflow.com/a/57599460