Skip to content

Instantly share code, notes, and snippets.

@lioneltchami
Created July 27, 2022 03:25
Show Gist options
  • Select an option

  • Save lioneltchami/a2c81bc30740bb87c5f4c4ce3655f896 to your computer and use it in GitHub Desktop.

Select an option

Save lioneltchami/a2c81bc30740bb87c5f4c4ce3655f896 to your computer and use it in GitHub Desktop.
resource "aws_iam_role" "kubernetes" {
name = "kubernetes"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ]
}
EOF
}
resource "aws_iam_role_policy" "kubernetes" {
name = "kubernetes"
role = "${aws_iam_role.kubernetes.id}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{ "Action" : ["ec2:*"], "Effect": "Allow", "Resource": ["*"] },
{ "Action" : ["elasticloadbalancing:*"], "Effect": "Allow", "Resource": ["*"] },
{ "Action": "route53:*", "Effect": "Allow", "Resource": ["*"] },
{ "Action": "ecr:*", "Effect": "Allow", "Resource": "*" }
]
}
EOF
}
resource "aws_iam_instance_profile" "kubernetes" {
name = "kubernetes"
roles = ["${aws_iam_role.kubernetes.name}"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment