day6-terraform on google - GCE
> gcloud init
create account on gcloud
Instance/VM
compute service - EC2
In your account first
1. create a project.
- create service
- create database service
- deploy webus/cli/api
based on the project, blling and everything
1. click on your account and
create new project (through web or GUI or CLI) to create a new project
Name: myterraform
remember to note the ID, which is also the project IP. Give name wisely. its very imporant
now, you will be on project.
click o your account and you will see what project you are in.
on the left side, you will see different menus services and you can directly launch fromt here.
click on compute Engine -> VM instances
-> compute Engine API
click on enable to activate it..
google: gcp region list
global locations
COde:
Goal: Step by step
-------------------
step1
Login: auth: user/pass
code: Key
Project ID: myterraform
region: asia_south1
=========================
go to terraform : searh provider: google
- google provider
- authentication
look for credential
> mkdir day5; cd day5
> notepad main.tf
provider "gogole" {
project = "myterraform"
region = "asia-south1"
}
look for authentication part
- we use access key to login and store in a file.
- create service account
- create key and store in a file
IAM and Admin
-> service account -> You will see your existing account.
-> this account is associated some policy or role
-> click on it and click on Keys
-> click on add key - create new key
-> select JSON (by default)
-> Click on Create and will be downloaded on your local PC.
Note: Keey it secret
go to documents/terraform-training/google/gce-key.json
> notepad main.tf
provider "gogole" {
project = "myterraform"
region = "asia-south1"
credentials = "gce-key.json"
}
> terraform init
downloads the plugins for provider
go back to compute service, and write how to launch manually
- computer Engine -> VM instance -> Create a new instance
give os name: os2
vm: os2
region: select mumbai
instance type - machine family -> by default E2-medium
machineType: ec-medium
boot disk (AMI) - click on change and select the os you want.
specify boot-disk image name: debian
boot disk type and size: 10G
go to network settting
click on management / networking
VPC/Network: default (Network Interface)
give os
name: os2
vm: os2
region: select mumbai
instance type - machine family -> by default E2-medium
machineType: ec-medium
boot disk (AMI) - click on change and select the os you want.
specify boot-disk image name: debian
boot disk type and size: 10G
go to network settting
click on management / networking
VPC/Network: default (Network Interface)
convert it into terrafrom code.
google for google service acount and look for example.
> notepad main.tf
provider "gogole" {
project = "myterraform"
region = "asia-south1"
credentials = "gce-key.json"
}
resource "google_compute_instance" "os1"
name = "os1"
machine_type = "e2-medium"
zone: = "asia_south1"
}
tags =
look for document what keyworks are optional and mandetory
> terraform plan
errors: account_id is require
google for: gcloud cli command
go to cloud sdk and click on install SDK and click on cloud DSK installer
after you install, one cmd is avialable..
> gcloud init
helps you to login
select 2
enter project name:
it will configure on your local system.
now, try again
> terrafro plan
> notepad main.tf
provider "gogole" {
project = "myterraform"
region = "asia-south1"
credentials = "gce-key.json"
}
resource "google_compute_instance" "os1"
name = "os1"
machine_type = "e2-medium"
zone: = "asia_south1"
}
> tf plan
need to specify network interface, book disk required
copy the example code
> notepad main.tf
provider "gogole" {
project = "myterraform"
region = "asia-south1"
credentials = "gce-key.json"
}
resource "google_compute_instance" "os1" {
name = "os1"
machine_type = "e2-medium"
zone: = "asia_south1-c"
}
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
network_interface {
network = "default"
}
>tf plan
> tf apply
error: if any, review
otherwise, instance should be created.
go to the console and see if you ca see other insances.
> tf destroy --help
destroy specific resource
> tf destroy -target=resource
>
>
Tuesday, May 18, 2021
Day6-terraform on google - GCE
Subscribe to:
Post Comments (Atom)
Git branch show detached HEAD
Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03) 00 2. Run re-set hard $ git reset --hard 3. ...
-
snmpconfig command allow you to managge snmpv1/v3 agent configuration on SAN switch. Event trap level is mapped with event severity level....
-
Firmware upgrade on HPE SuperDom Flex 280 - prerequisites tasks a. Set up repo b. Upload firmware to your webserver 1. For foundation so...
-
Disabling the Telnet protocol on Brocade SAN switches By default, telnet is enabled on Brocade SAN switches. As part of security hardening o...
No comments:
Post a Comment