forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
39 lines (37 loc) · 1.12 KB
/
utils.py
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
import json
import pulumi
def generate_kube_config(eks_cluster):
kubeconfig = pulumi.Output.all(eks_cluster.endpoint, eks_cluster.certificate_authority.apply(lambda v: v.data), eks_cluster.name).apply(lambda args: json.dumps({
"apiVersion": "v1",
"clusters": [{
"cluster": {
"server": args[0],
"certificate-authority-data": args[1]
},
"name": "kubernetes",
}],
"contexts": [{
"context": {
"cluster": "kubernetes",
"user": "aws",
},
"name": "aws",
}],
"current-context": "aws",
"kind": "Config",
"users": [{
"name": "aws",
"user": {
"exec": {
"apiVersion": "client.authentication.k8s.io/v1alpha1",
"command": "aws-iam-authenticator",
"args": [
"token",
"-i",
args[2],
],
},
},
}],
}))
return kubeconfig