Skip to content

Instantly share code, notes, and snippets.

@blogumi
Created April 4, 2020 18:55
Show Gist options
  • Save blogumi/bb0b3d243d062d9ae470bbea6061b195 to your computer and use it in GitHub Desktop.
Save blogumi/bb0b3d243d062d9ae470bbea6061b195 to your computer and use it in GitHub Desktop.
The below is an example IAM role and policy to allow the worker nodes to manage or retrieve data from other AWS services. It is used by Kubernetes to allow worker nodes to join the cluster.
resource "aws_iam_role" "demo-cluster" {
name = "terraform-eks-demo-cluster"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "eks.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
POLICY
}
resource "aws_iam_role_policy_attachment" "demo-cluster-AmazonEKSClusterPolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy"
role = aws_iam_role.demo-node.name
}
resource "aws_iam_role_policy_attachment" "demo-cluster-AmazonEKSServicePolicy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
role = aws_iam_role.demo-node.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment