-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateIRSA-eksctl.sh
executable file
·54 lines (48 loc) · 1.27 KB
/
createIRSA-eksctl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
##!/bin/bash
CLUSTER_NAME="k8s-gitops-cluster"
REGION=us-east-1
SERVICE_ACCOUNT_NAMESPACE=sealed-secrets
SERVICE_ACCOUNT_NAME=external-secrets
SERVICE_ACCOUNT_IAM_ROLE=EKS-ExteranlSecrets-ServiceAccount-Role
SERVICE_ACCOUNT_IAM_POLICY=EKS-SecretsManager-Policy
#
# Set up the permission policy
#
cat <<EOF > PermissionPolicy.json
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":[
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret",
"ssm:GetParameters"
],
"Resource":"*"
},
{
"Effect":"Allow",
"Action":[
"kms:Decrypt"
],
"Resource":"*"
}
]
}
EOF
SERVICE_ACCOUNT_IAM_POLICY_ARN=$(aws iam create-policy --policy-name $SERVICE_ACCOUNT_IAM_POLICY \
--policy-document file://PermissionPolicy.json \
--query 'Policy.Arn' --output text)
eksctl utils associate-iam-oidc-provider \
--cluster=$CLUSTER_NAME \
--approve
eksctl create iamserviceaccount \
--cluster=$CLUSTER_NAME \
--region=$REGION \
--name=$SERVICE_ACCOUNT_NAME \
--namespace=$SERVICE_ACCOUNT_NAMESPACE \
--role-name=$SERVICE_ACCOUNT_IAM_ROLE \
--attach-policy-arn=$SERVICE_ACCOUNT_IAM_POLICY_ARN \
--override-existing-serviceaccounts \
--approve