Difference between revisions of "Terraform S3 backend"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 7: Line 7:
 
     [[bucket]] = "[[aws s3 ls|your-terraform-states]]"
 
     [[bucket]] = "[[aws s3 ls|your-terraform-states]]"
 
     [[Terraform S3 backend|key]]<ref>https://www.terraform.io/docs/language/settings/backends/s3.html#key</ref>    = "[[terraform.tfstate]]"
 
     [[Terraform S3 backend|key]]<ref>https://www.terraform.io/docs/language/settings/backends/s3.html#key</ref>    = "[[terraform.tfstate]]"
     [[profile]] = "your-profile"
+
     [[Terraform S3 backend: profile|profile]] = "your-profile"
 
   }
 
   }
 
  }
 
  }

Revision as of 15:57, 16 March 2023

Terraform S3 backend.

Basic S3 example in backend.tf

terraform {
  backend "s3" {
    bucket = "your-terraform-states"
    key[1]    = "terraform.tfstate"
    profile = "your-profile"
  }
}

https://www.terraform.io/docs/language/settings/backends/s3.html#example-configuration

terraform {
  backend "s3" {
    bucket = "mybucket"
    key    = "path/to/my/key"
    region = "us-east-1"
  }
}

Example including DynamoDB table

terraform {
  backend "s3" {
    bucket = "your-terraform-states"
    key[2]    = "terraform.tfstate"
    region = "us-west-2"
    dynamodb_table = "your-terraform-states"
    profile = "your-profile"
    workspace_key_prefix = "your-workspace"
  }
}
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: JDK297FD1E5GY3TT, host id: JJJ1ThvIKmNSYOO3h2IZFECn9l8DnsofwXWk4F6a9/nzrqgNNbOzyw9d2PcAXSb4DDYwkr/VNWZ0

S3 backend errors

Related terms

See also

  • https://www.terraform.io/docs/language/settings/backends/s3.html#key
  • https://www.terraform.io/docs/language/settings/backends/s3.html#key
  • Advertising: