Moving Terraform State file to OCI Object Store
When developing with Terraform it is nice to keep everything local on your laptop. Makes for great ease of development; there are time when you want to share your environment, i.e. state file, with others in your development organization. In order to do this, the state file has to be moved to a common area. In many environments this would happen by moving the state file to an object store. Although many people talk about the other cloud platforms and how to do things; Oracle provides a pretty good platform for many items. The object store is only part of the it.
Build the Object Store
In order to build your object store, first you have to login to Oracle Cloud (cloud.oracle.com). Once logged in, you then need to go to hamburger menu in the upper left corner. Under Core Infrastructure, select Object Storage and Object Storage.
Once you arrive to the Object Storage page, you will be presented with a button that says Create Bucket. The bucket is where the state file will reside once it is provisioned there. Click Create Bucket.
After clicking the Create Bucket button, you are presented with a dialog to build the bucket. In this dialog, provide the bucket name, what type of storage (Standard) to use and allow Oracle to maintain the encryption. After ensuring these times are done, then click the Create Bucket button at the bottom of the dialog.
At this point, the bucket you plan on using for Terraform State file has been created.
Pre-Authenticated Request
With the Object Storage bucket created the next thing that has to be done is define a Pre-Authenticated Request. Pre-Authenticated requests are used to allow access to the object storage bucket without having to login each time you want to move an item to the bucket. This also allows for commands and dynamic commands to access the object store, place and use files in the bucket.
To create a Pre-Authenticated Request, click on the Create Pre-Authenticated Request button. This will bring up the Create Pre-Authenticated Request dialog. Within this dialog, provide a name, ensure the radio button for Object is selected, ensure that the object can be read/write, lastly set the expiration date. After all those items are set, click the Create Pre-Authenticated Request button.
Once the Pre-Authenticated Request has been created, you will be prompted to copy the corresponding URL. In our case, this URL looks similar to this:
Configure Backend State
Now that we have the URL needed to make an HTTP request to the Object Storage, we can configure the backend in the main.tf file. The code block that needs to be established is as follows:
########################
# Backend
########################
terraform {
backend "http” {
address = "https://objectstorage.us-ashburn-1.oraclecloud.com/p/Zi1rw_yl1E9Z1q.........zaaBmx71sas_oU/n/idtlingilfcy/b/bucket-terraform/o/terraform.tfstate”
update_method = “PUT"
}
}
As you can tell this is quite simple. We are simply telling terraform to use the HTTP protocol with the backend. Then providing the address for the backend and what method to use. In this case, we are using the cURL method of PUT to ensure changes to the state file are updated on the object store.
Initializing
In order for the state to be placed on the Object Storage that was just created, the terraform environment has to be initialized. This done by simply running terraform init.
Validating
After the initialization and/or an apply process, the state file can be validated by looking into the object storage and seeing if the file exists. In this example, the file was created and modified on 21 June 2020 @ 3:55 am UTC.
Summary
With the Terraform state file located in a cloud environment and in an object storage are it can be shared between members of a development staff and network operations departments. This makes it easy for everyone to keep track of what workloads have been created within a given cloud environment.
Enjoy!!!
Really great info can be found on weblog.Money from blog
Hey there! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my site to rank for some
targeted keywords but I’m not seeing very good success.
If you know of any please share. Cheers! You can read similar
art here: Eco product
Close to 3,000 reefs span more than 1,400 miles within the Coral Sea close to Australia.
sugar defender ingredients Discovering Sugar Protector has been a game-changer for me,
as I’ve always been vigilant concerning handling my blood sugar levels.
I currently feel empowered and positive in my capacity to maintain healthy levels, and my most
current checkup have actually mirrored this development.
Having a credible supplement to complement my a substantial resource of convenience, and I’m absolutely thankful for the substantial distinction Sugar Defender has actually made
in my general well-being.
Oh my goodness! Impressive article dude! Thanks, However I am going through problems with your RSS. I don’t understand why I can’t join it. Is there anyone else getting identical RSS problems? Anyone who knows the solution will you kindly respond? Thanks.
May I simply say what a relief to find a person that truly understands what they are discussing on the web. You definitely understand how to bring a problem to light and make it important. More and more people have to read this and understand this side of your story. I was surprised you aren’t more popular since you certainly have the gift.
Hi! I just wish to give you a big thumbs up for the great info you have got here on this post. I am coming back to your blog for more soon.
Howdy! This post could not be written any better! Reading through this article reminds me of my previous roommate! He constantly kept preaching about this. I will send this post to him. Fairly certain he will have a very good read. Thank you for sharing!
Spot on with this write-up, I absolutely believe that this website needs far more attention. I’ll probably be returning to read more, thanks for the information.
Right here is the perfect webpage for everyone who wants to find out about this topic. You know a whole lot its almost hard to argue with you (not that I really will need to…HaHa). You certainly put a brand new spin on a subject which has been written about for decades. Wonderful stuff, just excellent.
Nice post. I learn something totally new and challenging on websites I stumbleupon on a daily basis. It will always be interesting to read through articles from other writers and use something from other sites.
After looking over a few of the articles on your web site, I truly appreciate your technique of writing a blog. I book-marked it to my bookmark webpage list and will be checking back in the near future. Take a look at my website too and let me know your opinion.
Your style is really unique compared to other folks I’ve read stuff from. Thank you for posting when you have the opportunity, Guess I will just book mark this blog.
Nice post. I learn something new and challenging on sites I stumbleupon every day. It will always be useful to read content from other writers and practice a little something from their websites.
Excellent weblog right here! Additionally your website a lot up fast! What host are you the use of? Can I am getting your associate hyperlink on your host? I wish my website loaded up as fast as yours lol.
Thank you for the well-written blog post. I greatly treasured your generosity and help you offer through the totally free tips on your blog, specially the ones provided through this article. I know Britta would love to read more of your blog post. I’ve sent your website url to her. We love your thoughtfulness during this difficult time.