-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vijay patel
committed
Sep 16, 2019
1 parent
0268d88
commit 61bbfe2
Showing
21 changed files
with
210 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
resource "aws_iam_user_group_membership" "example1" { | ||
user = "${aws_iam_user.user1.name}" | ||
|
||
groups = [ | ||
"${aws_iam_group.group1.name}", | ||
] | ||
} | ||
|
||
resource "aws_iam_user" "user1" { | ||
name = "user1" | ||
} | ||
|
||
resource "aws_iam_group" "group1" { | ||
name = "group1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
resource "aws_iam_role_policy" "test_policy" { | ||
name = "iam_role_policy_example" | ||
role = "${aws_iam_role.test_role.id}" | ||
|
||
policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"ec2:Describe*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
EOF | ||
} | ||
|
||
resource "aws_iam_role" "test_role" { | ||
name = "iam_role_example" | ||
|
||
assume_role_policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Principal": { | ||
"Service": "ec2.amazonaws.com" | ||
}, | ||
"Effect": "Allow", | ||
"Sid": "" | ||
} | ||
] | ||
} | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "aws_iam_policy" "policy" { | ||
name = "iam_policy_example" | ||
path = "/" | ||
description = "My test policy" | ||
|
||
policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"ec2:Describe*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
resource "aws_iam_user" "lb" { | ||
name = "iam_user_example" | ||
path = "/system/" | ||
|
||
tags = { | ||
tag-key = "tag-value" | ||
} | ||
} | ||
|
||
resource "aws_iam_user_policy" "lb_ro" { | ||
name = "iam_user_policy" | ||
user = "${aws_iam_user.lb.name}" | ||
|
||
policy = <<EOF | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"ec2:Describe*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
variable "access_key" {} | ||
variable "secret_key" {} | ||
|
||
variable "region" { | ||
default = "us-east-1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# .tfvars files | ||
*.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Terraform-Tutorial | ||
Terraform Tutorial with all the Live Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
data "aws_vpc" "selected" { | ||
|
||
filter { | ||
name = "tag:Name" | ||
values = ["Default"] | ||
} | ||
} | ||
|
||
resource "aws_subnet" "example" { | ||
vpc_id = "${data.aws_vpc.selected.id}" | ||
cidr_block = "172.31.0.0/20" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "aws" { | ||
region = "${var.region}" | ||
version = "~> 2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
variable "access_key" {} | ||
variable "secret_key" {} | ||
variable "region" { | ||
default = "us-east-1" | ||
} | ||
variable "ami_id" { | ||
type = "map" | ||
default = { | ||
us-east-1 = "ami-035b3c7efe6d061d5" | ||
eu-west-2 = "ami-132b3c7efe6sdfdsfd" | ||
eu-central-1 = "ami-9787h5h6nsn" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
arn:aws:ec2:us-east-1:150843920836:instance/i-0d2877106f7377c0c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
resource "aws_instance" "web-server" { | ||
ami = "${lookup(var.ami_id, var.region)}" | ||
instance_type = "t2.micro" | ||
} | ||
ami = "${lookup(var.ami_id, var.region)}" | ||
instance_type = "t2.micro" | ||
|
||
output "public_ip"{ | ||
value="${aws_instance.web-server.public_ip}" | ||
|
||
provisioner "local-exec" { | ||
command = "echo ${aws_instance.web-server.private_ip} >> ip_list.txt" | ||
} | ||
|
||
provisioner "local-exec" { | ||
command = "echo ${aws_instance.web-server.arn} >> arn.txt" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
172.31.84.95 | ||
172.31.45.49 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
output "public_ip"{ | ||
value="${aws_instance.web-server.public_ip}" | ||
output "public_ip" { | ||
value = "${aws_instance.web-server.public_ip}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# .tfvars files | ||
*.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Terraform-Tutorial | ||
Terraform Tutorial with all the Live Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
resource "aws_s3_bucket" "bucket" { | ||
bucket = "my-tf-test-bucket-abc" | ||
acl = "private" | ||
|
||
tags = { | ||
Name = "My bucket" | ||
Environment = "Dev" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_version = ">= 0.11.0" | ||
backend "s3" { | ||
bucket = "backup-state-terraform" | ||
key = "terraform/test" | ||
region = "us-east-1" | ||
dynamodb_table = "backend-test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "aws" { | ||
region = "${var.region}" | ||
version = "~> 2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
variable "access_key" {} | ||
variable "secret_key" {} | ||
variable "region" { | ||
default = "us-east-1" | ||
} | ||
variable "ami_id" { | ||
type = "map" | ||
default = { | ||
us-east-1 = "ami-035b3c7efe6d061d5" | ||
eu-west-2 = "ami-132b3c7efe6sdfdsfd" | ||
eu-central-1 = "ami-9787h5h6nsn" | ||
} | ||
} |