sg, eks, iam 모듈추가
This commit is contained in:
16
modules/eks/main.tf
Normal file
16
modules/eks/main.tf
Normal file
@ -0,0 +1,16 @@
|
||||
resource "aws_eks_cluster" "demo" {
|
||||
name = var.cluster-name
|
||||
role_arn = aws_iam_role.demo-cluster.arn
|
||||
|
||||
enabled_cluster_log_types = ["api", "audit", "authenticator", "controllerManager", "scheduler"]
|
||||
|
||||
vpc_config {
|
||||
security_group_ids = [aws_security_group.demo-cluster.id]
|
||||
subnet_ids = [
|
||||
aws_subnet.VPC_HQ_public_1a.id,
|
||||
aws_subnet.VPC_HQ_public_1c.id
|
||||
]
|
||||
endpoint_private_access = true
|
||||
endpoint_public_access = true
|
||||
}
|
||||
}
|
0
modules/eks/outputs.tf
Normal file
0
modules/eks/outputs.tf
Normal file
0
modules/eks/valiables.tf
Normal file
0
modules/eks/valiables.tf
Normal file
5
modules/iam-policy-attach/main.tf
Normal file
5
modules/iam-policy-attach/main.tf
Normal file
@ -0,0 +1,5 @@
|
||||
resource "aws_iam_policy_attachment" "test-attach" {
|
||||
name = "${var.iam_name}-att"
|
||||
roles = ["${var.role_name}"]
|
||||
policy_arn = "${var.arn}"
|
||||
}
|
0
modules/iam-policy-attach/outputs.tf
Normal file
0
modules/iam-policy-attach/outputs.tf
Normal file
14
modules/iam-policy-attach/variables.tf
Normal file
14
modules/iam-policy-attach/variables.tf
Normal file
@ -0,0 +1,14 @@
|
||||
variable "iam_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "role_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "arn" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
14
modules/iam/eks-cluster.json.tftpl
Normal file
14
modules/iam/eks-cluster.json.tftpl
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"Version" : "2012-10-17",
|
||||
"Statement" : [
|
||||
{
|
||||
"Effect" : "Allow",
|
||||
"Principal" : {
|
||||
"Service" : [
|
||||
"eks.amazonaws.com"
|
||||
]
|
||||
},
|
||||
"Action" : "sts:AssumeRole"
|
||||
}
|
||||
]
|
||||
}
|
23
modules/iam/main.tf
Normal file
23
modules/iam/main.tf
Normal file
@ -0,0 +1,23 @@
|
||||
resource "aws_iam_role" "iam-role" {
|
||||
name = var.iam_name
|
||||
assume_role_policy = var.policy
|
||||
|
||||
tags = {
|
||||
tag-key = var.tag_name
|
||||
}
|
||||
}
|
||||
|
||||
# {
|
||||
# "Version" : "2012-10-17",
|
||||
# "Statement" : [
|
||||
# {
|
||||
# "Effect" : "Allow",
|
||||
# "Principal" : {
|
||||
# "Service" : [
|
||||
# "eks.amazonaws.com"
|
||||
# ]
|
||||
# },
|
||||
# "Action" : "sts:AssumeRole"
|
||||
# }
|
||||
# ]
|
||||
# }
|
4
modules/iam/outputs.tf
Normal file
4
modules/iam/outputs.tf
Normal file
@ -0,0 +1,4 @@
|
||||
output "iam_name" {
|
||||
value = aws_iam_role.iam-role.name
|
||||
|
||||
}
|
14
modules/iam/variables.tf
Normal file
14
modules/iam/variables.tf
Normal file
@ -0,0 +1,14 @@
|
||||
variable "iam_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "policy" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
variable "vpc_id" {
|
||||
description = "set vpc id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
variable "vpc_id" {
|
||||
description = "set vpc id"
|
||||
type = string
|
||||
}
|
11
modules/sg-rule-add/main.tf
Normal file
11
modules/sg-rule-add/main.tf
Normal file
@ -0,0 +1,11 @@
|
||||
resource "aws_security_group_rule" "sg-rule-add" {
|
||||
description = "Security groups rule add"
|
||||
|
||||
type = var.type
|
||||
from_port = var.set_ports.http
|
||||
to_port = var.set_ports.http
|
||||
protocol = var.set_ports.protocol_tcp #tcp
|
||||
cidr_blocks = var.cidr_blocks
|
||||
security_group_id = var.sg_id
|
||||
|
||||
}
|
10
modules/sg-rule-add/outputs.tf
Normal file
10
modules/sg-rule-add/outputs.tf
Normal file
@ -0,0 +1,10 @@
|
||||
//sg-output
|
||||
output "vpc_hq_id" {
|
||||
description = "The name of vpc hq id"
|
||||
value = aws_vpc.vpc-hq.id
|
||||
}
|
||||
|
||||
output "vpc_name" {
|
||||
value = var.tag_name
|
||||
}
|
||||
|
8
modules/sg-rule-add/variables.tf
Normal file
8
modules/sg-rule-add/variables.tf
Normal file
@ -0,0 +1,8 @@
|
||||
variable "type" {
|
||||
description = "security rule type"
|
||||
type = string
|
||||
}
|
||||
variable "from_port" {
|
||||
description = "from port"
|
||||
type = number
|
||||
}
|
5
modules/sg/main.tf
Normal file
5
modules/sg/main.tf
Normal file
@ -0,0 +1,5 @@
|
||||
resource "aws_security_group" "sg" {
|
||||
description = "Security groups"
|
||||
name = var.sg_name
|
||||
|
||||
}
|
5
modules/sg/outputs.tf
Normal file
5
modules/sg/outputs.tf
Normal file
@ -0,0 +1,5 @@
|
||||
//sg-output
|
||||
output "sg_id" {
|
||||
description = "sg id outputs"
|
||||
value = aws_security_group.sg.id
|
||||
}
|
4
modules/sg/variables.tf
Normal file
4
modules/sg/variables.tf
Normal file
@ -0,0 +1,4 @@
|
||||
variable "sg_name" {
|
||||
description = "security group name"
|
||||
type = string
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
resource "aws_iam_role" "eks-cluster" {
|
||||
name = "iam role eks-cluster"
|
||||
|
||||
# Terraform's "jsonencode" function converts a
|
||||
# Terraform expression result to valid JSON syntax.
|
||||
assume_role_policy = jsonencode({
|
||||
"Version" : "2012-10-17",
|
||||
"Statement" : [
|
||||
{
|
||||
"Effect" : "Allow",
|
||||
"Principal" : {
|
||||
"Service" : [
|
||||
"eks.amazonaws.com"
|
||||
]
|
||||
},
|
||||
"Action" : "sts:AssumeRole"
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
tags = {
|
||||
tag-key = "eks-cluster-rule"
|
||||
}
|
||||
}
|
||||
|
10
modules/vpc-subnet/terraform.tf
Normal file
10
modules/vpc-subnet/terraform.tf
Normal file
@ -0,0 +1,10 @@
|
||||
terraform {
|
||||
backend "remote"{
|
||||
hostname = "app.terraform.io"
|
||||
organization = "22shop"
|
||||
|
||||
workspaces {
|
||||
name = "tf-cloud-backend"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user