|
8 months ago | |
---|---|---|
bin | 1 year ago | |
resources | 8 months ago | |
.gitignore | 1 year ago | |
.terraform.lock.hcl | 8 months ago | |
LICENSE | 1 year ago | |
README.md | 8 months ago | |
india.tfvars.gpg | 1 year ago | |
india.tfvars.sample | 1 year ago | |
main.tf | 1 year ago | |
terraform.tfstate.backup.gpg | 1 year ago | |
terraform.tfstate.gpg | 1 year ago |
README.md
Terraform — Create a Virtual Cloud Network in Oracle Cloud
Create a Virtual Cloud Network (VCN) in Oracle Cloud.
You can run two servers for free by using the Oracle Cloud Always Free tier. Deploy an instance using either of the Terraform scripts below,
- terraform__oci-instance-1
- terraform__oci-instance-2
Code Mirrors
Configuration
Step 1: Create a file to store the Terraform input variables. Use india.tfvars.sample
as a reference. Keep india.tfvars
as the filename or change the name in the following files,
.gitignore
bin/plan.sh
Step 3: Set vcn_cidr
, public1_cidr
and private1_cidr
as desired.
Step 3: Set compartment
to the desired value. List of compartments in your Oracle Cloud account are at cloud.oracle.com/identity/compartments.
Authentication
Oracle provider documentation is at registry.terraform.io/providers/hashicorp/oci/latest.
Oracle Cloud Shell can deploy this script without configuration.
Deployment
Step 1: Use the following command to create a Terraform plan,
$ ./bin/plan.sh
To avoid fetching the latest state of resources, use the following command,
$ ./bin/plan.sh -refresh=false
Step 2: Review the plan using the following command,
$ ./bin/view.sh
Step 3: Apply the plan using the following command,
$ ./bin/apply.sh
Step 4: Use the following command to display the public subnet,
$ terraform show oci_core_subnet.public
Step 5: Use the following command to display the private subnet,
$ terraform show oci_core_subnet.private
Encryption
Encrypt sensitive files (Terraform input variables and state) before saving them. .gitignore
must contain the unencrypted file paths.
Use the following command to decrypt the files after cloning the repository,
$ ./bin/decrypt.sh
Use the following command after running bin/apply.sh
to encrypt the updated state files,
$ ./bin/encrypt.sh <gpg key id>