Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valut #65

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Day-1/PROJECT-ec2-instance-creation/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
provider "aws" {
/*provider "aws" {
region = "us-east-1" # Set your desired AWS region
}

resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0" # Specify an appropriate AMI ID
instance_type = "t2.micro"
}*/

resource "aws_instance" "sasiram" {
ami = var.ami
instance_type = var.instance_type
}
3 changes: 3 additions & 0 deletions Day-1/PROJECT-ec2-instance-creation/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = var.region
}
16 changes: 16 additions & 0 deletions Day-1/PROJECT-ec2-instance-creation/variable.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
variable "region" {
description = "value"
type = string
default = "us-east-1"
}
variable "instance_type" {
description = "value"
type = string
default = "t2.micro"
}

variable "ami" {
description = "value"
type = string
default = "ami-0e86e20dae9224db8"
}
48 changes: 48 additions & 0 deletions Day-2/builtin-functions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
variable "list1" {
type = list
default = ["a","b"]
}

variable "list2" {
type = list
default = ["c","d","e"]
}

output "combined_list" {
value = concat(var.list1,var.list2)
}

output "selected_element" {
value = element(var.list1,1)
}

output "length_variable" {
value = length(var.list2)

}

variable "my_map" {
type = map(string)
default = {"name" = "Alice", "age" = "30"}
}

output "value" {
value = lookup(var.my_map, "name") # Returns "Alice"
}

variable "my_list" {
default = ["apple", "banana", "cherry"]
}

output "joined_var" {
value = join("-", var.my_list)
}


variable "items" {
default = ["apple", "banana", "cherry"]
}

output "fruit_list" {
value = join(", ", var.items)
}
16 changes: 16 additions & 0 deletions Day-2/conditional-expressions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
provider "aws" {
region = "us-east-1"
}

variable "create_instance" {
description = "Environment type"
type = string
default = "1"
}
resource "aws_instance" "condtion" {
count = var.create_instance ? 1 : 0

ami = "ami-0182f373e66f89c85"
instance_type = "t2.micro"

}
2 changes: 2 additions & 0 deletions Day-2/dev.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ami = "ami-0182f373e66f89c85"
instance_type = "t2.micro"
21 changes: 21 additions & 0 deletions Day-2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
provider "aws" {
region = "us-east-1"
}

variable "ami" {
description = "value"
type = string
default = "value"

}

variable "instance_type" {
description = "value"
type = string
default = "value"

}
resource "aws_instance" "tfvariable" {
ami = var.ami
instance_type = var.instance_type
}
20 changes: 20 additions & 0 deletions Day-2/multiple-regions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
provider "aws" {
region = "us-east-1"
alias = "us-eastone"
}

provider "aws" {
region = "us-east-2"
alias = "us-easttwo"
}

resource "aws_instance" "usoneregion_instance" {
ami = "ami-0e86e20dae9224db8"
instance_type = "t2.micro"
provider = aws.us-eastone
}
resource "aws_instance" "ustworegion_instance" {
ami = "ami-09efc42336106d2f2"
instance_type = "t2.micro"
provider = aws.us-easttwo
}
44 changes: 44 additions & 0 deletions Day-2/multiple_providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
provider "aws" {
region = "us-east-1"
}

provider "azurerm" {
subscription_id = "your-azure-subscription-id"
client_id = "your-azure-client-id"
client_secret = "your-azure-client-secret"
tenant_id = "your-azure-tenant-id"
}

resource "aws_instance" "aws_provider" {
ami = "ami-0182f373e66f89c85"
instance_type = "t2.micro"
}

resource "azurerm_virtual_machine" "example" {
name = "test"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
network_interface_ids = [azurerm_network_interface.main.id]
vm_size = "Standard_DS1_v2"

storage_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
storage_os_disk {
name = "myosdisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
}
9 changes: 9 additions & 0 deletions Day-2/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
provider "aws" {
region = "us-east-1"

}

resource "aws_instance" "provider_example" {
ami = "ami-0182f373e66f89c85"
instance_type = "t2.micro"
}
8 changes: 8 additions & 0 deletions Day-2/required-providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.66.0"
}
}
}
2 changes: 2 additions & 0 deletions Day-2/stage.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ami = "ami-0e86e20dae9224db8"
instance_type = "t2.micro"
30 changes: 30 additions & 0 deletions Day-2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@


provider "aws" {
region = "us-east-1"
}


variable "ami" {
description = "value"
type = string
default = "ami-0182f373e66f89c85"

}
variable "instance_type" {
description = "value"
type = string
default = "t2.micro"

}

resource "aws_instance" "aws_instance_variables" {
ami = var.ami
instance_type = var.instance_type
}

output "public_ip_output" {
description = "value"
value = aws_instance.aws_instance_variables.public_ip

}
9 changes: 4 additions & 5 deletions Day-3/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ provider "aws" {
region = "us-east-1"
}

module "ec2_instance" {
source = "./modules/ec2_instance"
ami_value = "ami-053b0d53c279acc90" # replace this
instance_type_value = "t2.micro"
subnet_id_value = "subnet-019ea91ed9b5252e7". # replace this
module "ec2-instance_example_basic" {
source = "./modules/ec2_instance"
ami = "ami-0e86e20dae9224db8"
instance_type = "t2.micro"
}
8 changes: 4 additions & 4 deletions Day-3/modules/ec2_instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ provider "aws" {
region = "us-east-1"
}

resource "aws_instance" "example" {
ami = var.ami_value
instance_type = var.instance_type_value
subnet_id = var.subnet_id_value
resource "aws_instance" "module_example" {
ami = var.ami
instance_type = var.instance_type

}
5 changes: 3 additions & 2 deletions Day-3/modules/ec2_instance/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
output "public-ip-address" {
value = aws_instance.example.public_ip
output "ec2_intance_public_ip" {
value = aws_instance.module_example.public_ip

}
17 changes: 9 additions & 8 deletions Day-3/modules/ec2_instance/variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
variable "ami_value" {
description = "value for the ami"
variable "ami" {
description = "value"
type = string
default = "value"

}

variable "instance_type_value" {
description = "value for instance_type"
}

variable "subnet_id_value" {
description = "value for the subnet_id"
variable "instance_type" {
description = "value"
type = string
default = "value"
}
41 changes: 20 additions & 21 deletions Day-6/main.tf
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
provider "aws" {
region = "us-east-1"
}
provider "aws" {
region = "us-east-1"
}

variable "ami" {
description = "value"
}
variable "ami" {
description = "this is ami value"
}

variable "instance_type" {
description = "value"
type = map(string)
variable "instance_type" {
description = "this is instance type"
type = map(string)
default = {
"dev" = "t2.micro"
"stage" = "t2.medium"
"prod" = "t2.xlarge"
}
}
module "namespace_demo" {
source = "./modules/ec2-instance"
ami = var.ami
instance_type = lookup(var.instance_type,terraform.workspace,"t2.micro")

default = {
"dev" = "t2.micro"
"stage" = "t2.medium"
"prod" = "t2.xlarge"
}
}

module "ec2_instance" {
source = "./modules/ec2_instance"
ami = var.ami
instance_type = lookup(var.instance_type, terraform.workspace, "t2.micro")
}
}
18 changes: 18 additions & 0 deletions Day-6/modules/ec2-instance/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
provider "aws"{
region = "us-east-1"
}

variable "ami" {
default = "this is ami value"
}
variable "instance_type" {
default = "this is instance type value"
}



resource "aws_instance" "test"{
ami= var.ami
instance_type= var.instance_type

}
Loading