Terraform Remote Backend with AWS S3

preview_player
Показать описание
In this video i'm going to show you how to setup a remote backend in terraform using an AWS S3 bucket and dynamoDB.

Check out my complete crash course on Terraform:

Subscribe to my Channel:

-Sanjeev Thiyagarajan
Рекомендации по теме
Комментарии
Автор

for my people who are confused why you get an Error 403 when trying to do this (even when you've given the TF provider for AWS credentials) it's because you need the AWS CLI to be configured too. So go and install the cli and then run `aws configure` enter the same credentials (or other ones up to you) and then try again

shaded
Автор

This tutorial saved me lots of pain. Many thanks for sharing

ianhoskings
Автор

Hi Sanjeev, great video! Not sure if I missed this but could you explain why you set the key as global/s3/terraform.tfstate ?

Bastonis
Автор

what about dynamo DB config, how is it going to be used by terraform??

tusharshukla
Автор

very clear, simple and I really love your accent

phuletravinh
Автор

This is a clear, simple and fast explanation. well done and thank you Sanjeev.

rorycawley
Автор

Nice tutorial! Thank you.
A few words about storage resources, like S3 Bucket, ECR, etc.
Terraform is not handling very well with resources like that and resources that already exist because of the idea behind it- to create and destroy the resources quickly and efficiently (among other purposes of course).
With ECR for example, we don't always want to destroy it but if you created it with Terraform, it would try to.
The best way, in my opinion, of doing that is to create manually (sad, I know) those storage resources and then attach them to Terraform.
Other ways are pretty messy and could cause a lot of errors and headaches.

MathoAvito
Автор

Thanks sanjeev .This is a good tutorial. How to do the same thing when am deploying the same script to multiple AWS accounts ? Because initially the statefile is stored in s3 bucket in account A, but when I try to deploy the same script in account B, it fails to refresh the state owing to the user in account B not having access to bucket in account A.

jayateerthmirji
Автор

How to setup an s3 backend for multi account setup? The state is not getting updated in the s3 residing in base account after creating resources in target account. Used ec2 with assume role auth for deployment. It initializes the backend and creates the resources but fails to update state and gives access denied error. Please help

mohammednadeem
Автор

Awesome! Please show in a demo project in real life scenario.. Thank You

Learn_IT_with_Azizul
Автор

Is it safe to make the bucket name public?

andherium
Автор

Sanjeev thanks for this video. It seems like this would only be used if you wanted to share code with a team, and not for CI/CD environments as you would have to pop in and out of local / remote backend to destroy infra.

zvirtual
Автор

How to get the deleted services manually from aws console?

Googlepaynnn
Автор

Thank you very much for the explonantion. However I have a question, what if i have a single terraform configuration for creating S3 bucket, but then reuse the code with everything stay same only i change the AWS region. Because i creating TF configuration to create something, and then i want to recreate same this but in different region, so what i did is creating variable for AWS region and run the TF and created correctly. After that i run it again and then i input different variable for region and get an error that the bucket doesn't exist in new region. I mean i can create 3 copies of same configuration, but if we have 10 developer teams and each team needs to copy configuration from other teams but run in different regions we will have like 100 files in our github repo. Any ideas ? Thanks

markomilosavljevic
Автор

Thanks again...I have gone through your terraform 2 hr class and it was really helpful...but it cuts short in the end. I wanted to upload a few files into an S3 bucket and I am having issues with the etag setup, filemd5. Can you upload the remaining portion of the class. Also can you create and upload an intermediate to master Terraform class? Thanks.

practicaldeen
Автор

nice lection mr. could you tell wich tf vscode extention do you use ?

koyote
Автор

Sajeev we need more help on Terraform modules not explained clearly in other videos

balamuruganchinnasamy
Автор

Great tutorial! However, the way terraform creates backend-related resources (S3 Bucket, DynamoDB Table) directly is likely to get messed up later. They must be created manually in advance and only referenced in Terraform scripts.

haje
Автор

I use s3 backend with conjunction of terraform workspaces and its really amazing,
basicly for each backend (statefile) i've got seperate S3 statefile so to delete specific workspace (environment) i just do this

## to delete environment
terraform workspace select <env-name>
terraform destroy
## to delete workspace after that, so no stale tfstate file left on S3
terraform workspace select default ## needed becouse you cant delete currently selected workspace
terraform workspace delete <env-name> ## will delete Tfstate file on S3

benjaminshtark
Автор

Error: error configuring S3 Backend: no valid credential sources for S3 Backend found. I am getting this can anyone help

sanjunaik