Skip to content

Commit

Permalink
add permissions for api key and usage plan CRUD
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-negusse committed Oct 16, 2023
1 parent 714d11c commit 378df36
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions terraform/modules/eks/api-gateway-access-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": "apigateway:*",
"Resource": [
"arn:aws:apigateway:*::/apikeys/*",
"arn:aws:apigateway:*::/apikeys",
"arn:aws:apigateway:*::/restapis/*/authorizers",
"arn:aws:apigateway:*::/restapis/*/authorizers/*",
"arn:aws:apigateway:*::/usageplans/*/keys/*",
"arn:aws:apigateway:*::/usageplans/*/keys"
]
},
{
"Sid": "",
"Effect": "Allow",
"Action": "apigateway:*",
"Resource": "arn:aws:apigateway:*::/usageplans/*"
}
]
}
15 changes: 15 additions & 0 deletions terraform/modules/eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ resource "aws_iam_policy" "eks-admin-DatabaseBackupToS3Policy" {
policy = data.aws_iam_policy_document.eks-admin-DatabaseBackupToS3-document.json
}

data "aws_iam_policy_document" "eks-admin-APIGatewayAccessPolicy-document" {
source_policy_documents = [file("${path.module}/api-gateway-access-policy.json")]
}

resource "aws_iam_policy" "eks-admin-APIGatewayAccessPolicy" {
name = "APIGatewayAccessPolicy"
path = "/"
policy = data.aws_iam_policy_document.eks-admin-APIGatewayAccessPolicy-document.json
}

resource "aws_iam_role" "ebs_csi_iam_role" {
name = "AmazonEKS_EBS_CSI_DriverRole"

Expand Down Expand Up @@ -244,3 +254,8 @@ resource "aws_iam_role_policy_attachment" "eks-node-group-admin-AmazonEKS_EBS_CS
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy"
role = aws_iam_role.eks-node-group-iam-role.name
}

resource "aws_iam_role_policy_attachment" "eks-node-group-admin-APIGatewayAccessPolicy" {
policy_arn = aws_iam_policy.eks-admin-APIGatewayAccessPolicy.arn
role = aws_iam_role.eks-node-group-iam-role.name
}

0 comments on commit 378df36

Please sign in to comment.