├── Day10.tf ├── Day11.tf ├── Day12.tf ├── Day13.tf ├── Day14.tf ├── Day15.tf ├── Day16.tf ├── Day17.tf ├── Day18.tf ├── Day19.tf ├── Day1EC2instancecreation.tf ├── Day2.tf ├── Day21.java ├── Day3-S3bucketcreation.tf ├── Day4-Lambdainstance.tf ├── Day5 ├── alternate_provider.tf └── set-aliases-default.tf ├── Day6 ├── Variables.tf ├── main.tf └── terraform.tfvars ├── Day7_Azurerm.tf ├── Day8 └── Different _regions.tf └── Day9.tf /Day10.tf: -------------------------------------------------------------------------------- 1 | # Define an example resource (e.g., AWS EC2 instance) 2 | resource "aws_instance" "example" { 3 | ami = "ami-0c55b159cbfafe1f0" 4 | instance_type = "t2.micro" 5 | tags = { 6 | Name = "example-instance" 7 | } 8 | } 9 | 10 | # to display the state of the above aws resource you need to use the commands below 11 | # Define an example resource (e.g., AWS EC2 instance) 12 | resource "aws_instance" "example" { 13 | ami = "ami-0c55b159cbfafe1f0" 14 | instance_type = "t2.micro" 15 | tags = { 16 | Name = "example-instance" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Day11.tf: -------------------------------------------------------------------------------- 1 | # main.tf 2 | 3 | # Define your AWS provider 4 | provider "aws" { 5 | region = "us-west-2" 6 | } 7 | 8 | # Define an AWS EC2 instance 9 | resource "aws_instance" "example" { 10 | ami = "ami-0c55b159cbfafe1f0" 11 | instance_type = "t2.micro" 12 | } 13 | 14 | # Define a null resource to trigger drift detection 15 | resource "null_resource" "drift_detection" { 16 | triggers = { 17 | # Change this value to trigger drift detection 18 | timestamp = "${timestamp()}" 19 | } 20 | 21 | # Run terraform plan as part of the null resource 22 | provisioner "local-exec" { 23 | command = "terraform plan" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Day12.tf: -------------------------------------------------------------------------------- 1 | # Declare an AWS EC2 instance resource 2 | resource "aws_instance" "example" { 3 | ami = "ami-0c55b159cbfafe1f0" 4 | instance_type = "t2.micro" 5 | tags = { 6 | Name = "ExampleInstance" 7 | } 8 | } 9 | 10 | # Addressing the resource 11 | aws_instance.example 12 | -------------------------------------------------------------------------------- /Day13.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "your-aws-region" 3 | } 4 | 5 | resource "aws_vpc" "example" { 6 | cidr_block = "10.0.0.0/16" 7 | tags = { 8 | Name = "example-vpc" 9 | } 10 | } 11 | 12 | resource "aws_internet_gateway" "example" { 13 | vpc_id = aws_vpc.example.id 14 | tags = { 15 | Name = "example-igw" 16 | } 17 | } 18 | 19 | resource "aws_subnet" "example" { 20 | vpc_id = aws_vpc.example.id 21 | cidr_block = "10.0.1.0/24" 22 | availability_zone = "your-availability-zone" 23 | tags = { 24 | Name = "example-subnet" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Day14.tf: -------------------------------------------------------------------------------- 1 | # Define the provider 2 | provider "aws" { 3 | region = "us-east-1" # Specify your desired AWS region 4 | } 5 | 6 | # Create an S3 bucket 7 | resource "aws_s3_bucket" "example_bucket" { 8 | bucket = "example-bucket-name" # Specify your desired bucket name 9 | acl = "private" # Set the bucket access control list (ACL) 10 | } 11 | 12 | # Define bucket policy to grant access to a specific IAM user 13 | resource "aws_s3_bucket_policy" "example_bucket_policy" { 14 | bucket = aws_s3_bucket.example_bucket.id 15 | 16 | policy = jsonencode({ 17 | Version = "2012-10-17", 18 | Statement = [{ 19 | Effect = "Allow", 20 | Principal = { 21 | AWS = "arn:aws:iam::ACCOUNT_ID:user/USERNAME" # Specify the ARN of the IAM user you want to grant access to 22 | }, 23 | Action = "s3:*", 24 | Resource = "${aws_s3_bucket.example_bucket.arn}/*" 25 | }] 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /Day15.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "us-west-2" 3 | } 4 | 5 | resource "aws_cloudwatch_metric_alarm" "example" { 6 | alarm_name = "example-alarm" 7 | comparison_operator = "GreaterThanOrEqualToThreshold" 8 | evaluation_periods = "2" 9 | metric_name = "CPUUtilization" 10 | namespace = "AWS/EC2" 11 | period = "300" 12 | statistic = "Average" 13 | threshold = "80" 14 | 15 | dimensions = { 16 | InstanceId = "i-1234567890abcdef0" 17 | } 18 | 19 | alarm_description = "This metric monitors CPU utilization on the EC2 instance" 20 | alarm_actions = ["arn:aws:sns:us-west-2:123456789012:example-topic"] 21 | } 22 | -------------------------------------------------------------------------------- /Day16.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "us-west-2" // Change this to your desired region 3 | } 4 | 5 | module "eks" { 6 | source = "terraform-aws-modules/eks/aws" 7 | cluster_name = "my-cks-cluster" 8 | cluster_version = "1.21" // Update to your desired Kubernetes version 9 | subnets = ["subnet-12345678", "subnet-23456789", "subnet-34567890"] // Update with your subnet IDs 10 | vpc_id = "vpc-0123456789abcdef0" // Update with your VPC ID 11 | node_groups = { 12 | eks_nodes = { 13 | desired_capacity = 2 14 | max_capacity = 3 15 | min_capacity = 1 16 | instance_type = "t3.medium" // Update with your desired instance type 17 | key_name = "your-key-pair-name" // Update with your SSH key pair name 18 | } 19 | } 20 | tags = { 21 | Environment = "Production" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Day17.tf: -------------------------------------------------------------------------------- 1 | #Define AWS provider 2 | provider "aws" { 3 | region = "us-east-1" 4 | } 5 | 6 | # Create IAM role for EC2 instance 7 | resource "aws_iam_role" "ec2_role" { 8 | name = "ec2_s3_access_role" 9 | assume_role_policy = <