Skip to content

Commit

Permalink
added eks examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dsreehas committed Apr 29, 2024
1 parent 06ac780 commit 59bba79
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified examples/.DS_Store
Binary file not shown.
Binary file added examples/eks-role/.DS_Store
Binary file not shown.
Binary file added examples/eks-role/aws-managed/.DS_Store
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions examples/eks-role/aws-managed/eks-service-role/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "iam_role_with_managed_policies" {
source = "github.com/dsreehas/terraform-iam-role"
role_name = var.role_name
assume_role_policy = file("./policies/assume_role_policy.json")
managed_policy_arns = var.managed_policy_arns

}
19 changes: 19 additions & 0 deletions examples/eks-role/aws-managed/eks-service-role/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
output "iam_role_with_managed_policies_arn" {
description = "The Amazon Resource Name (ARN) specifying the IAM role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_arn
}

output "iam_role_with_managed_policies_name" {
description = "The name of the IAM role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_name
}

output "iam_role_with_managed_policies_assume_role_policy" {
description = "The IAM assume role policy associated with the role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_assume_role_policy
}

output "iam_role_with_managed_policies_managed_policy_arns" {
description = "The managed policy ARNs attached to the IAM role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_managed_policy_arns
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
13 changes: 13 additions & 0 deletions examples/eks-role/aws-managed/eks-service-role/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.0.0"
}
}
}

provider "aws" {
region = var.aws_region
profile = var.aws_profile
}
23 changes: 23 additions & 0 deletions examples/eks-role/aws-managed/eks-service-role/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "aws_region" {
description = "Selected AWS region"
type = string
default = null
}

variable "aws_profile" {
description = "Selected AWS profile"
type = string
default = null
}

variable "role_name" {
description = "Name of the IAM role"
type = string
default = "multiple-managed-policies-role"
}

variable "managed_policy_arns" {
description = "List of managed policies ARNs to attach"
type = list(string)
default = ["arn:aws:iam::aws:policy/AmazonEKSClusterPolicy", "arn:aws:iam::aws:policy/AmazonEKSVPCResourceController"]
}
3 changes: 3 additions & 0 deletions examples/eks-role/aws-managed/eks-service-role/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.13"
}
Binary file not shown.
7 changes: 7 additions & 0 deletions examples/eks-role/aws-managed/eks-worker-node-role/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "iam_role_with_managed_policies" {
source = "github.com/dsreehas/terraform-iam-role"
role_name = var.role_name
assume_role_policy = file("./policies/assume_role_policy.json")
managed_policy_arns = var.managed_policy_arns

}
19 changes: 19 additions & 0 deletions examples/eks-role/aws-managed/eks-worker-node-role/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
output "iam_role_with_managed_policies_arn" {
description = "The Amazon Resource Name (ARN) specifying the IAM role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_arn
}

output "iam_role_with_managed_policies_name" {
description = "The name of the IAM role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_name
}

output "iam_role_with_managed_policies_assume_role_policy" {
description = "The IAM assume role policy associated with the role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_assume_role_policy
}

output "iam_role_with_managed_policies_managed_policy_arns" {
description = "The managed policy ARNs attached to the IAM role with managed policies"
value = module.iam_role_with_managed_policies.iam_role_managed_policy_arns
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
13 changes: 13 additions & 0 deletions examples/eks-role/aws-managed/eks-worker-node-role/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.0.0"
}
}
}

provider "aws" {
region = var.aws_region
profile = var.aws_profile
}
23 changes: 23 additions & 0 deletions examples/eks-role/aws-managed/eks-worker-node-role/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable "aws_region" {
description = "Selected AWS region"
type = string
default = null
}

variable "aws_profile" {
description = "Selected AWS profile"
type = string
default = null
}

variable "role_name" {
description = "Name of the IAM role"
type = string
default = "multiple-managed-policies-role"
}

variable "managed_policy_arns" {
description = "List of managed policies ARNs to attach"
type = list(string)
default = ["arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.13"
}

0 comments on commit 59bba79

Please sign in to comment.