@highstate/cloudflare 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connection/index.js +44 -0
- package/dist/index.js +9175 -0
- package/package.json +34 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
import { cloudflare } from '@highstate/library';
|
2
|
+
import { forUnit } from '@highstate/pulumi';
|
3
|
+
import { Provider, getZones } from '@pulumi/cloudflare';
|
4
|
+
|
5
|
+
const { name, secrets, outputs } = forUnit(cloudflare.connection);
|
6
|
+
const provider = new Provider("cloudflare", { apiToken: secrets.apiToken });
|
7
|
+
const { zones } = await getZones({ filter: {} }, { provider });
|
8
|
+
if (!zones.length) {
|
9
|
+
throw new Error(
|
10
|
+
"No zones found with the provided API token. Ensure the token has Zone.Zone:Read permission on the zone."
|
11
|
+
);
|
12
|
+
}
|
13
|
+
if (zones.length > 1) {
|
14
|
+
throw new Error(
|
15
|
+
"Multiple zones found with the provided API token, please use separate tokens and connections for each zone."
|
16
|
+
);
|
17
|
+
}
|
18
|
+
if (!zones[0].id) {
|
19
|
+
throw new Error("Zone ID is missing.");
|
20
|
+
}
|
21
|
+
if (!zones[0].name) {
|
22
|
+
throw new Error("Zone name is missing.");
|
23
|
+
}
|
24
|
+
var index = outputs({
|
25
|
+
dnsProvider: {
|
26
|
+
name,
|
27
|
+
type: "cloudflare",
|
28
|
+
domain: zones[0].name,
|
29
|
+
data: {
|
30
|
+
zoneId: zones[0].id,
|
31
|
+
apiToken: secrets.apiToken
|
32
|
+
}
|
33
|
+
},
|
34
|
+
$status: {
|
35
|
+
domain: {
|
36
|
+
value: zones[0].name
|
37
|
+
},
|
38
|
+
zoneId: {
|
39
|
+
value: zones[0].id
|
40
|
+
}
|
41
|
+
}
|
42
|
+
});
|
43
|
+
|
44
|
+
export { index as default };
|