@pulumi/fastly 11.2.0-alpha.1762840749 → 11.2.0-alpha.1763071789
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/package.json +2 -2
- package/tlsCertificate.d.ts +2 -2
- package/tlsCertificate.js +2 -2
- package/tlsPlatformCertificate.d.ts +5 -5
- package/tlsPlatformCertificate.js +5 -5
- package/tlsPrivateKey.d.ts +1 -1
- package/tlsPrivateKey.js +1 -1
- package/tlsSubscription.d.ts +192 -0
- package/tlsSubscription.js +192 -0
- package/tlsSubscription.js.map +1 -1
- package/tlsSubscriptionValidation.d.ts +84 -0
- package/tlsSubscriptionValidation.js +84 -0
- package/tlsSubscriptionValidation.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulumi/fastly",
|
|
3
|
-
"version": "11.2.0-alpha.
|
|
3
|
+
"version": "11.2.0-alpha.1763071789",
|
|
4
4
|
"description": "A Pulumi package for creating and managing fastly cloud resources.. Based on terraform-provider-fastly: version v4",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pulumi",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"pulumi": {
|
|
24
24
|
"resource": true,
|
|
25
25
|
"name": "fastly",
|
|
26
|
-
"version": "11.2.0-alpha.
|
|
26
|
+
"version": "11.2.0-alpha.1763071789"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/tlsCertificate.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
14
14
|
* import * as fastly from "@pulumi/fastly";
|
|
15
15
|
* import * as tls from "@pulumi/tls";
|
|
16
16
|
*
|
|
17
|
-
* const key = new tls.
|
|
18
|
-
* const cert = new tls.
|
|
17
|
+
* const key = new tls.PrivateKey("key", {algorithm: "RSA"});
|
|
18
|
+
* const cert = new tls.SelfSignedCert("cert", {
|
|
19
19
|
* keyAlgorithm: key.algorithm,
|
|
20
20
|
* privateKeyPem: key.privateKeyPem,
|
|
21
21
|
* subject: [{
|
package/tlsCertificate.js
CHANGED
|
@@ -20,8 +20,8 @@ const utilities = require("./utilities");
|
|
|
20
20
|
* import * as fastly from "@pulumi/fastly";
|
|
21
21
|
* import * as tls from "@pulumi/tls";
|
|
22
22
|
*
|
|
23
|
-
* const key = new tls.
|
|
24
|
-
* const cert = new tls.
|
|
23
|
+
* const key = new tls.PrivateKey("key", {algorithm: "RSA"});
|
|
24
|
+
* const cert = new tls.SelfSignedCert("cert", {
|
|
25
25
|
* keyAlgorithm: key.algorithm,
|
|
26
26
|
* privateKeyPem: key.privateKeyPem,
|
|
27
27
|
* subject: [{
|
|
@@ -14,9 +14,9 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
14
14
|
* import * as fastly from "@pulumi/fastly";
|
|
15
15
|
* import * as tls from "@pulumi/tls";
|
|
16
16
|
*
|
|
17
|
-
* const caKey = new tls.
|
|
18
|
-
* const key = new tls.
|
|
19
|
-
* const ca = new tls.
|
|
17
|
+
* const caKey = new tls.PrivateKey("ca_key", {algorithm: "RSA"});
|
|
18
|
+
* const key = new tls.PrivateKey("key", {algorithm: "RSA"});
|
|
19
|
+
* const ca = new tls.SelfSignedCert("ca", {
|
|
20
20
|
* keyAlgorithm: caKey.algorithm,
|
|
21
21
|
* privateKeyPem: caKey.privateKeyPem,
|
|
22
22
|
* subject: [{
|
|
@@ -29,7 +29,7 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
29
29
|
* "server_auth",
|
|
30
30
|
* ],
|
|
31
31
|
* });
|
|
32
|
-
* const example = new tls.
|
|
32
|
+
* const example = new tls.CertRequest("example", {
|
|
33
33
|
* keyAlgorithm: key.algorithm,
|
|
34
34
|
* privateKeyPem: key.privateKeyPem,
|
|
35
35
|
* subject: [{
|
|
@@ -40,7 +40,7 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
40
40
|
* "www.example.com",
|
|
41
41
|
* ],
|
|
42
42
|
* });
|
|
43
|
-
* const cert = new tls.
|
|
43
|
+
* const cert = new tls.LocallySignedCert("cert", {
|
|
44
44
|
* certRequestPem: example.certRequestPem,
|
|
45
45
|
* caKeyAlgorithm: caKey.algorithm,
|
|
46
46
|
* caPrivateKeyPem: caKey.privateKeyPem,
|
|
@@ -20,9 +20,9 @@ const utilities = require("./utilities");
|
|
|
20
20
|
* import * as fastly from "@pulumi/fastly";
|
|
21
21
|
* import * as tls from "@pulumi/tls";
|
|
22
22
|
*
|
|
23
|
-
* const caKey = new tls.
|
|
24
|
-
* const key = new tls.
|
|
25
|
-
* const ca = new tls.
|
|
23
|
+
* const caKey = new tls.PrivateKey("ca_key", {algorithm: "RSA"});
|
|
24
|
+
* const key = new tls.PrivateKey("key", {algorithm: "RSA"});
|
|
25
|
+
* const ca = new tls.SelfSignedCert("ca", {
|
|
26
26
|
* keyAlgorithm: caKey.algorithm,
|
|
27
27
|
* privateKeyPem: caKey.privateKeyPem,
|
|
28
28
|
* subject: [{
|
|
@@ -35,7 +35,7 @@ const utilities = require("./utilities");
|
|
|
35
35
|
* "server_auth",
|
|
36
36
|
* ],
|
|
37
37
|
* });
|
|
38
|
-
* const example = new tls.
|
|
38
|
+
* const example = new tls.CertRequest("example", {
|
|
39
39
|
* keyAlgorithm: key.algorithm,
|
|
40
40
|
* privateKeyPem: key.privateKeyPem,
|
|
41
41
|
* subject: [{
|
|
@@ -46,7 +46,7 @@ const utilities = require("./utilities");
|
|
|
46
46
|
* "www.example.com",
|
|
47
47
|
* ],
|
|
48
48
|
* });
|
|
49
|
-
* const cert = new tls.
|
|
49
|
+
* const cert = new tls.LocallySignedCert("cert", {
|
|
50
50
|
* certRequestPem: example.certRequestPem,
|
|
51
51
|
* caKeyAlgorithm: caKey.algorithm,
|
|
52
52
|
* caPrivateKeyPem: caKey.privateKeyPem,
|
package/tlsPrivateKey.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
13
13
|
* import * as fastly from "@pulumi/fastly";
|
|
14
14
|
* import * as tls from "@pulumi/tls";
|
|
15
15
|
*
|
|
16
|
-
* const demo = new tls.
|
|
16
|
+
* const demo = new tls.PrivateKey("demo", {algorithm: "RSA"});
|
|
17
17
|
* const demoTlsPrivateKey = new fastly.TlsPrivateKey("demo", {
|
|
18
18
|
* keyPem: demo.privateKeyPem,
|
|
19
19
|
* name: "tf-demo",
|
package/tlsPrivateKey.js
CHANGED
|
@@ -19,7 +19,7 @@ const utilities = require("./utilities");
|
|
|
19
19
|
* import * as fastly from "@pulumi/fastly";
|
|
20
20
|
* import * as tls from "@pulumi/tls";
|
|
21
21
|
*
|
|
22
|
-
* const demo = new tls.
|
|
22
|
+
* const demo = new tls.PrivateKey("demo", {algorithm: "RSA"});
|
|
23
23
|
* const demoTlsPrivateKey = new fastly.TlsPrivateKey("demo", {
|
|
24
24
|
* keyPem: demo.privateKeyPem,
|
|
25
25
|
* name: "tf-demo",
|
package/tlsSubscription.d.ts
CHANGED
|
@@ -12,6 +12,198 @@ import * as outputs from "./types/output";
|
|
|
12
12
|
*
|
|
13
13
|
* The examples below demonstrate usage with AWS Route53 to configure DNS, and the `fastly.TlsSubscriptionValidation` resource to wait for validation to complete.
|
|
14
14
|
*
|
|
15
|
+
* ## Example Usage
|
|
16
|
+
*
|
|
17
|
+
* **Basic usage:**
|
|
18
|
+
*
|
|
19
|
+
* The following example demonstrates how to configure two subdomains (e.g. `a.example.com`, `b.example.com`).
|
|
20
|
+
*
|
|
21
|
+
* The workflow configures a `fastly.TlsSubscription` resource, then a `awsRoute53Record` resource for handling the creation of the 'challenge' DNS records (e.g. `_acme-challenge.a.example.com` and `_acme-challenge.b.example.com`).
|
|
22
|
+
*
|
|
23
|
+
* We configure the `fastly.TlsSubscriptionValidation` resource, which blocks other resources until the challenge DNS records have been validated by Fastly.
|
|
24
|
+
*
|
|
25
|
+
* Once the validation has been successful, the configured `fastly.getTlsConfiguration` data source will filter the available results looking for an appropriate TLS configuration object. If that filtering process is successful, then the subsequent `awsRoute53Record` resources (for configuring the subdomains) will be executed using the returned TLS configuration data.
|
|
26
|
+
*
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
29
|
+
* import * as aws from "@pulumi/aws";
|
|
30
|
+
* import * as fastly from "@pulumi/fastly";
|
|
31
|
+
* import * as std from "@pulumi/std";
|
|
32
|
+
*
|
|
33
|
+
* // NOTE: Creating a hosted zone will automatically create SOA/NS records.
|
|
34
|
+
* const production = new aws.index.Route53Zone("production", {name: "example.com"});
|
|
35
|
+
* const example = new aws.index.Route53domainsRegisteredDomain("example", {
|
|
36
|
+
* nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({
|
|
37
|
+
* name: entry.value,
|
|
38
|
+
* })),
|
|
39
|
+
* domainName: "example.com",
|
|
40
|
+
* });
|
|
41
|
+
* const subdomains = [
|
|
42
|
+
* "a.example.com",
|
|
43
|
+
* "b.example.com",
|
|
44
|
+
* ];
|
|
45
|
+
* const exampleServiceVcl = new fastly.ServiceVcl("example", {
|
|
46
|
+
* domains: subdomains.map((v, k) => ({key: k, value: v})).map(entry => ({
|
|
47
|
+
* name: entry.value,
|
|
48
|
+
* })),
|
|
49
|
+
* name: "example-service",
|
|
50
|
+
* backends: [{
|
|
51
|
+
* address: "127.0.0.1",
|
|
52
|
+
* name: "localhost",
|
|
53
|
+
* }],
|
|
54
|
+
* forceDestroy: true,
|
|
55
|
+
* });
|
|
56
|
+
* const exampleTlsSubscription = new fastly.TlsSubscription("example", {
|
|
57
|
+
* domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))),
|
|
58
|
+
* certificateAuthority: "lets-encrypt",
|
|
59
|
+
* });
|
|
60
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
61
|
+
* exampleTlsSubscription.domains.apply(domains => {
|
|
62
|
+
* for (const range of Object.entries(domains.reduce((__obj, domain) => ({ ...__obj, [domain]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${domain}`).map(obj => (obj)))[0] }))).map(([k, v]) => ({key: k, value: v}))) {
|
|
63
|
+
* domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, {
|
|
64
|
+
* name: range.value.recordName,
|
|
65
|
+
* type: range.value.recordType,
|
|
66
|
+
* zoneId: production.zoneId,
|
|
67
|
+
* allowOverwrite: true,
|
|
68
|
+
* records: [range.value.recordValue],
|
|
69
|
+
* ttl: 60,
|
|
70
|
+
* }, {
|
|
71
|
+
* dependsOn: [exampleTlsSubscription],
|
|
72
|
+
* }));
|
|
73
|
+
* }
|
|
74
|
+
* });
|
|
75
|
+
* // This is a resource that other resources can depend on if they require the certificate to be issued.
|
|
76
|
+
* // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached).
|
|
77
|
+
* const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, {
|
|
78
|
+
* dependsOn: [domainValidation],
|
|
79
|
+
* });
|
|
80
|
+
* // This data source lists all available configuration objects.
|
|
81
|
+
* // It uses a `default` attribute to narrow down the list to just one configuration object.
|
|
82
|
+
* // If the filtered list has a length that is not exactly one element, you'll see an error returned.
|
|
83
|
+
* // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below).
|
|
84
|
+
* //
|
|
85
|
+
* // IMPORTANT: Not all customers will have a 'default' configuration.
|
|
86
|
+
* // If you have issues filtering with `default = true`, then you may need another attribute.
|
|
87
|
+
* // Refer to the fastly_tls_configuration documentation for available attributes:
|
|
88
|
+
* // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional
|
|
89
|
+
* const defaultTls = fastly.getTlsConfiguration({
|
|
90
|
+
* "default": true,
|
|
91
|
+
* });
|
|
92
|
+
* // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple subdomain records.
|
|
93
|
+
* const subdomain: aws.index.Route53Record[] = [];
|
|
94
|
+
* for (const range = {value: 0}; range.value < std.index.toset({
|
|
95
|
+
* input: subdomains,
|
|
96
|
+
* }).result; range.value++) {
|
|
97
|
+
* subdomain.push(new aws.index.Route53Record(`subdomain-${range.value}`, {
|
|
98
|
+
* name: range.value,
|
|
99
|
+
* records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)),
|
|
100
|
+
* ttl: 300,
|
|
101
|
+
* type: "CNAME",
|
|
102
|
+
* zoneId: production.zoneId,
|
|
103
|
+
* }));
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* **Configuring an apex and a wildcard domain:**
|
|
108
|
+
*
|
|
109
|
+
* The following example is similar to the above but differs by demonstrating how to handle configuring an apex domain (e.g. `example.com`) and a wildcard domain (e.g. `*.example.com`) so you can support multiple subdomains to your service.
|
|
110
|
+
*
|
|
111
|
+
* The difference in the workflow is with how to handle the Fastly API returning a single 'challenge' for both domains (e.g. `_acme-challenge.example.com`). This is done by normalising the wildcard (i.e. replacing `*.example.com` with `example.com`) and then working around the issue of the returned object having two identical keys.
|
|
112
|
+
*
|
|
113
|
+
* ```typescript
|
|
114
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
115
|
+
* import * as aws from "@pulumi/aws";
|
|
116
|
+
* import * as fastly from "@pulumi/fastly";
|
|
117
|
+
* import * as std from "@pulumi/std";
|
|
118
|
+
*
|
|
119
|
+
* // NOTE: Creating a hosted zone will automatically create SOA/NS records.
|
|
120
|
+
* const production = new aws.index.Route53Zone("production", {name: "example.com"});
|
|
121
|
+
* const example = new aws.index.Route53domainsRegisteredDomain("example", {
|
|
122
|
+
* nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({
|
|
123
|
+
* name: entry.value,
|
|
124
|
+
* })),
|
|
125
|
+
* domainName: "example.com",
|
|
126
|
+
* });
|
|
127
|
+
* const domains = [
|
|
128
|
+
* "example.com",
|
|
129
|
+
* "*.example.com",
|
|
130
|
+
* ];
|
|
131
|
+
* const exampleServiceVcl = new fastly.ServiceVcl("example", {
|
|
132
|
+
* domains: domains.map((v, k) => ({key: k, value: v})).map(entry => ({
|
|
133
|
+
* name: entry.value,
|
|
134
|
+
* })),
|
|
135
|
+
* name: "example-service",
|
|
136
|
+
* backends: [{
|
|
137
|
+
* address: "127.0.0.1",
|
|
138
|
+
* name: "localhost",
|
|
139
|
+
* }],
|
|
140
|
+
* forceDestroy: true,
|
|
141
|
+
* });
|
|
142
|
+
* const exampleTlsSubscription = new fastly.TlsSubscription("example", {
|
|
143
|
+
* domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))),
|
|
144
|
+
* certificateAuthority: "lets-encrypt",
|
|
145
|
+
* });
|
|
146
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
147
|
+
* exampleTlsSubscription.domains.apply(domains => {
|
|
148
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
149
|
+
* pulumi.all(domains.reduce((__obj, domain) => ({ ...__obj, [std.index.replace({
|
|
150
|
+
* text: domain,
|
|
151
|
+
* search: "*.",
|
|
152
|
+
* replace: "",
|
|
153
|
+
* }).result]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${std.index.replace({
|
|
154
|
+
* text: domain,
|
|
155
|
+
* search: "*.",
|
|
156
|
+
* replace: "",
|
|
157
|
+
* }).result}`).map(obj => (obj)))[0] }))).apply(rangeBody => {
|
|
158
|
+
* for (const range of Object.entries(rangeBody).map(([k, v]) => ({key: k, value: v}))) {
|
|
159
|
+
* domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, {
|
|
160
|
+
* name: range.value[0].recordName,
|
|
161
|
+
* type: range.value[0].recordType,
|
|
162
|
+
* zoneId: production.zoneId,
|
|
163
|
+
* allowOverwrite: true,
|
|
164
|
+
* records: [range.value[0].recordValue],
|
|
165
|
+
* ttl: 60,
|
|
166
|
+
* }, {
|
|
167
|
+
* dependsOn: [exampleTlsSubscription],
|
|
168
|
+
* }));
|
|
169
|
+
* }
|
|
170
|
+
* });
|
|
171
|
+
* });
|
|
172
|
+
* // This is a resource that other resources can depend on if they require the certificate to be issued.
|
|
173
|
+
* // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached).
|
|
174
|
+
* const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, {
|
|
175
|
+
* dependsOn: [domainValidation],
|
|
176
|
+
* });
|
|
177
|
+
* // This data source lists all available configuration objects.
|
|
178
|
+
* // It uses a `default` attribute to narrow down the list to just one configuration object.
|
|
179
|
+
* // If the filtered list has a length that is not exactly one element, you'll see an error returned.
|
|
180
|
+
* // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below).
|
|
181
|
+
* //
|
|
182
|
+
* // IMPORTANT: Not all customers will have a 'default' configuration.
|
|
183
|
+
* // If you have issues filtering with `default = true`, then you may need another attribute.
|
|
184
|
+
* // Refer to the fastly_tls_configuration documentation for available attributes:
|
|
185
|
+
* // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional
|
|
186
|
+
* const defaultTls = fastly.getTlsConfiguration({
|
|
187
|
+
* "default": true,
|
|
188
|
+
* });
|
|
189
|
+
* // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple records...
|
|
190
|
+
* const apex = new aws.index.Route53Record("apex", {
|
|
191
|
+
* name: "example.com",
|
|
192
|
+
* records: .filter(record => record.recordType == "A").map(record => (record.recordValue)),
|
|
193
|
+
* ttl: 300,
|
|
194
|
+
* type: "A",
|
|
195
|
+
* zoneId: production.zoneId,
|
|
196
|
+
* });
|
|
197
|
+
* // NOTE: This subdomain matches our Fastly service because of the wildcard domain (`*.example.com`) that was added to the service.
|
|
198
|
+
* const subdomain = new aws.index.Route53Record("subdomain", {
|
|
199
|
+
* name: "test.example.com",
|
|
200
|
+
* records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)),
|
|
201
|
+
* ttl: 300,
|
|
202
|
+
* type: "CNAME",
|
|
203
|
+
* zoneId: production.zoneId,
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
15
207
|
* ## Import
|
|
16
208
|
*
|
|
17
209
|
* A subscription can be imported using its Fastly subscription ID, e.g.
|
package/tlsSubscription.js
CHANGED
|
@@ -16,6 +16,198 @@ const utilities = require("./utilities");
|
|
|
16
16
|
*
|
|
17
17
|
* The examples below demonstrate usage with AWS Route53 to configure DNS, and the `fastly.TlsSubscriptionValidation` resource to wait for validation to complete.
|
|
18
18
|
*
|
|
19
|
+
* ## Example Usage
|
|
20
|
+
*
|
|
21
|
+
* **Basic usage:**
|
|
22
|
+
*
|
|
23
|
+
* The following example demonstrates how to configure two subdomains (e.g. `a.example.com`, `b.example.com`).
|
|
24
|
+
*
|
|
25
|
+
* The workflow configures a `fastly.TlsSubscription` resource, then a `awsRoute53Record` resource for handling the creation of the 'challenge' DNS records (e.g. `_acme-challenge.a.example.com` and `_acme-challenge.b.example.com`).
|
|
26
|
+
*
|
|
27
|
+
* We configure the `fastly.TlsSubscriptionValidation` resource, which blocks other resources until the challenge DNS records have been validated by Fastly.
|
|
28
|
+
*
|
|
29
|
+
* Once the validation has been successful, the configured `fastly.getTlsConfiguration` data source will filter the available results looking for an appropriate TLS configuration object. If that filtering process is successful, then the subsequent `awsRoute53Record` resources (for configuring the subdomains) will be executed using the returned TLS configuration data.
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
33
|
+
* import * as aws from "@pulumi/aws";
|
|
34
|
+
* import * as fastly from "@pulumi/fastly";
|
|
35
|
+
* import * as std from "@pulumi/std";
|
|
36
|
+
*
|
|
37
|
+
* // NOTE: Creating a hosted zone will automatically create SOA/NS records.
|
|
38
|
+
* const production = new aws.index.Route53Zone("production", {name: "example.com"});
|
|
39
|
+
* const example = new aws.index.Route53domainsRegisteredDomain("example", {
|
|
40
|
+
* nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({
|
|
41
|
+
* name: entry.value,
|
|
42
|
+
* })),
|
|
43
|
+
* domainName: "example.com",
|
|
44
|
+
* });
|
|
45
|
+
* const subdomains = [
|
|
46
|
+
* "a.example.com",
|
|
47
|
+
* "b.example.com",
|
|
48
|
+
* ];
|
|
49
|
+
* const exampleServiceVcl = new fastly.ServiceVcl("example", {
|
|
50
|
+
* domains: subdomains.map((v, k) => ({key: k, value: v})).map(entry => ({
|
|
51
|
+
* name: entry.value,
|
|
52
|
+
* })),
|
|
53
|
+
* name: "example-service",
|
|
54
|
+
* backends: [{
|
|
55
|
+
* address: "127.0.0.1",
|
|
56
|
+
* name: "localhost",
|
|
57
|
+
* }],
|
|
58
|
+
* forceDestroy: true,
|
|
59
|
+
* });
|
|
60
|
+
* const exampleTlsSubscription = new fastly.TlsSubscription("example", {
|
|
61
|
+
* domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))),
|
|
62
|
+
* certificateAuthority: "lets-encrypt",
|
|
63
|
+
* });
|
|
64
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
65
|
+
* exampleTlsSubscription.domains.apply(domains => {
|
|
66
|
+
* for (const range of Object.entries(domains.reduce((__obj, domain) => ({ ...__obj, [domain]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${domain}`).map(obj => (obj)))[0] }))).map(([k, v]) => ({key: k, value: v}))) {
|
|
67
|
+
* domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, {
|
|
68
|
+
* name: range.value.recordName,
|
|
69
|
+
* type: range.value.recordType,
|
|
70
|
+
* zoneId: production.zoneId,
|
|
71
|
+
* allowOverwrite: true,
|
|
72
|
+
* records: [range.value.recordValue],
|
|
73
|
+
* ttl: 60,
|
|
74
|
+
* }, {
|
|
75
|
+
* dependsOn: [exampleTlsSubscription],
|
|
76
|
+
* }));
|
|
77
|
+
* }
|
|
78
|
+
* });
|
|
79
|
+
* // This is a resource that other resources can depend on if they require the certificate to be issued.
|
|
80
|
+
* // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached).
|
|
81
|
+
* const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, {
|
|
82
|
+
* dependsOn: [domainValidation],
|
|
83
|
+
* });
|
|
84
|
+
* // This data source lists all available configuration objects.
|
|
85
|
+
* // It uses a `default` attribute to narrow down the list to just one configuration object.
|
|
86
|
+
* // If the filtered list has a length that is not exactly one element, you'll see an error returned.
|
|
87
|
+
* // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below).
|
|
88
|
+
* //
|
|
89
|
+
* // IMPORTANT: Not all customers will have a 'default' configuration.
|
|
90
|
+
* // If you have issues filtering with `default = true`, then you may need another attribute.
|
|
91
|
+
* // Refer to the fastly_tls_configuration documentation for available attributes:
|
|
92
|
+
* // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional
|
|
93
|
+
* const defaultTls = fastly.getTlsConfiguration({
|
|
94
|
+
* "default": true,
|
|
95
|
+
* });
|
|
96
|
+
* // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple subdomain records.
|
|
97
|
+
* const subdomain: aws.index.Route53Record[] = [];
|
|
98
|
+
* for (const range = {value: 0}; range.value < std.index.toset({
|
|
99
|
+
* input: subdomains,
|
|
100
|
+
* }).result; range.value++) {
|
|
101
|
+
* subdomain.push(new aws.index.Route53Record(`subdomain-${range.value}`, {
|
|
102
|
+
* name: range.value,
|
|
103
|
+
* records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)),
|
|
104
|
+
* ttl: 300,
|
|
105
|
+
* type: "CNAME",
|
|
106
|
+
* zoneId: production.zoneId,
|
|
107
|
+
* }));
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* **Configuring an apex and a wildcard domain:**
|
|
112
|
+
*
|
|
113
|
+
* The following example is similar to the above but differs by demonstrating how to handle configuring an apex domain (e.g. `example.com`) and a wildcard domain (e.g. `*.example.com`) so you can support multiple subdomains to your service.
|
|
114
|
+
*
|
|
115
|
+
* The difference in the workflow is with how to handle the Fastly API returning a single 'challenge' for both domains (e.g. `_acme-challenge.example.com`). This is done by normalising the wildcard (i.e. replacing `*.example.com` with `example.com`) and then working around the issue of the returned object having two identical keys.
|
|
116
|
+
*
|
|
117
|
+
* ```typescript
|
|
118
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
119
|
+
* import * as aws from "@pulumi/aws";
|
|
120
|
+
* import * as fastly from "@pulumi/fastly";
|
|
121
|
+
* import * as std from "@pulumi/std";
|
|
122
|
+
*
|
|
123
|
+
* // NOTE: Creating a hosted zone will automatically create SOA/NS records.
|
|
124
|
+
* const production = new aws.index.Route53Zone("production", {name: "example.com"});
|
|
125
|
+
* const example = new aws.index.Route53domainsRegisteredDomain("example", {
|
|
126
|
+
* nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({
|
|
127
|
+
* name: entry.value,
|
|
128
|
+
* })),
|
|
129
|
+
* domainName: "example.com",
|
|
130
|
+
* });
|
|
131
|
+
* const domains = [
|
|
132
|
+
* "example.com",
|
|
133
|
+
* "*.example.com",
|
|
134
|
+
* ];
|
|
135
|
+
* const exampleServiceVcl = new fastly.ServiceVcl("example", {
|
|
136
|
+
* domains: domains.map((v, k) => ({key: k, value: v})).map(entry => ({
|
|
137
|
+
* name: entry.value,
|
|
138
|
+
* })),
|
|
139
|
+
* name: "example-service",
|
|
140
|
+
* backends: [{
|
|
141
|
+
* address: "127.0.0.1",
|
|
142
|
+
* name: "localhost",
|
|
143
|
+
* }],
|
|
144
|
+
* forceDestroy: true,
|
|
145
|
+
* });
|
|
146
|
+
* const exampleTlsSubscription = new fastly.TlsSubscription("example", {
|
|
147
|
+
* domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))),
|
|
148
|
+
* certificateAuthority: "lets-encrypt",
|
|
149
|
+
* });
|
|
150
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
151
|
+
* exampleTlsSubscription.domains.apply(domains => {
|
|
152
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
153
|
+
* pulumi.all(domains.reduce((__obj, domain) => ({ ...__obj, [std.index.replace({
|
|
154
|
+
* text: domain,
|
|
155
|
+
* search: "*.",
|
|
156
|
+
* replace: "",
|
|
157
|
+
* }).result]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${std.index.replace({
|
|
158
|
+
* text: domain,
|
|
159
|
+
* search: "*.",
|
|
160
|
+
* replace: "",
|
|
161
|
+
* }).result}`).map(obj => (obj)))[0] }))).apply(rangeBody => {
|
|
162
|
+
* for (const range of Object.entries(rangeBody).map(([k, v]) => ({key: k, value: v}))) {
|
|
163
|
+
* domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, {
|
|
164
|
+
* name: range.value[0].recordName,
|
|
165
|
+
* type: range.value[0].recordType,
|
|
166
|
+
* zoneId: production.zoneId,
|
|
167
|
+
* allowOverwrite: true,
|
|
168
|
+
* records: [range.value[0].recordValue],
|
|
169
|
+
* ttl: 60,
|
|
170
|
+
* }, {
|
|
171
|
+
* dependsOn: [exampleTlsSubscription],
|
|
172
|
+
* }));
|
|
173
|
+
* }
|
|
174
|
+
* });
|
|
175
|
+
* });
|
|
176
|
+
* // This is a resource that other resources can depend on if they require the certificate to be issued.
|
|
177
|
+
* // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached).
|
|
178
|
+
* const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, {
|
|
179
|
+
* dependsOn: [domainValidation],
|
|
180
|
+
* });
|
|
181
|
+
* // This data source lists all available configuration objects.
|
|
182
|
+
* // It uses a `default` attribute to narrow down the list to just one configuration object.
|
|
183
|
+
* // If the filtered list has a length that is not exactly one element, you'll see an error returned.
|
|
184
|
+
* // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below).
|
|
185
|
+
* //
|
|
186
|
+
* // IMPORTANT: Not all customers will have a 'default' configuration.
|
|
187
|
+
* // If you have issues filtering with `default = true`, then you may need another attribute.
|
|
188
|
+
* // Refer to the fastly_tls_configuration documentation for available attributes:
|
|
189
|
+
* // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional
|
|
190
|
+
* const defaultTls = fastly.getTlsConfiguration({
|
|
191
|
+
* "default": true,
|
|
192
|
+
* });
|
|
193
|
+
* // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple records...
|
|
194
|
+
* const apex = new aws.index.Route53Record("apex", {
|
|
195
|
+
* name: "example.com",
|
|
196
|
+
* records: .filter(record => record.recordType == "A").map(record => (record.recordValue)),
|
|
197
|
+
* ttl: 300,
|
|
198
|
+
* type: "A",
|
|
199
|
+
* zoneId: production.zoneId,
|
|
200
|
+
* });
|
|
201
|
+
* // NOTE: This subdomain matches our Fastly service because of the wildcard domain (`*.example.com`) that was added to the service.
|
|
202
|
+
* const subdomain = new aws.index.Route53Record("subdomain", {
|
|
203
|
+
* name: "test.example.com",
|
|
204
|
+
* records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)),
|
|
205
|
+
* ttl: 300,
|
|
206
|
+
* type: "CNAME",
|
|
207
|
+
* zoneId: production.zoneId,
|
|
208
|
+
* });
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
19
211
|
* ## Import
|
|
20
212
|
*
|
|
21
213
|
* A subscription can be imported using its Fastly subscription ID, e.g.
|
package/tlsSubscription.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tlsSubscription.js","sourceRoot":"","sources":["../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BAAiB,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC;YAC1D,cAAc,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC;YAC1C,cAAc,CAAC,cAAc,CAAC,GAAG,IAAI,EAAE,YAAY,CAAC;YACpD,cAAc,CAAC,aAAa,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC;YAClD,cAAc,CAAC,eAAe,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YACpD,cAAc,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAChD,cAAc,CAAC,qBAAqB,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC1D,cAAc,CAAC,sBAAsB,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC3D,cAAc,CAAC,uBAAuB,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC5D,cAAc,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC5C,cAAc,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;SACnD;QACD,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,IAAI,CAAC,CAAC;QACnE,KAAK,CAAC,eAAe,CAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;;AArIL,0CAsIC;AAxHG,gBAAgB;AACO,4BAAY,GAAG,8CAA8C,CAAC"}
|
|
@@ -5,6 +5,90 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
5
5
|
* Most commonly, this resource is used together with a resource for a DNS record and `fastly.TlsSubscription` to request a DNS validated certificate, deploy the required validation records and wait for validation to complete.
|
|
6
6
|
*
|
|
7
7
|
* > **Warning:** This resource implements a part of the validation workflow. It does not represent a real-world entity in Fastly, therefore changing or deleting this resource on its own has no immediate effect.
|
|
8
|
+
*
|
|
9
|
+
* ## Example Usage
|
|
10
|
+
*
|
|
11
|
+
* DNS Validation with AWS Route53:
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
15
|
+
* import * as aws from "@pulumi/aws";
|
|
16
|
+
* import * as fastly from "@pulumi/fastly";
|
|
17
|
+
* import * as std from "@pulumi/std";
|
|
18
|
+
*
|
|
19
|
+
* // NOTE: Creating a hosted zone will automatically create SOA/NS records.
|
|
20
|
+
* const production = new aws.index.Route53Zone("production", {name: "example.com"});
|
|
21
|
+
* const example = new aws.index.Route53domainsRegisteredDomain("example", {
|
|
22
|
+
* nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({
|
|
23
|
+
* name: entry.value,
|
|
24
|
+
* })),
|
|
25
|
+
* domainName: "example.com",
|
|
26
|
+
* });
|
|
27
|
+
* const subdomains = [
|
|
28
|
+
* "a.example.com",
|
|
29
|
+
* "b.example.com",
|
|
30
|
+
* ];
|
|
31
|
+
* const exampleServiceVcl = new fastly.ServiceVcl("example", {
|
|
32
|
+
* domains: subdomains.map((v, k) => ({key: k, value: v})).map(entry => ({
|
|
33
|
+
* name: entry.value,
|
|
34
|
+
* })),
|
|
35
|
+
* name: "example-service",
|
|
36
|
+
* backends: [{
|
|
37
|
+
* address: "127.0.0.1",
|
|
38
|
+
* name: "localhost",
|
|
39
|
+
* }],
|
|
40
|
+
* forceDestroy: true,
|
|
41
|
+
* });
|
|
42
|
+
* const exampleTlsSubscription = new fastly.TlsSubscription("example", {
|
|
43
|
+
* domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))),
|
|
44
|
+
* certificateAuthority: "lets-encrypt",
|
|
45
|
+
* });
|
|
46
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
47
|
+
* exampleTlsSubscription.domains.apply(domains => {
|
|
48
|
+
* for (const range of Object.entries(domains.reduce((__obj, domain) => ({ ...__obj, [domain]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${domain}`).map(obj => (obj)))[0] }))).map(([k, v]) => ({key: k, value: v}))) {
|
|
49
|
+
* domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, {
|
|
50
|
+
* name: range.value.recordName,
|
|
51
|
+
* type: range.value.recordType,
|
|
52
|
+
* zoneId: production.zoneId,
|
|
53
|
+
* allowOverwrite: true,
|
|
54
|
+
* records: [range.value.recordValue],
|
|
55
|
+
* ttl: 60,
|
|
56
|
+
* }, {
|
|
57
|
+
* dependsOn: [exampleTlsSubscription],
|
|
58
|
+
* }));
|
|
59
|
+
* }
|
|
60
|
+
* });
|
|
61
|
+
* // This is a resource that other resources can depend on if they require the certificate to be issued.
|
|
62
|
+
* // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached).
|
|
63
|
+
* const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, {
|
|
64
|
+
* dependsOn: [domainValidation],
|
|
65
|
+
* });
|
|
66
|
+
* // This data source lists all available configuration objects.
|
|
67
|
+
* // It uses a `default` attribute to narrow down the list to just one configuration object.
|
|
68
|
+
* // If the filtered list has a length that is not exactly one element, you'll see an error returned.
|
|
69
|
+
* // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below).
|
|
70
|
+
* //
|
|
71
|
+
* // IMPORTANT: Not all customers will have a 'default' configuration.
|
|
72
|
+
* // If you have issues filtering with `default = true`, then you may need another attribute.
|
|
73
|
+
* // Refer to the fastly_tls_configuration documentation for available attributes:
|
|
74
|
+
* // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional
|
|
75
|
+
* const defaultTls = fastly.getTlsConfiguration({
|
|
76
|
+
* "default": true,
|
|
77
|
+
* });
|
|
78
|
+
* // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple subdomain records.
|
|
79
|
+
* const subdomain: aws.index.Route53Record[] = [];
|
|
80
|
+
* for (const range = {value: 0}; range.value < std.index.toset({
|
|
81
|
+
* input: subdomains,
|
|
82
|
+
* }).result; range.value++) {
|
|
83
|
+
* subdomain.push(new aws.index.Route53Record(`subdomain-${range.value}`, {
|
|
84
|
+
* name: range.value,
|
|
85
|
+
* records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)),
|
|
86
|
+
* ttl: 300,
|
|
87
|
+
* type: "CNAME",
|
|
88
|
+
* zoneId: production.zoneId,
|
|
89
|
+
* }));
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
8
92
|
*/
|
|
9
93
|
export declare class TlsSubscriptionValidation extends pulumi.CustomResource {
|
|
10
94
|
/**
|
|
@@ -11,6 +11,90 @@ const utilities = require("./utilities");
|
|
|
11
11
|
* Most commonly, this resource is used together with a resource for a DNS record and `fastly.TlsSubscription` to request a DNS validated certificate, deploy the required validation records and wait for validation to complete.
|
|
12
12
|
*
|
|
13
13
|
* > **Warning:** This resource implements a part of the validation workflow. It does not represent a real-world entity in Fastly, therefore changing or deleting this resource on its own has no immediate effect.
|
|
14
|
+
*
|
|
15
|
+
* ## Example Usage
|
|
16
|
+
*
|
|
17
|
+
* DNS Validation with AWS Route53:
|
|
18
|
+
*
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
21
|
+
* import * as aws from "@pulumi/aws";
|
|
22
|
+
* import * as fastly from "@pulumi/fastly";
|
|
23
|
+
* import * as std from "@pulumi/std";
|
|
24
|
+
*
|
|
25
|
+
* // NOTE: Creating a hosted zone will automatically create SOA/NS records.
|
|
26
|
+
* const production = new aws.index.Route53Zone("production", {name: "example.com"});
|
|
27
|
+
* const example = new aws.index.Route53domainsRegisteredDomain("example", {
|
|
28
|
+
* nameServer: Object.entries(production.nameServers).map(([k, v]) => ({key: k, value: v})).map(entry => ({
|
|
29
|
+
* name: entry.value,
|
|
30
|
+
* })),
|
|
31
|
+
* domainName: "example.com",
|
|
32
|
+
* });
|
|
33
|
+
* const subdomains = [
|
|
34
|
+
* "a.example.com",
|
|
35
|
+
* "b.example.com",
|
|
36
|
+
* ];
|
|
37
|
+
* const exampleServiceVcl = new fastly.ServiceVcl("example", {
|
|
38
|
+
* domains: subdomains.map((v, k) => ({key: k, value: v})).map(entry => ({
|
|
39
|
+
* name: entry.value,
|
|
40
|
+
* })),
|
|
41
|
+
* name: "example-service",
|
|
42
|
+
* backends: [{
|
|
43
|
+
* address: "127.0.0.1",
|
|
44
|
+
* name: "localhost",
|
|
45
|
+
* }],
|
|
46
|
+
* forceDestroy: true,
|
|
47
|
+
* });
|
|
48
|
+
* const exampleTlsSubscription = new fastly.TlsSubscription("example", {
|
|
49
|
+
* domains: exampleServiceVcl.domains.apply(domains => .map(domain => (domain.name))),
|
|
50
|
+
* certificateAuthority: "lets-encrypt",
|
|
51
|
+
* });
|
|
52
|
+
* const domainValidation: aws.index.Route53Record[] = [];
|
|
53
|
+
* exampleTlsSubscription.domains.apply(domains => {
|
|
54
|
+
* for (const range of Object.entries(domains.reduce((__obj, domain) => ({ ...__obj, [domain]: exampleTlsSubscription.managedDnsChallenges.apply(managedDnsChallenges => managedDnsChallenges.filter(obj => obj.recordName == `_acme-challenge.${domain}`).map(obj => (obj)))[0] }))).map(([k, v]) => ({key: k, value: v}))) {
|
|
55
|
+
* domainValidation.push(new aws.index.Route53Record(`domain_validation-${range.key}`, {
|
|
56
|
+
* name: range.value.recordName,
|
|
57
|
+
* type: range.value.recordType,
|
|
58
|
+
* zoneId: production.zoneId,
|
|
59
|
+
* allowOverwrite: true,
|
|
60
|
+
* records: [range.value.recordValue],
|
|
61
|
+
* ttl: 60,
|
|
62
|
+
* }, {
|
|
63
|
+
* dependsOn: [exampleTlsSubscription],
|
|
64
|
+
* }));
|
|
65
|
+
* }
|
|
66
|
+
* });
|
|
67
|
+
* // This is a resource that other resources can depend on if they require the certificate to be issued.
|
|
68
|
+
* // NOTE: Internally the resource keeps retrying `GetTLSSubscription` until no error is returned (or the configured timeout is reached).
|
|
69
|
+
* const exampleTlsSubscriptionValidation = new fastly.TlsSubscriptionValidation("example", {subscriptionId: exampleTlsSubscription.id}, {
|
|
70
|
+
* dependsOn: [domainValidation],
|
|
71
|
+
* });
|
|
72
|
+
* // This data source lists all available configuration objects.
|
|
73
|
+
* // It uses a `default` attribute to narrow down the list to just one configuration object.
|
|
74
|
+
* // If the filtered list has a length that is not exactly one element, you'll see an error returned.
|
|
75
|
+
* // The single TLS configuration is then returned and can be referenced by other resources (see aws_route53_record below).
|
|
76
|
+
* //
|
|
77
|
+
* // IMPORTANT: Not all customers will have a 'default' configuration.
|
|
78
|
+
* // If you have issues filtering with `default = true`, then you may need another attribute.
|
|
79
|
+
* // Refer to the fastly_tls_configuration documentation for available attributes:
|
|
80
|
+
* // https://registry.terraform.io/providers/fastly/fastly/latest/docs/data-sources/tls_configuration#optional
|
|
81
|
+
* const defaultTls = fastly.getTlsConfiguration({
|
|
82
|
+
* "default": true,
|
|
83
|
+
* });
|
|
84
|
+
* // Once validation is complete and we've retrieved the TLS configuration data, we can create multiple subdomain records.
|
|
85
|
+
* const subdomain: aws.index.Route53Record[] = [];
|
|
86
|
+
* for (const range = {value: 0}; range.value < std.index.toset({
|
|
87
|
+
* input: subdomains,
|
|
88
|
+
* }).result; range.value++) {
|
|
89
|
+
* subdomain.push(new aws.index.Route53Record(`subdomain-${range.value}`, {
|
|
90
|
+
* name: range.value,
|
|
91
|
+
* records: .filter(record => record.recordType == "CNAME").map(record => (record.recordValue)),
|
|
92
|
+
* ttl: 300,
|
|
93
|
+
* type: "CNAME",
|
|
94
|
+
* zoneId: production.zoneId,
|
|
95
|
+
* }));
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
14
98
|
*/
|
|
15
99
|
class TlsSubscriptionValidation extends pulumi.CustomResource {
|
|
16
100
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tlsSubscriptionValidation.js","sourceRoot":"","sources":["../tlsSubscriptionValidation.ts"],"names":[],"mappings":";AAAA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