Difference between revisions of "Terraform S3 backend"
Jump to navigation
Jump to search
↑ https://www.terraform.io/docs/language/settings/backends/s3.html#key
↑ https://www.terraform.io/docs/language/settings/backends/s3.html#key
Line 50: | Line 50: | ||
* <code>[[Error: Failed to get existing workspaces: S3 bucket does not exist.]]</code>: <code>[[aws s3 mb]]</code> | * <code>[[Error: Failed to get existing workspaces: S3 bucket does not exist.]]</code>: <code>[[aws s3 mb]]</code> | ||
* <code>[[Error: no valid credential sources for S3 Backend found]]</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 == |
Revision as of 14:02, 3 July 2024
Contents
Basic S3 examples 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" } }
#This simple example will prompt you for bucket name once you executed terraform init terraform { backend "s3" { } }
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" } }
profile
: https://www.terraform.io/docs/language/settings/backends/s3.html#profilekey
: 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 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
Error: Backend configuration changed
Error: Failed to get existing workspaces: S3 bucket does not exist.
:aws s3 mb
Error: no valid credential sources for S3 Backend found
Changelog
Related terms
terraform init
- Bucket versioning
- Remote state backends to manage Terraform state
terraform_remote_state
data sourceaws s3api create-bucket
andaws s3 mb
aws s3 ls
provider.tf
- Terraform backend: gcs
See also
- Terraform configuration files, Terraform state files:
.tf
,.tfvars
,main.tf, outputs.tf
,variables.tf
,.terraform.d/
,terraform init
,providers.tf
,.terraform/
,terraform.tfstate
,.terraform.lock.hcl
,terraform.tfstate.d, override.tf, versions.tf
- Terraform backends:
S3
,Terraform S3 backend: dynamodb table
,GCS, remote
Advertising: