From 23cd4e4da7764b59b1ff42a41f9b96bc06c12c97 Mon Sep 17 00:00:00 2001 From: Pratik Das Date: Fri, 16 Apr 2021 16:01:29 +0400 Subject: [PATCH] updated git ignore --- .gitignore | 2 + aws/aws-terraform/aws-app-stack-cloud/main.tf | 41 +++++++++++++++++++ .../modules/application/main.tf | 5 +++ .../modules/application/outputs.tf | 4 ++ .../modules/application/variables.tf | 16 ++++++++ .../modules/storage/main.tf | 9 ++++ .../modules/storage/outputs.tf | 4 ++ .../modules/storage/variables.tf | 13 ++++++ .../aws-app-stack-input-vars/main.tf | 24 +++++++++++ .../aws-app-stack-input-vars/terraform.tfvars | 1 + .../aws-app-stack-input-vars/variables.tf | 4 ++ .../aws-app-stack-modules/main.tf | 33 +++++++++++++++ .../modules/application/main.tf | 5 +++ .../modules/application/outputs.tf | 4 ++ .../modules/application/variables.tf | 16 ++++++++ .../modules/storage/main.tf | 9 ++++ .../modules/storage/outputs.tf | 4 ++ .../modules/storage/variables.tf | 13 ++++++ aws/aws-terraform/aws-app-stack/main.tf | 24 +++++++++++ 19 files changed, 231 insertions(+) create mode 100644 aws/aws-terraform/aws-app-stack-cloud/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-cloud/modules/application/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-cloud/modules/application/outputs.tf create mode 100644 aws/aws-terraform/aws-app-stack-cloud/modules/application/variables.tf create mode 100644 aws/aws-terraform/aws-app-stack-cloud/modules/storage/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-cloud/modules/storage/outputs.tf create mode 100644 aws/aws-terraform/aws-app-stack-cloud/modules/storage/variables.tf create mode 100644 aws/aws-terraform/aws-app-stack-input-vars/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-input-vars/terraform.tfvars create mode 100644 aws/aws-terraform/aws-app-stack-input-vars/variables.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/modules/application/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/modules/application/outputs.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/modules/application/variables.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/modules/storage/main.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/modules/storage/outputs.tf create mode 100644 aws/aws-terraform/aws-app-stack-modules/modules/storage/variables.tf create mode 100644 aws/aws-terraform/aws-app-stack/main.tf diff --git a/.gitignore b/.gitignore index 07f8b1e..ea75cff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ **/.idea/ **/*.iml +**/.DS_Store +**/.terraform diff --git a/aws/aws-terraform/aws-app-stack-cloud/main.tf b/aws/aws-terraform/aws-app-stack-cloud/main.tf new file mode 100644 index 0000000..52d2c3b --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/main.tf @@ -0,0 +1,41 @@ +terraform { + + backend "remote" { + hostname = "app.terraform.io" + organization = "pratikorg" + token = "pj7p59JFwSC4jQ.atlasv1.qfmTxLjTfaM5zKyaQrcGzuTojv6oCyLIoIAO7DkA2ieQY7OyINjINGGMiTczt62p1bs" + workspaces { + name = "my-tf-workspace" + } + } + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.36" + } + } +} + +provider "aws" { + profile = "default" + region = "us-west-2" +} + +module "app_server" { + source = "./modules/application" + + ec2_instance_type = "t2.micro" + ami = "ami-830c94e3" + tags = { + Name = "server for web" + Env = "dev" + } +} + +module "app_storage" { + source = "./modules/storage/" + + bucket_name = "io.pratik.tf-example-bucket" + env = "dev" +} + diff --git a/aws/aws-terraform/aws-app-stack-cloud/modules/application/main.tf b/aws/aws-terraform/aws-app-stack-cloud/modules/application/main.tf new file mode 100644 index 0000000..21a2552 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/modules/application/main.tf @@ -0,0 +1,5 @@ +resource "aws_instance" "vm-web" { + ami = var.ami + instance_type = var.ec2_instance_type + tags = var.tags +} diff --git a/aws/aws-terraform/aws-app-stack-cloud/modules/application/outputs.tf b/aws/aws-terraform/aws-app-stack-cloud/modules/application/outputs.tf new file mode 100644 index 0000000..3a56539 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/modules/application/outputs.tf @@ -0,0 +1,4 @@ +output "instanceID" { + description = "ID of ec2 instance" + value = aws_instance.vm-web.id +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-cloud/modules/application/variables.tf b/aws/aws-terraform/aws-app-stack-cloud/modules/application/variables.tf new file mode 100644 index 0000000..a98430b --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/modules/application/variables.tf @@ -0,0 +1,16 @@ +variable "ec2_instance_type" { + description = "Instance type" + type = string +} + +variable "ami" { + description = "ami id" + type = string +} + +variable "tags" { + description = "Tags to set on the bucket." + type = map(string) + default = {Name = "server for web" + Env = "dev"} +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-cloud/modules/storage/main.tf b/aws/aws-terraform/aws-app-stack-cloud/modules/storage/main.tf new file mode 100644 index 0000000..1b37e38 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/modules/storage/main.tf @@ -0,0 +1,9 @@ +resource "aws_s3_bucket" "s3_bucket" { + bucket = format("%s-%s",var.bucket_name,var.env) + acl = "private" + + tags = { + Name = var.bucket_name + Environment = var.env + } +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-cloud/modules/storage/outputs.tf b/aws/aws-terraform/aws-app-stack-cloud/modules/storage/outputs.tf new file mode 100644 index 0000000..247972b --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/modules/storage/outputs.tf @@ -0,0 +1,4 @@ +output "arn" { + description = "ARN of the bucket" + value = aws_s3_bucket.s3_bucket.arn +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-cloud/modules/storage/variables.tf b/aws/aws-terraform/aws-app-stack-cloud/modules/storage/variables.tf new file mode 100644 index 0000000..568a0ff --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-cloud/modules/storage/variables.tf @@ -0,0 +1,13 @@ +# Input variable definitions + +variable "bucket_name" { + description = "Name of bucket" + type = string +} + +variable "env" { + description = "Environment like dev, prod" + type = string +} + + diff --git a/aws/aws-terraform/aws-app-stack-input-vars/main.tf b/aws/aws-terraform/aws-app-stack-input-vars/main.tf new file mode 100644 index 0000000..957949d --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-input-vars/main.tf @@ -0,0 +1,24 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.27" + } + } +} + +provider "aws" { + profile = "default" + region = "us-west-2" +} + +resource "aws_instance" "vm-web" { + ami = "ami-830c94e3" + instance_type = var.ec2_instance_type + + tags = { + Name = "server for web" + Env = "dev" + } +} + diff --git a/aws/aws-terraform/aws-app-stack-input-vars/terraform.tfvars b/aws/aws-terraform/aws-app-stack-input-vars/terraform.tfvars new file mode 100644 index 0000000..47f411c --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-input-vars/terraform.tfvars @@ -0,0 +1 @@ +ec2_instance_type = "t2.micro" diff --git a/aws/aws-terraform/aws-app-stack-input-vars/variables.tf b/aws/aws-terraform/aws-app-stack-input-vars/variables.tf new file mode 100644 index 0000000..f96e9fb --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-input-vars/variables.tf @@ -0,0 +1,4 @@ +variable "ec2_instance_type" { + description = "AWS EC2 instance type." + type = string +} diff --git a/aws/aws-terraform/aws-app-stack-modules/main.tf b/aws/aws-terraform/aws-app-stack-modules/main.tf new file mode 100644 index 0000000..715ff27 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/main.tf @@ -0,0 +1,33 @@ +terraform { + + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.36" + } + } +} + +provider "aws" { + profile = "default" + region = "us-west-2" +} + +module "app_server" { + source = "./modules/application" + + ec2_instance_type = "t2.micro" + ami = "ami-830c94e3" + tags = { + Name = "server for web" + Env = "dev" + } +} + +module "app_storage" { + source = "./modules/storage/" + + bucket_name = "io.pratik.tf-example-bucket" + env = "dev" +} + diff --git a/aws/aws-terraform/aws-app-stack-modules/modules/application/main.tf b/aws/aws-terraform/aws-app-stack-modules/modules/application/main.tf new file mode 100644 index 0000000..21a2552 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/modules/application/main.tf @@ -0,0 +1,5 @@ +resource "aws_instance" "vm-web" { + ami = var.ami + instance_type = var.ec2_instance_type + tags = var.tags +} diff --git a/aws/aws-terraform/aws-app-stack-modules/modules/application/outputs.tf b/aws/aws-terraform/aws-app-stack-modules/modules/application/outputs.tf new file mode 100644 index 0000000..3a56539 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/modules/application/outputs.tf @@ -0,0 +1,4 @@ +output "instanceID" { + description = "ID of ec2 instance" + value = aws_instance.vm-web.id +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-modules/modules/application/variables.tf b/aws/aws-terraform/aws-app-stack-modules/modules/application/variables.tf new file mode 100644 index 0000000..a98430b --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/modules/application/variables.tf @@ -0,0 +1,16 @@ +variable "ec2_instance_type" { + description = "Instance type" + type = string +} + +variable "ami" { + description = "ami id" + type = string +} + +variable "tags" { + description = "Tags to set on the bucket." + type = map(string) + default = {Name = "server for web" + Env = "dev"} +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-modules/modules/storage/main.tf b/aws/aws-terraform/aws-app-stack-modules/modules/storage/main.tf new file mode 100644 index 0000000..1b37e38 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/modules/storage/main.tf @@ -0,0 +1,9 @@ +resource "aws_s3_bucket" "s3_bucket" { + bucket = format("%s-%s",var.bucket_name,var.env) + acl = "private" + + tags = { + Name = var.bucket_name + Environment = var.env + } +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-modules/modules/storage/outputs.tf b/aws/aws-terraform/aws-app-stack-modules/modules/storage/outputs.tf new file mode 100644 index 0000000..247972b --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/modules/storage/outputs.tf @@ -0,0 +1,4 @@ +output "arn" { + description = "ARN of the bucket" + value = aws_s3_bucket.s3_bucket.arn +} \ No newline at end of file diff --git a/aws/aws-terraform/aws-app-stack-modules/modules/storage/variables.tf b/aws/aws-terraform/aws-app-stack-modules/modules/storage/variables.tf new file mode 100644 index 0000000..568a0ff --- /dev/null +++ b/aws/aws-terraform/aws-app-stack-modules/modules/storage/variables.tf @@ -0,0 +1,13 @@ +# Input variable definitions + +variable "bucket_name" { + description = "Name of bucket" + type = string +} + +variable "env" { + description = "Environment like dev, prod" + type = string +} + + diff --git a/aws/aws-terraform/aws-app-stack/main.tf b/aws/aws-terraform/aws-app-stack/main.tf new file mode 100644 index 0000000..0b655f3 --- /dev/null +++ b/aws/aws-terraform/aws-app-stack/main.tf @@ -0,0 +1,24 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.27" + } + } +} + +provider "aws" { + profile = "default" + region = "us-west-2" +} + +resource "aws_instance" "vm-web" { + ami = "ami-830c94e3" + instance_type = "t2.micro" + + tags = { + Name = "server for web" + Env = "dev" + } +} +