Editing Terraform S3 backend

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
[[Terraform]] [[S3]] [[backend]].  
+
[[Terraform]] [[S3]] backend.  
 
* https://www.terraform.io/docs/language/settings/backends/s3.html
 
* https://www.terraform.io/docs/language/settings/backends/s3.html
  
== Basic S3 examples in [[backend.tf]] ==
+
== Example ==
terraform {
 
  backend "s3" {
 
    [[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: profile|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"
 
  }
 
}
 
 
 
 
 
#This simple example will prompt you for bucket name once you executed [[terraform init]]
 
terraform {
 
  backend "s3" {
 
  }
 
}
 
 
 
== Example including [[DynamoDB]] table ==
 
 
  terraform {
 
  terraform {
 
   backend "s3" {
 
   backend "s3" {
 
     [[bucket]] = "your-terraform-states"
 
     [[bucket]] = "your-terraform-states"
     [[key]]<ref>https://www.terraform.io/docs/language/settings/backends/s3.html#key</ref>   = "[[terraform.tfstate]]"
+
     key    = "terraform.tfstate"
 
     region = "[[us-west-2]]"
 
     region = "[[us-west-2]]"
 
     [[dynamodb_table]] = "your-terraform-states"
 
     [[dynamodb_table]] = "your-terraform-states"
Line 40: Line 15:
  
 
* <code>[[profile]]</code>: https://www.terraform.io/docs/language/settings/backends/s3.html#profile
 
* <code>[[profile]]</code>: https://www.terraform.io/docs/language/settings/backends/s3.html#profile
* <code>[[key]]</code>: path to the [[state file]] inside the [[S3 Bucket]]. https://www.terraform.io/docs/language/settings/backends/s3.html#key
+
* <code>key</code>: path to the [[state file]] inside the [[S3 Bucket]]. https://www.terraform.io/docs/language/settings/backends/s3.html#key
  
 
  Successfully configured the backend "s3"! Terraform will automatically
 
  Successfully configured the backend "s3"! Terraform will automatically
Line 47: Line 22:
  
 
== S3 backend errors ==
 
== S3 backend errors ==
* <code>[[Error: Backend configuration changed]]</code>
+
* [[Error: Backend configuration changed]]
* <code>[[Error: Failed to get existing workspaces: S3 bucket does not exist.]]</code>: <code>[[aws s3 mb]]</code>
+
* [[Error: Failed to get existing workspaces: S3 bucket does not exist.]]: <code>[[aws s3 mb]]</code>
* <code>[[Error: no valid credential sources for S3 Backend found]]</code>
 
 
 
== Changelog ==
 
* [[Terraform versions|1.6.0]] (Oct 2023) https://github.com/hashicorp/terraform/blob/v1.6/CHANGELOG.md#160-october-4-2023
 
  
 
== Related terms ==
 
== Related terms ==
Line 58: Line 29:
 
* [[Bucket versioning]]
 
* [[Bucket versioning]]
 
* [[Remote state backends to manage Terraform state]]
 
* [[Remote state backends to manage Terraform state]]
* <code>[[terraform_remote_state]]</code> [[data source]]
 
* <code>[[aws s3api create-bucket]]</code> and <code>[[aws s3 mb]]</code>
 
* <code>[[aws s3 ls]]</code>
 
* <code>[[provider.tf]]</code>
 
* [[Terraform backend: gcs]]
 
  
 
== See also ==
 
== See also ==

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Templates used on this page:

Advertising: