mirror of
https://github.com/farcasclaudiu/terraform-course.git
synced 2026-06-22 07:01:56 +03:00
5d9eeb6c4c
* Terraform 0.12
58 lines
1.3 KiB
Terraform
58 lines
1.3 KiB
Terraform
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-cluster.name
|
|
}
|
|
|
|
resource "aws_iam_role_policy_attachment" "demo-cluster-AmazonEKSServicePolicy" {
|
|
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSServicePolicy"
|
|
role = aws_iam_role.demo-cluster.name
|
|
}
|
|
|
|
# If no loadbalancer was ever created in this region, then this following role is necessary
|
|
resource "aws_iam_role_policy" "demo-cluster-service-linked-role" {
|
|
name = "service-linked-role"
|
|
role = aws_iam_role.demo-cluster.name
|
|
|
|
policy = <<EOF
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Effect": "Allow",
|
|
"Action": "iam:CreateServiceLinkedRole",
|
|
"Resource": "arn:aws:iam::*:role/aws-service-role/*"
|
|
},
|
|
{
|
|
"Effect": "Allow",
|
|
"Action": [
|
|
"ec2:DescribeAccountAttributes"
|
|
],
|
|
"Resource": "*"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
|
|
}
|
|
|