Hi,
I was trying to connect s3 bucket from VS Code, I wrote a terraform code that I wanted to run and had backend.tf file:
terraform {
backend “s3” {
bucket = “my-jenkins-terraform-project”
region = “us-east-1”
key = “jenkins-server/terraform.tfstate”
}
}
I created a user and assigned these policies: AdministratorAccess and AmazonS3FullAccess policy. I then used aws configure on VS Code and entered the access key credentials.
I also created s3 bucket policy:
{
“Version”: “2012-10-17”,
“Statement”: [
{
“Effect”: “Allow”,
“Principal”: “",
“Action”: "s3:”,
“Resource”: [
“arn:aws:s3:::my-jenkins-terraform-project”,
“arn:aws:s3:::my-jenkins-terraform-project/*”
]
}
]
}
When doing terraform init, I am getting this error:
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: DCBWGMSY1794HKH3, host id: iA6le46iX/aLfXqJRyQ1Com7vpZp7hxipBxCvltssicG/UAjo/KUuyPV7VpxzJJrATJAxo/vvNA=
Edit: Bucket region is us-east-1