-
Notifications
You must be signed in to change notification settings - Fork 54
/
index.ts
93 lines (82 loc) · 3.01 KB
/
index.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2021, Pulumi Corporation. All rights reserved.
import * as pulumi from "@pulumi/pulumi";
import * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
import * as operator from "./operator";
// #############################################################################
// Deploy the Pulumi Kubernetes Operator
// By default, uses $HOME/.kube/config when no kubeconfig is set.
const provider = new k8s.Provider("k8s");
// Create the Pulumi Kubernetes Operator.
// Uses a custom ComponentResource class based on Typescript code in https://git.io/JJ6yj
const name = "pulumi-k8s-operator"
const pulumiOperator = new operator.PulumiKubernetesOperator(name, {
namespace: "default",
provider,
});
// #############################################################################
// Deploy AWS S3 Buckets
// Get the Pulumi API token and AWS creds.
const config = new pulumi.Config();
const pulumiAccessToken = config.requireSecret("pulumiAccessToken");
const awsAccessKeyId = config.require("awsAccessKeyId");
const awsSecretAccessKey = config.requireSecret("awsSecretAccessKey");
const awsSessionToken = config.requireSecret("awsSessionToken");
const stackName = config.require("stackName");
const stackProjectRepo = config.get("stackProjectRepo") || "https://github.com/joeduffy/test-s3-op-project";
// Create the creds as Kubernetes Secrets.
const accessToken = new kx.Secret("accesstoken", {
stringData: {accessToken: pulumiAccessToken},
});
const awsCreds = new kx.Secret("aws-creds", {
stringData: {
"AWS_ACCESS_KEY_ID": awsAccessKeyId,
"AWS_SECRET_ACCESS_KEY": awsSecretAccessKey,
"AWS_SESSION_TOKEN": awsSessionToken,
},
});
// Create an AWS S3 Pulumi Stack in Kubernetes.
const mystack = new k8s.apiextensions.CustomResource("my-stack", {
apiVersion: 'pulumi.com/v1',
kind: 'Stack',
spec: {
stack: stackName,
projectRepo: stackProjectRepo,
branch: "refs/heads/master",
envRefs: {
PULUMI_ACCESS_TOKEN:
{
type: "Secret",
secret: {
name: accessToken.metadata.name,
key: "accessToken",
},
},
AWS_ACCESS_KEY_ID: {
type: "Secret",
secret: {
name: awsCreds.metadata.name,
key: "AWS_ACCESS_KEY_ID",
},
},
AWS_SECRET_ACCESS_KEY: {
type: "Secret",
secret: {
name: awsCreds.metadata.name,
key: "AWS_SECRET_ACCESS_KEY",
},
},
AWS_SESSION_TOKEN: {
type: "Secret",
secret: {
name: awsCreds.metadata.name,
key: "AWS_SESSION_TOKEN",
}
}
},
config: {
"aws:region": "us-west-2",
},
destroyOnFinalize: true,
},
}, {dependsOn: pulumiOperator.deployment});