Code Monkey home page Code Monkey logo

terraform-php-for-last-usecase's Introduction

Terraform-

This space will keep on updating, so check this regularly for an update Download Terraform from official site https://www.terraform.io/downloads.html

Set Up patch variable for this as per doc and check your tf version

tf1

Create a terraform user to integrate AWS with terraform. I have created a user terraform. tf2

Provide Administrator access policy to this user tf3

Download Access key id. Create a credential in order to authenticate with AWS by default. tf4

Create a .aws folder inside the user folder and save your cred.(You can choose any other folder) Save your cred inside the c\users\username.aws
tf5

I’ll use Git here to integrate terra with AWS so ensure you have Git installed to follow along. You can also use other command line as well to work with.Create a folder & Initialize your git repos tf6

Create a file and add the below tf code to create a bucket in aws. tf7

provider "aws" { # Terraform is used to create, manage, and update infrastructure resources such as physical machines, VMs, network switches, containers, and more. Almost any infrastructure type can be represented as a resource in Terraform.

A provider is responsible for understanding API interactions and exposing resources. Providers generally are an IaaS (e.g. Alibaba Cloud, AWS, GCP, Microsoft Azure, OpenStack), PaaS (e.g. Heroku), or SaaS services (e.g. Terraform Cloud, DNSimple, Cloudflare).

profile = "default" # this is your default profile to authenticate to aws using your saved cred region = "us-west-2" }

resource "aws_s3_bucket" "tf_course" { # what resources you are using need to be place here. in this ex s3. resource name is tf_course this is how terraform define bucket = "tf-aws-june28" # this is consider as arguments in terraform and we use this in "". this is how aws define this name acl = "private" # an argument to define it is a private bucket }

Use git add to add this file in local git repo

Commit your repo using git commit and it it ask for id provide your github account details tf8
Initialize your tf directory. Once initialize we are ready to deploy our code to aws tf9

Now use terraform apply. This will ask you to complete the changes on AWS, put yes, if you don’t want this to ask you yes or no, you can simply write in the beginning as

tf10

Terraform apply -auto-approve

tf11

As soon as you hit yes within a sec this will deploy a bucket in your aws console tf12

Login and check in your console

tf13

You can also save this plan to a file to see what exactly it is going to do

Use terrafor show command to check the result

tf14

Terraform graph - so i have one S3 bucket in my account and lets see what we get when we generate the graph for it

tf15

How does TF work ?

IaC - This is an Infrastructure as Code. We can define resources based on tf code. You can build your infrastructure using a code, share it with others. You need to plan your execution well. Resources - Building blocks of Terraform code Define the “what” of your infrastructure Different settings for every provider like (AWS,Azure,GCP etc..)

Code> State> Plan > Apply = Always remember this.

Terraform plan --help = this will give you what options we can use with plan

tf16

As we have destroyed our previous bucks env, Now lets add VPC in our tf code Create a new prod .tf file and add below tf17

Use terraform plan to see what it is going to do. As you can see using plan we can see this is going to create a default vpc tf18

Add this file using git add prod.tf command tf19

And use git status to trak the file. As you can see git has found the previous .tf file has been deleted so we need to use git add firs_code.tf to add this file to repo

tf20

Now you can use git commit command to add the vpc changes to it. tf21

this is it now new bucket deployed under default vpc.

terraform-php-for-last-usecase's People

Contributors

himashugit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.