-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
abe8d90
commit 1e4c37a
Showing
10 changed files
with
627 additions
and
24 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
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,11 @@ | ||
# Terraform version | ||
terraform { | ||
required_version = ">= 1.5.0" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.5.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
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 @@ | ||
module "fargate" { | ||
source = "./node_group/fargate_profile" | ||
|
||
name = var.name | ||
environment = var.environment | ||
label_order = var.label_order | ||
enabled =var.enabled | ||
fargate_enabled = var.fargate_enabled | ||
cluster_name = join("", aws_eks_cluster.default.*.name) | ||
fargate_profiles = var.fargate_profiles | ||
subnet_ids = var.subnet_ids | ||
|
||
} |
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
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,72 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 3.1.15" | ||
} | ||
} | ||
} | ||
|
||
#Module : label | ||
#Description : Terraform module to create consistent naming for multiple names. | ||
module "labels" { | ||
source = "clouddrove/labels/aws" | ||
version = "1.3.0" | ||
|
||
name = var.name | ||
environment = var.environment | ||
managedby = var.managedby | ||
delimiter = var.delimiter | ||
attributes = compact(concat(var.attributes, ["fargate"])) | ||
label_order = var.label_order | ||
} | ||
|
||
|
||
#Module : IAM ROLE | ||
#Description : Provides an IAM role. | ||
resource "aws_iam_role" "fargate_role" { | ||
count = var.enabled && var.fargate_enabled ? 1 : 0 | ||
|
||
name = format("%s-fargate-role", module.labels.id) | ||
assume_role_policy = join("", data.aws_iam_policy_document.aws_eks_fargate_policy.*.json) | ||
tags = module.labels.tags | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "amazon_eks_fargate_pod_execution_role_policy" { | ||
count = var.enabled && var.fargate_enabled ? 1 : 0 | ||
|
||
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy" | ||
role = join("", aws_iam_role.fargate_role.*.name) | ||
} | ||
|
||
#Module : EKS Fargate | ||
#Descirption : Enabling fargate for AWS EKS | ||
resource "aws_eks_fargate_profile" "default" { | ||
for_each = var.enabled && var.fargate_enabled ? var.fargate_profiles : {} | ||
|
||
cluster_name = var.cluster_name | ||
fargate_profile_name = format("%s-%s", module.labels.id, each.value.addon_name ) | ||
pod_execution_role_arn = aws_iam_role.fargate_role[0].arn | ||
subnet_ids = var.subnet_ids | ||
tags = module.labels.tags | ||
|
||
selector { | ||
namespace = lookup(each.value, "namespace", "default") | ||
labels = lookup(each.value, "labels", null ) | ||
} | ||
} | ||
|
||
# AWS EKS Fargate policy | ||
data "aws_iam_policy_document" "aws_eks_fargate_policy" { | ||
count = var.enabled && var.fargate_enabled ? 1 : 0 | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["eks-fargate-pods.amazonaws.com"] | ||
} | ||
} | ||
} |
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,72 @@ | ||
#Module : LABEL | ||
#Description : Terraform label module variables. | ||
variable "name" { | ||
type = string | ||
default = "" | ||
description = "Name (e.g. `app` or `cluster`)." | ||
} | ||
|
||
variable "environment" { | ||
type = string | ||
default = "" | ||
description = "Environment (e.g. `prod`, `dev`, `staging`)." | ||
} | ||
|
||
variable "label_order" { | ||
type = list(any) | ||
default = [] | ||
description = "Label order, e.g. `name`,`application`." | ||
} | ||
|
||
variable "attributes" { | ||
type = list(any) | ||
default = [] | ||
description = "Additional attributes (e.g. `1`)." | ||
} | ||
|
||
variable "tags" { | ||
type = map(any) | ||
default = {} | ||
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)." | ||
} | ||
|
||
variable "managedby" { | ||
type = string | ||
default = "hello@clouddorve.com" | ||
description = "ManagedBy, eg 'pps'." | ||
} | ||
|
||
variable "delimiter" { | ||
type = string | ||
default = "-" | ||
description = "Delimiter to be used between `organization`, `environment`, `name` and `attributes`." | ||
} | ||
|
||
variable "enabled" { | ||
type = bool | ||
default = true | ||
description = "Whether to create the resources. Set to `false` to prevent the module from creating any resources." | ||
} | ||
|
||
variable "fargate_enabled" { | ||
type = bool | ||
default = false | ||
description = "Whether fargate profile is enabled or not" | ||
} | ||
|
||
variable "fargate_profiles" { | ||
type = map(any) | ||
default = {} | ||
description = "The number of Fargate Profiles that would be created." | ||
} | ||
|
||
variable "cluster_name" { | ||
type = string | ||
default = "" | ||
description = "The name of the EKS cluster." | ||
} | ||
|
||
variable "subnet_ids" { | ||
type = list(string) | ||
description = "A list of subnet IDs to launch resources in." | ||
} |
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