Rahul I'm watching all your videos, what I observed is a clear demonstration on what ur saying and ur making it looks easy after watching ur video. Please do a complete tutorial of creating a cluster and deploying an application using terraform.
I have a question regarding Terraform state locking mechanisms. In AWS, we use DynamoDB to acquire a lock on the state file when running Terraform commands to prevent concurrent modifications. How can we achieve a similar state locking mechanism in Azure? Specifically, what services and configurations should we use to ensure the state file is properly locked when multiple DevOps engineers are working with Terraform in Azure?
Hi Rahul. Thanks for your wonderful videos. I currently have multiple projects and I’m using one S3 bucket for my state backend. These multiple project state files are separated by paths in the S3 bucket. Now, I want to implement DynamoDB state file lock. Since I have multiple projects, can I use only one DynamoDB table, like I used one S3 bucket for my state file backend? If the answer is yes, how does DynamoDB separate and isolate the locks for each project in this table? Or do I have to create multiple DynamoDB table for all my projects? Your guidance and thoughts on this would be appreciated.
There is a mistake in this video if I understood the concept clearly. When you are running terraform apply as developer 2, it is not making a new ec2 but terraform just updated the name tag. And you said that you deleted the old ec2 which was lauched previously but if you look at the public ipv4 DNS closely, the old ec2 was not deleted. Please correct me if I am wrong. Thank you.
the whole notion of dev-2 using the same tfstate file means, any changes you're making to existing tfstate file is an update. Tag name was the only change. I think he got confused with the terms there. He didn't delete his old one. Dev-2 updated the Name of the instance that was created by Dev-1.
Hi Rahul, actually I just started learning terraform and your videos are very helpful for learning terraform. I have one query. I went through the document you shared in description box. In the document you have created dynamoDB table by manually and also created by adding terraform resouce as aws_dynamodb_table, so after creating dynamoDB table manually why we need to add aws_dynamodb_table as a resource in main.tf
Hello Rahul there is a small mistake at last the developer 2 has just replaced the developer 1 instance it did not created new you can check the plan ..Please correct that thank you ..Nice video .
Hello Rahul, first thanks for shared, I have a questions, you can use the same key for both projects and not have problems, but the state of each project is not overwritten? I thinks that each state have info specific about you deploy, please can you helm with this doubth, Thanks again and regards
Hey Rahul, could you please help. Here when dev 2 applied changes it launched one more instance.. so every time they make changes a new instance will be launched. Dev 1 and Dev2 working for the same instance.. They pulled the statefile. Dev1 updated and pushed and updated the statefile however Dev2 still has the old state file. How will Dev2 get the latest changes to the instance and add his change and push it back?
Thanks for the tutorial, I was able to follow along and the terraform.tfstate file was in my s3 bucket, but it’s also on my local machine, I tried deleting locally but it got created once again after running terraform init, is this a morning approach? Or am I doing something wrong? Thanks
Bro i have an question for uu... if two developer User A and User B are working under the same project. User A configured the entire s3 backend and raised the ec2-instance. How could User B sync the files, which has been created by user A ???. i mean how will he configure so that he could get terraform.tfstate file into this local system and can view wat User A has written the code.
i have a use case, here developer2 has pushed it config and he is able to do it, but it should not. Because he should first pull the state file . What ma I missing here?
As per the video i'm trying to create 2 ec2 instances with the same state file, but in my case 1st ec2 instance is creating when i creating 2 one first one deleting and creating wit the 2 one. Any suggestions please.
Hii Rahul I have doubt in this video We are using here S3 and Dynamo db Y not we directly store the statefile into Dynamo db again y we are using S3 object.
Hello sir, Actually when you used to apply command for project 2 developer but it was not created a new resource and just make a changes on tag in which you have created project 1 developer resources.
Yes... Looks like the same Ec2 created by developer 1 for project 1 got updated with the name in the second run initiated by developer 2 because the aws instance definition name was same with the other one... (in both main.tf file & same tf state file)
Nice explanation, thanks. One question though, once the developer 1 has updated the state doesn't developer 2 pull the state before running the terraform apply ?
Informative...! :) may be this question is not relevant to this video. Incase some how accidentally deleted remote terraform state file from s3, in that case how we can troubleshoot ?
The simple answer is you are screwed, there is no way you can get state file back if it has been deleted. The another way to be safe is to enabled the provisioning on the state file so that you have the older version of state file in your versioning repository
Hi I getting error for S3 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: 13YNJNZ963P0G2PC, host id: BesL3R7isQNbpgHpncUwj1Eg9kioyJLxo4Gxw0fHCtKZzqM7vrKlT2Dw+ijf0WNcwjYBJLfOWGE= Any clue?
If 2 dev are using separate folders then state file will be diff for two directory's. Isn't it? Or only one state file will be maintain for my laptop though i have created multiple projects?
state files will be different for each folder if its locally stored but since Remote backend is being used here it will be 1 single statefile (s3://jhooq-terraform-s3-bucket/jhooq/terraform/remote/s3/terraform.tfstate)
hmm terraform state locking is concept meant mostly for developer although you could use inside the CI CD pipeline as well. But i am still wondering why you want to trigger terraform apply from jenkins?
@@RahulWagh so it can go through a PR approval before making changes to production. Why would you give developer access to apply to prod? Should be a role that Jenkins assume.
I always keep the more stress on concept first. All though incorporating S3 bucket code inside terraform is not a big deal but end users like you are only interested in dyanmoDB state locking concept. If i start putting everything in session then length of the session would increase many fold and no one is interested in learning how to create S3 bucket using terraform when i am saying the headline state locking using dyanmodb
I think it's wise to mention that there are several ways of creating S3 bucket. And that you chose to do it the console way. But I guess, if we're going to create S3 bucket from local. We should make backend changes to terraform only after we create the S3 bucket on aws from local.
Wooooow this is some brilliant stuff, well done! well explained !
Nice Explanation. Very well demonstrated. Now i got clear concept on locking.
Glad to hear that
Easy to follow and well explained. Thanks
You're welcome!
Rahul I'm watching all your videos, what I observed is a clear demonstration on what ur saying and ur making it looks easy after watching ur video.
Please do a complete tutorial of creating a cluster and deploying an application using terraform.
well explained in short , Thanks Rahul
very helpful, very good teacher he is
Thank you very much Sir, for this wonderful, very simple explanation.....you are awesome.
Very informative Tutorial Rahul. 🎉 Your videos are helping a lot in clearing concepts. Thanks for the awesome efforts
Glad to hear that
It was amazing video, Nice explanation and I got full clarity idea on the terraform state locking file processing 👍👌
Good Job Man I really liked it, waiting for more sessions to come !!!
Very soon!
Hi Praveen, your video's really helped me with my terraform projects. Thanks a lot.
I am glad to hear that
very good explanation
Thanks
I have a question regarding Terraform state locking mechanisms. In AWS, we use DynamoDB to acquire a lock on the state file when running Terraform commands to prevent concurrent modifications. How can we achieve a similar state locking mechanism in Azure? Specifically, what services and configurations should we use to ensure the state file is properly locked when multiple DevOps engineers are working with Terraform in Azure?
Really superb
Thank you! Cheers!
Hi Rahul. Thanks for your wonderful videos. I currently have multiple projects and I’m using one S3 bucket for my state backend. These multiple project state files are separated by paths in the S3 bucket. Now, I want to implement DynamoDB state file lock. Since I have multiple projects, can I use only one DynamoDB table, like I used one S3 bucket for my state file backend? If the answer is yes, how does DynamoDB separate and isolate the locks for each project in this table? Or do I have to create multiple DynamoDB table for all my projects? Your guidance and thoughts on this would be appreciated.
excellent info great work👌👌
Really nice video - completed the playlist
There are more to come
brilliant
Nice explanation !! Thank You !!
Glad it was helpful!
Nice content. One suggestion to viewers is - let's create that S3 bucket/ddb also through terraform rather than console.
Yeah that’s totally true you can create the s3 bucket as well as dynamodb using terraform but here the idea was to show the locking concept
Nice question, I was just about to ask this. I created my S3 bucket and dynamic db via terraform also. Thanks for the clarification
Very well explained.
Glad you liked it
Spot on Sir 👌
U r always gives nice good content.. keep rocking 👍 👌 .. thx
My pleasure 😊
Excited to see this :) cheers!!!
You will like it
There is a mistake in this video if I understood the concept clearly. When you are running terraform apply as developer 2, it is not making a new ec2 but terraform just updated the name tag. And you said that you deleted the old ec2 which was lauched previously but if you look at the public ipv4 DNS closely, the old ec2 was not deleted. Please correct me if I am wrong. Thank you.
the whole notion of dev-2 using the same tfstate file means, any changes you're making to existing tfstate file is an update. Tag name was the only change.
I think he got confused with the terms there. He didn't delete his old one. Dev-2 updated the Name of the instance that was created by Dev-1.
@@SaiKrishnaSanka Thanks! this clarified my doubt and gave clear understanding. When he said dev2 created new instance, I was like whaaaatt.. lol.
Hi Rahul, actually I just started learning terraform and your videos are very helpful for learning terraform. I have one query. I went through the document you shared in description box. In the document you have created dynamoDB table by manually and also created by adding terraform resouce as aws_dynamodb_table, so after creating dynamoDB table manually why we need to add aws_dynamodb_table as a resource in main.tf
Hello Rahul there is a small mistake at last the developer 2 has just replaced the developer 1 instance it did not created new you can check the plan ..Please correct that thank you ..Nice video .
I will check
Hello Rahul, first thanks for shared, I have a questions,
you can use the same key for both projects and not have problems, but the state of each project is not overwritten?
I thinks that each state have info specific about you deploy, please can you helm with this doubth,
Thanks again and regards
thank you!
Welcome!
Hey Rahul, could you please help. Here when dev 2 applied changes it launched one more instance.. so every time they make changes a new instance will be launched.
Dev 1 and Dev2 working for the same instance..
They pulled the statefile.
Dev1 updated and pushed and updated the statefile however Dev2 still has the old state file. How will Dev2 get the latest changes to the instance and add his change and push it back?
very usefull
Glad you think so!
Thanks for the tutorial, I was able to follow along and the terraform.tfstate file was in my s3 bucket, but it’s also on my local machine, I tried deleting locally but it got created once again after running terraform init, is this a morning approach? Or am I doing something wrong? Thanks
Thanks Rahul. How to achieve the same using google cloud ?
Well it will be totally different and will need another session to demonstrate for google cloud
Hey, what does that Digest value mean in the DynamoDB after applying the terraform. You should have explained that as well.
Bro i have an question for uu...
if two developer User A and User B are working under the same project. User A configured the entire s3 backend and raised the ec2-instance. How could User B sync the files, which has been created by user A ???. i mean how will he configure so that he could get terraform.tfstate file into this local system and can view wat User A has written the code.
i have a use case, here developer2 has pushed it config and he is able to do it, but it should not. Because he should first pull the state file . What ma I missing here?
Hi Rahul instead of passing access key and secret i passed profile but gives error does not find error can you help me resolve the issue
Rahul, how do I store multiple state files in s3?
As per the video i'm trying to create 2 ec2 instances with the same state file, but in my case 1st ec2 instance is creating when i creating 2 one first one deleting and creating wit the 2 one. Any suggestions please.
Hii Rahul
I have doubt in this video
We are using here S3 and Dynamo db
Y not we directly store the statefile into Dynamo db again y we are using S3 object.
S3 is for storing FILES and directories while DynamoDB is for Key-value pairs. Understand the difference.
Hello sir, Actually when you used to apply command for project 2 developer but it was not created a new resource and just make a changes on tag in which you have created project 1 developer resources.
Yes... Looks like the same Ec2 created by developer 1 for project 1 got updated with the name in the second run initiated by developer 2 because the aws instance definition name was same with the other one... (in both main.tf file & same tf state file)
and how to unlock
the state file
lock?
hi Rahul Key name what i will provide ?
Nice explanation, thanks. One question though, once the developer 1 has updated the state doesn't developer 2 pull the state before running the terraform apply ?
That is correct
Dear Rahul sir,
Could you please make any video of the how to integrate jenkins with terraform and using ansible.
surely i will add it to my list
Informative...! :) may be this question is not relevant to this video. Incase some how accidentally deleted remote terraform state file from s3, in that case how we can troubleshoot ?
The simple answer is you are screwed, there is no way you can get state file back if it has been deleted.
The another way to be safe is to enabled the provisioning on the state file so that you have the older version of state file in your versioning repository
Hi I getting error for S3 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: 13YNJNZ963P0G2PC, host id: BesL3R7isQNbpgHpncUwj1Eg9kioyJLxo4Gxw0fHCtKZzqM7vrKlT2Dw+ijf0WNcwjYBJLfOWGE=
Any clue?
If 2 dev are using separate folders then state file will be diff for two directory's. Isn't it? Or only one state file will be maintain for my laptop though i have created multiple projects?
state files will be different for each folder if its locally stored but since Remote backend is being used here it will be 1 single statefile
(s3://jhooq-terraform-s3-bucket/jhooq/terraform/remote/s3/terraform.tfstate)
sir, please make more video on dynamo db
Is there a point in state locking if using CICD to run terraform apply?
hmm terraform state locking is concept meant mostly for developer although you could use inside the CI CD pipeline as well. But i am still wondering why you want to trigger terraform apply from jenkins?
@@RahulWagh so it can go through a PR approval before making changes to production. Why would you give developer access to apply to prod? Should be a role that Jenkins assume.
in my case i've had to provide the access key for backend init: terraform init -backend-config="access_key=" -backend-config="secret_key="
Access key and secret key inside a tf file is insane...
Hello stephen it is just for tutorial not for production use, the idea is to learn the concepts. Not to build production level application on youtube.
Nice home..it's distracting terraform
😀
I find it so silly that you are using an infrastructure as code tool but then you go and make the S3 bucket manually... WTF
I always keep the more stress on concept first. All though incorporating S3 bucket code inside terraform is not a big deal but end users like you are only interested in dyanmoDB state locking concept. If i start putting everything in session then length of the session would increase many fold and no one is interested in learning how to create S3 bucket using terraform when i am saying the headline state locking using dyanmodb
I think it's wise to mention that there are several ways of creating S3 bucket. And that you chose to do it the console way.
But I guess, if we're going to create S3 bucket from local. We should make backend changes to terraform only after we create the S3 bucket on aws from local.
Good explanation
Thanks for liking
Hey Rahul. Please are you doing some live session training and if yes please share information on how to reach you. Thanks